worker-timers-broker
Advanced tools
Comparing version 7.0.3 to 7.1.0
export declare const load: (url: string) => { | ||
clearInterval: (timerId: number) => void; | ||
clearTimeout: (timerId: number) => void; | ||
setInterval: (func: Function, delay?: number) => number; | ||
setTimeout: (func: Function, delay?: number) => number; | ||
setInterval: (func: Function, delay?: number, ...args: any[]) => number; | ||
setTimeout: (func: Function, delay?: number, ...args: any[]) => number; | ||
}; | ||
//# sourceMappingURL=module.d.ts.map |
@@ -94,6 +94,6 @@ import { generateUniqueNumber } from 'fast-unique-numbers'; | ||
}; | ||
const setInterval = (func, delay = 0) => { | ||
const setInterval = (func, delay = 0, ...args) => { | ||
const timerId = generateUniqueNumber(scheduledIntervalFunctions); | ||
scheduledIntervalFunctions.set(timerId, () => { | ||
func(); | ||
func(...args); | ||
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func(). | ||
@@ -125,5 +125,5 @@ if (typeof scheduledIntervalFunctions.get(timerId) === 'function') { | ||
}; | ||
const setTimeout = (func, delay = 0) => { | ||
const setTimeout = (func, delay = 0, ...args) => { | ||
const timerId = generateUniqueNumber(scheduledTimeoutFunctions); | ||
scheduledTimeoutFunctions.set(timerId, func); | ||
scheduledTimeoutFunctions.set(timerId, () => func(...args)); | ||
worker.postMessage({ | ||
@@ -130,0 +130,0 @@ id: null, |
@@ -113,5 +113,8 @@ (function (global, factory) { | ||
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
args[_key - 2] = arguments[_key]; | ||
} | ||
var timerId = fastUniqueNumbers.generateUniqueNumber(scheduledIntervalFunctions); | ||
scheduledIntervalFunctions.set(timerId, function () { | ||
func(); | ||
func.apply(void 0, args); | ||
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func(). | ||
@@ -145,4 +148,9 @@ if (typeof scheduledIntervalFunctions.get(timerId) === 'function') { | ||
var delay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { | ||
args[_key2 - 2] = arguments[_key2]; | ||
} | ||
var timerId = fastUniqueNumbers.generateUniqueNumber(scheduledTimeoutFunctions); | ||
scheduledTimeoutFunctions.set(timerId, func); | ||
scheduledTimeoutFunctions.set(timerId, function () { | ||
return func.apply(void 0, args); | ||
}); | ||
worker.postMessage({ | ||
@@ -149,0 +157,0 @@ id: null, |
@@ -19,3 +19,3 @@ { | ||
"devDependencies": { | ||
"@babel/core": "^7.24.8", | ||
"@babel/core": "^7.24.9", | ||
"@babel/plugin-external-helpers": "^7.24.7", | ||
@@ -47,3 +47,3 @@ "@babel/plugin-transform-runtime": "^7.24.7", | ||
"mocha": "^10.6.0", | ||
"prettier": "^3.3.2", | ||
"prettier": "^3.3.3", | ||
"rimraf": "^5.0.8", | ||
@@ -85,3 +85,3 @@ "rollup": "^4.18.1", | ||
"types": "build/es2019/module.d.ts", | ||
"version": "7.0.3" | ||
"version": "7.1.0" | ||
} |
@@ -121,7 +121,7 @@ import { generateUniqueNumber } from 'fast-unique-numbers'; | ||
const setInterval = (func: Function, delay = 0) => { | ||
const setInterval = (func: Function, delay = 0, ...args: any[]) => { | ||
const timerId = generateUniqueNumber(scheduledIntervalFunctions); | ||
scheduledIntervalFunctions.set(timerId, () => { | ||
func(); | ||
func(...args); | ||
@@ -157,6 +157,6 @@ // Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func(). | ||
const setTimeout = (func: Function, delay = 0) => { | ||
const setTimeout = (func: Function, delay = 0, ...args: any[]) => { | ||
const timerId = generateUniqueNumber(scheduledTimeoutFunctions); | ||
scheduledTimeoutFunctions.set(timerId, func); | ||
scheduledTimeoutFunctions.set(timerId, () => func(...args)); | ||
@@ -163,0 +163,0 @@ worker.postMessage(<ISetNotification>{ |
Sorry, the diff of this file is not supported yet
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
32474
494