Skip to content

Commit

Permalink
Initial deposit
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Dec 11, 2014
1 parent 4002458 commit 98fc489
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
40 changes: 40 additions & 0 deletions 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;
};
11 changes: 11 additions & 0 deletions 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"
}

0 comments on commit 98fc489

Please sign in to comment.