diff --git a/index.js b/index.js new file mode 100644 index 0000000..576bdd4 --- /dev/null +++ b/index.js @@ -0,0 +1,40 @@ +function Kareem() { + this._pres = {}; + this._posts = {}; +} + +Kareem.prototype.execPre = function(name, context, arguments) { + +}; + +Kareem.prototype.pre = function(name, isAsync, fn, error) { + if ('boolean' !== typeof arguments[1]) { + errorCallback = callback; + callback = isAsync; + isAsync = false; + } + + this._pres[name] = this._pres[name] || []; + var pres = this._pres[name]; + + if (isAsync) { + pres.numAsync = pres.numAsync || 0; + ++pres.numAsync; + } + + fn.isAsync = isAsync; + this._pres.push(fn); + + return this; +}; + +Kareem.prototype.post = function(name, isAsync, fn) { + if (arguments.length === 2) { + fn = isAsync; + isAsync = false; + } + + fn.isAsync = isAsync; + (this._posts[name] = this._posts[name] || []).push(fn); + return this; +}; diff --git a/package.json b/package.json new file mode 100644 index 0000000..ca89e8f --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "kareem", + "version": "0.0.0", + "description": "Next-generation hooks", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +}