JSFiddle - React, Tailwind, and code Playground
JavaScript
var MySQL = function(){
DatabaseInterface(this);
};
MySQL.prototype.connect = function(dsn,user,pass,option){
//
};
MySQL.prototype.prepare = function(query){
//
};
MySQL.prototype.find = function(table,column,condition){
//
};
MySQL.prototype.save = function(table,column,condition){
//
};
new MySQL;
function DatabaseInterface(con){
if(!'connect' in con || !getParamNames(con.connect) == "dsn,user,pass,option")
throw new Error("This method is not correctly overwritten1!");
if(!'prepare' in con || !getParamNames(con.prepare) == "query")
throw new Error("This method is not correctly overwritten2!");
if(!'find' in con || !getParamNames(con.find) == "table,column,condition")
throw new Error("This method is not correctly overwritten3!");
if(!'save' in con || !getParamNames(con.save) == "table,column,condition")
throw new Error("This method is not correctly overwritten4!");
}
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
function getParamNames(func) {
var fnStr = func.toString().replace(STRIP_COMMENTS, '')
var result = fnStr.slice(fnStr.indexOf('(')+1, fnStr.indexOf(')')).match(/([^\s,]+)/g)
if(result === null)
result = []
return result
}