debounce-queue
Advanced tools
Comparing version 0.2.2 to 0.3.0
17
index.js
@@ -1,3 +0,1 @@ | ||
const defaultEnqueue = require('./enqueue'); | ||
module.exports = function debounceQueue(callback, opts = {}) { | ||
@@ -17,19 +15,8 @@ if (typeof callback !== 'function') { | ||
const enqueue = opts.enqueue || defaultEnqueue; | ||
const maxWait = opts.maxWait || (delay + 2000); | ||
let time = new Date(); | ||
function debounced(data) { | ||
function debounced(...args) { | ||
if (sleeping) return; | ||
const queueCopy = queue.slice() | ||
const ret = enqueue(data, queueCopy, (_data = data, queue = queueCopy) => defaultEnqueue(_data, queue)); | ||
if (!(ret instanceof Array)) { | ||
throw new Error('opts.enqueue must return a modified queue array'); | ||
} else { | ||
// if (ret.length < queue.length) { | ||
// console.warn('WARNING: Returned queue has fewer items than the original'); | ||
// } | ||
queue = ret; | ||
} | ||
queue.push(args); | ||
if (new Date(time + maxWait) < new Date()) { | ||
@@ -36,0 +23,0 @@ setNextTimer(); |
{ | ||
"name": "debounce-queue", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "Like lodash.debounce but you get an array of all previous (unique) events", | ||
"repository": "laggingreflex/debounce-queue" | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
2806
3
54