@cardsgame/utils
Advanced tools
Comparing version 0.1.13 to 0.1.14
@@ -0,1 +1,2 @@ | ||
export * from "./arrays"; | ||
export * from "./events"; | ||
@@ -2,0 +3,0 @@ export * from "./mapSchema"; |
@@ -6,2 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__export(require("./arrays")); | ||
__export(require("./events")); | ||
@@ -8,0 +9,0 @@ __export(require("./mapSchema")); |
@@ -9,2 +9,7 @@ /** | ||
/** | ||
* Call each function with the current argument and the result is use for the next call | ||
* @param initial value to be passed through the pipeline | ||
*/ | ||
export declare const compose: (value: any, ...functions: ((...args: any[]) => any)[]) => any; | ||
/** | ||
* Executes function multiple times | ||
@@ -11,0 +16,0 @@ * @param length number of times function will be exetuced |
@@ -13,2 +13,23 @@ "use strict"; | ||
/** | ||
* Call each function with the current argument and the result is use for the next call | ||
* @param initial value to be passed through the pipeline | ||
*/ | ||
exports.compose = function (value) { | ||
var functions = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
functions[_i - 1] = arguments[_i]; | ||
} | ||
return functions.reduce(function (arg, fn) { | ||
if (typeof fn === "function") { | ||
return fn(arg); | ||
} | ||
else if (typeof fn === "undefined") { | ||
return arg; | ||
} | ||
else { | ||
throw new Error("utils/compose, I expected a function here, got \"" + typeof fn + "\" instead..."); | ||
} | ||
}, value); | ||
}; | ||
/** | ||
* Executes function multiple times | ||
@@ -15,0 +36,0 @@ * @param length number of times function will be exetuced |
{ | ||
"name": "@cardsgame/utils", | ||
"version": "0.1.13", | ||
"version": "0.1.14", | ||
"description": "", | ||
@@ -21,3 +21,3 @@ "main": "lib/index.js", | ||
}, | ||
"gitHead": "ffb389831a9aa7be3967d047b16187cf2efc53fc" | ||
"gitHead": "ac661e983fa7fff451c8301ebbca6567e6ad97d5" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
17948
27
289