hooks-mixin
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -1,1 +0,1 @@ | ||
'use strict';function hook(a,b){if(!(a&&'string'==typeof a))throw new TypeError('name should be non empty string');if('function'!=typeof b)throw new TypeError('fn is not a function');this.__hooks||(this.__hooks={}),this.__hooks[a]||(this.__hooks[a]=[]),this.__hooks[a].push(b)}function getHooks(a,b){return a.__hooks&&a.__hooks[b]?a.__hooks[b]:null}function removeHook(a,b){var c=getHooks(this,a);if(!c)return null;var d=c.indexOf(b);return-1===d?null:(c.splice(d,1),b)}function getHookArguments(a,b){var c=Array.from(b);return c.shift(),c.push(a),c}function processHooks(a){var b=getHooks(this,a);if(b){var c=getHookArguments(this,arguments),d=!0,e=!1,f=void 0;try{for(var g,h,i=b[Symbol.iterator]();!(d=(g=i.next()).done);d=!0)h=g.value,h.apply(null,c)}catch(a){e=!0,f=a}finally{try{!d&&i.return&&i.return()}finally{if(e)throw f}}}}function processHooksAsync(a){var b=getHooks(this,a);if(b){var c=getHookArguments(this,arguments);return Promise.all(b.map(function(a){return a.apply(null,c)}))}}module.exports=function(a){return a.prototype.hook=hook,a.prototype.removeHook=removeHook,a.prototype.processHooks=processHooks,a.prototype.processHooksAsync=processHooksAsync,a}; | ||
"use strict";function hook(a,b){if(!(a&&"string"==typeof a))throw new TypeError("name should be non empty string");if("function"!=typeof b)throw new TypeError("fn is not a function");this.__hooks||(this.__hooks={}),this.__hooks[a]||(this.__hooks[a]=[]),this.__hooks[a].push(b)}function getHooks(a,b){return a.__hooks&&a.__hooks[b]?a.__hooks[b]:null}function removeHook(a,b){var c=getHooks(this,a);if(!c)return null;var d=c.indexOf(b);return-1===d?null:(c.splice(d,1),b)}function getHookArguments(a,b){var c=Array.from(b);return c.shift(),c.push(a),c}function processHooks(a){var b=getHooks(this,a);if(b){var c=getHookArguments(this,arguments),d=!0,e=!1,f=void 0;try{for(var g,h,i=b[Symbol.iterator]();!(d=(g=i.next()).done);d=!0)h=g.value,h.apply(null,c)}catch(a){e=!0,f=a}finally{try{d||null==i["return"]||i["return"]()}finally{if(e)throw f}}}}function processHooksAsync(a){var b=getHooks(this,a);if(b){var c=getHookArguments(this,arguments);return Promise.all(b.map(function(a){return a.apply(null,c)}))}}module.exports=function(a){return a.prototype.hook=hook,a.prototype.removeHook=removeHook,a.prototype.processHooks=processHooks,a.prototype.processHooksAsync=processHooksAsync,a}; |
{ | ||
"name": "hooks-mixin", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "A small mixin for classes. Adds hooks ability to your classes", | ||
@@ -15,3 +15,3 @@ "main": "index.js", | ||
"scripts": { | ||
"build": "NODE_ENV=production ./node_modules/babel-cli/bin/babel.js index.js -d build/", | ||
"build": "NODE_ENV=production ./node_modules/.bin/babel index.js -d build/", | ||
"test": "jest", | ||
@@ -22,9 +22,10 @@ "tarball": "tarball=\"$(npm pack .)\"; wc -c \"${tarball}\"; tar tvf \"${tarball}\"; rm \"${tarball}\";", | ||
"devDependencies": { | ||
"babel-cli": "^6.26.0", | ||
"babel-eslint": "^8.2.1", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-minify": "^0.4.0", | ||
"eslint": "^4.15.0", | ||
"jest": "^22.4.3" | ||
"@babel/cli": "^7.5.0", | ||
"@babel/core": "^7.5.4", | ||
"@babel/preset-env": "^7.5.4", | ||
"babel-eslint": "^10.0.2", | ||
"babel-preset-minify": "^0.5.0", | ||
"eslint": "^6.0.1", | ||
"jest": "^24.8.0" | ||
} | ||
} |
6775
7