@aspectron/flow-async
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -13,2 +13,35 @@ const fasync = { }; | ||
/** | ||
* debounce provided function for given time | ||
* @param {String} name key name to debounce function | ||
* @param {Number} time time in milliseconds for delay | ||
* @param {Function} fn a function to debounce | ||
* @return {Object} a reference to debounced function | ||
* @since 0.0.1 | ||
*/ | ||
fasync._debounce = new Map(); | ||
fasync.debounce = (name, time, fn)=>{ | ||
if(typeof time == 'function'){ | ||
let _fn = fn; | ||
fn = time; | ||
time = _fn; | ||
} | ||
if(fasync._debounce.has(name)) | ||
fasync._debounce.get(name).cancel(); | ||
fasync._debounce.set(name, { | ||
id:setTimeout(fn, time), | ||
cancel(){ | ||
if(this.id){ | ||
clearTimeout(this.id) | ||
this.id = null; | ||
} | ||
} | ||
}) | ||
return fasync._debounce.get(name); | ||
} | ||
fasync.Semaphore = class Semaphore extends Promise { | ||
@@ -15,0 +48,0 @@ constructor(name) { |
{ | ||
"name": "@aspectron/flow-async", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Async Utility Functions", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
8101
243