Procházet zdrojové kódy

added context parameter to promisify

mightyplow před 8 roky
rodič
revize
259bfdf64c
2 změnil soubory, kde provedl 3 přidání a 3 odebrání
  1. 2 2
      lib/function.js
  2. 1 1
      package.json

+ 2 - 2
lib/function.js

@@ -24,7 +24,7 @@ const curry = fn => {
 
 const combine = argsToArray(fns => fns.reverse().reduce((fnc, fn) => val => fnc(fn(val))));
 
-const promisify = fn => () => {
+const promisify = (fn, context = null) => () => {
     // copy passed arguments to a new array
     const args = toArray(arguments);
 
@@ -39,7 +39,7 @@ const promisify = fn => () => {
         });
 
         // call the original function with our callback flavoured arguments
-        fn.apply(null, args);
+        fn.apply(context, args);
     });
 };
 

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@mightyplow/jslib",
-  "version": "0.2.3",
+  "version": "0.2.4",
   "description": "js, helpers library",
   "main": "jslib.js",
   "devDependencies": {