function-overloader
Advanced tools
Comparing version 1.1.0 to 1.2.0
{ | ||
"name": "function-overloader", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "improve overloading functions and methods in js", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -176,4 +176,12 @@ # FUNCTION OVERLOADER | ||
## Debugger | ||
For easy debug this library run your script with | ||
``` | ||
DEBUG=Overloader <command to run> | ||
``` | ||
## License | ||
MIT |
@@ -0,1 +1,2 @@ | ||
import debug from "debug"; | ||
/** | ||
@@ -12,3 +13,5 @@ * Class representing helper for methods for simplify overloading | ||
constructor() { | ||
this._debug = debug("overloader"); | ||
this._args = Array.from(arguments); | ||
this._debug("constructor get arguments ", this._args); | ||
this._enabled = true; | ||
@@ -26,2 +29,3 @@ this._result = null; | ||
when() { | ||
this._debug("when", Array.from(arguments)); | ||
let checkCondition = false; | ||
@@ -44,7 +48,13 @@ if (arguments.length === 0 && this._args.length === 0) { | ||
} | ||
this._debug("result", checkCondition); | ||
return { | ||
do: callback => { | ||
this._debug("do"); | ||
if (checkCondition && this._enabled) { | ||
this._debug("execute function"); | ||
this._enabled = false; | ||
this._result = callback(...this._args); | ||
let result = callback(...this._args); | ||
this._debug("function sync result", result); | ||
this._result = result; | ||
} | ||
@@ -51,0 +61,0 @@ return this; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69400
355
187