lib0 0.2.101 → 0.2.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/array.d.ts +1 -0
- package/array.d.ts.map +1 -1
- package/array.js +36 -0
- package/array.test.d.ts +2 -0
- package/array.test.d.ts.map +1 -1
- package/coverage/tmp/coverage-131665-1744412653331-0.json +1 -0
- package/dist/aes-gcm.cjs +4 -4
- package/dist/{array-8d6422a6.cjs → array-df2f5859.cjs} +40 -2
- package/dist/array-df2f5859.cjs.map +1 -0
- package/dist/array.cjs +2 -1
- package/dist/array.cjs.map +1 -1
- package/dist/array.d.ts +1 -0
- package/dist/array.d.ts.map +1 -1
- package/dist/array.test.d.ts +2 -0
- package/dist/array.test.d.ts.map +1 -1
- package/dist/{broadcastchannel-a4555c37.cjs → broadcastchannel-90ed6188.cjs} +2 -2
- package/dist/{broadcastchannel-a4555c37.cjs.map → broadcastchannel-90ed6188.cjs.map} +1 -1
- package/dist/broadcastchannel.cjs +8 -8
- package/dist/{buffer-6e426aed.cjs → buffer-8fda3816.cjs} +6 -6
- package/dist/{buffer-6e426aed.cjs.map → buffer-8fda3816.cjs.map} +1 -1
- package/dist/buffer.cjs +7 -7
- package/dist/cache.cjs +2 -2
- package/dist/component.cjs +4 -4
- package/dist/{decoding-2c98f95d.cjs → decoding-ec031c24.cjs} +3 -3
- package/dist/{decoding-2c98f95d.cjs.map → decoding-ec031c24.cjs.map} +1 -1
- package/dist/decoding.cjs +4 -4
- package/dist/{diff-2825aafb.cjs → diff-1498c2c4.cjs} +2 -2
- package/dist/{diff-2825aafb.cjs.map → diff-1498c2c4.cjs.map} +1 -1
- package/dist/diff.cjs +3 -3
- package/dist/{encoding-559e49f1.cjs → encoding-8ccbade2.cjs} +3 -3
- package/dist/{encoding-559e49f1.cjs.map → encoding-8ccbade2.cjs.map} +1 -1
- package/dist/encoding.cjs +3 -3
- package/dist/{environment-95824d14.cjs → environment-e0a40d7b.cjs} +3 -3
- package/dist/{environment-95824d14.cjs.map → environment-e0a40d7b.cjs.map} +1 -1
- package/dist/environment.cjs +4 -4
- package/dist/{eventloop-d0571621.cjs → eventloop-b299a889.cjs} +28 -6
- package/dist/eventloop-b299a889.cjs.map +1 -0
- package/dist/eventloop.cjs +4 -1
- package/dist/eventloop.cjs.map +1 -1
- package/dist/eventloop.d.ts +1 -1
- package/dist/eventloop.d.ts.map +1 -1
- package/dist/eventloop.test.d.ts +2 -0
- package/dist/eventloop.test.d.ts.map +1 -1
- package/dist/{function-932685da.cjs → function-6d805aac.cjs} +2 -2
- package/dist/{function-932685da.cjs.map → function-6d805aac.cjs.map} +1 -1
- package/dist/function.cjs +2 -2
- package/dist/index.cjs +12 -12
- package/dist/jwt.cjs +7 -7
- package/dist/list.cjs +2 -2
- package/dist/logging.cjs +6 -6
- package/dist/logging.common.cjs +4 -4
- package/dist/logging.node.cjs +4 -4
- package/dist/observable.cjs +1 -1
- package/dist/performance.node.cjs +2 -2
- package/dist/{prng-ffbde921.cjs → prng-af7307f5.cjs} +3 -3
- package/dist/{prng-ffbde921.cjs.map → prng-af7307f5.cjs.map} +1 -1
- package/dist/prng.cjs +8 -8
- package/dist/rabin-gf2-polynomial.cjs +7 -7
- package/dist/rabin-uncached.cjs +7 -7
- package/dist/rabin.cjs +7 -7
- package/dist/{string-d07c212b.cjs → string-95449d68.cjs} +2 -2
- package/dist/{string-d07c212b.cjs.map → string-95449d68.cjs.map} +1 -1
- package/dist/string.cjs +2 -2
- package/dist/testing.cjs +9 -9
- package/dist/{websocket-9495c37b.cjs → websocket-cae5df8e.cjs} +1 -1
- package/dist/{websocket-9495c37b.cjs.map → websocket-cae5df8e.cjs.map} +1 -1
- package/dist/websocket.cjs +2 -2
- package/eventloop.d.ts +1 -1
- package/eventloop.d.ts.map +1 -1
- package/eventloop.js +27 -5
- package/eventloop.test.d.ts +2 -0
- package/eventloop.test.d.ts.map +1 -1
- package/package.json +1 -1
- package/test.html +1 -1
- package/coverage/tmp/coverage-7197-1742897575185-0.json +0 -1
- package/dist/array-8d6422a6.cjs.map +0 -1
- package/dist/eventloop-d0571621.cjs.map +0 -1
package/eventloop.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* global requestIdleCallback, requestAnimationFrame, cancelIdleCallback, cancelAnimationFrame */
|
|
2
2
|
|
|
3
|
+
import * as time from './time.js'
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Utility module to work with EcmaScript's event loop.
|
|
5
7
|
*
|
|
@@ -93,14 +95,34 @@ export const idleCallback = cb => typeof requestIdleCallback !== 'undefined' ? n
|
|
|
93
95
|
|
|
94
96
|
/**
|
|
95
97
|
* @param {number} timeout Timeout of the debounce action
|
|
96
|
-
* @
|
|
98
|
+
* @param {number} triggerAfter Optional. Trigger callback after a certain amount of time
|
|
99
|
+
* without waiting for debounce.
|
|
97
100
|
*/
|
|
98
|
-
export const createDebouncer = timeout => {
|
|
101
|
+
export const createDebouncer = (timeout, triggerAfter = -1) => {
|
|
99
102
|
let timer = -1
|
|
100
|
-
|
|
103
|
+
/**
|
|
104
|
+
* @type {number?}
|
|
105
|
+
*/
|
|
106
|
+
let lastCall = null
|
|
107
|
+
/**
|
|
108
|
+
* @param {((...args: any)=>void)?} cb function to trigger after debounce. If null, it will reset the
|
|
109
|
+
* debounce.
|
|
110
|
+
*/
|
|
111
|
+
return cb => {
|
|
101
112
|
clearTimeout(timer)
|
|
102
|
-
if (
|
|
103
|
-
|
|
113
|
+
if (cb) {
|
|
114
|
+
if (triggerAfter >= 0) {
|
|
115
|
+
const now = time.getUnixTime()
|
|
116
|
+
if (lastCall === null) lastCall = now
|
|
117
|
+
if (now - lastCall > triggerAfter) {
|
|
118
|
+
lastCall = null
|
|
119
|
+
timer = /** @type {any} */ (setTimeout(cb, 0))
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
timer = /** @type {any} */ (setTimeout(() => { lastCall = null; cb() }, timeout))
|
|
124
|
+
} else {
|
|
125
|
+
lastCall = null
|
|
104
126
|
}
|
|
105
127
|
}
|
|
106
128
|
}
|
package/eventloop.test.d.ts
CHANGED
|
@@ -4,5 +4,7 @@ export function testInterval(_tc: t.TestCase): Promise<void>;
|
|
|
4
4
|
export function testAnimationFrame(_tc: t.TestCase): Promise<void>;
|
|
5
5
|
export function testIdleCallback(_tc: t.TestCase): Promise<void>;
|
|
6
6
|
export function testDebouncer(_tc: t.TestCase): Promise<void>;
|
|
7
|
+
export function testDebouncerTriggerAfter(_tc: t.TestCase): Promise<void>;
|
|
8
|
+
export function testDebouncerClear(_tc: t.TestCase): Promise<void>;
|
|
7
9
|
import * as t from './testing.js';
|
|
8
10
|
//# sourceMappingURL=eventloop.test.d.ts.map
|
package/eventloop.test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventloop.test.d.ts","sourceRoot":"","sources":["eventloop.test.js"],"names":[],"mappings":"AAOO,wCAFI,EAAE,QAAQ,yBAkBpB;AAKM,iCAFI,EAAE,QAAQ,iBAYpB;AAKM,kCAFI,EAAE,QAAQ,iBAepB;AAKM,wCAFI,EAAE,QAAQ,iBAOpB;AAKM,sCAFI,EAAE,QAAQ,iBAMpB;AAKM,mCAFI,EAAE,QAAQ,iBAcpB;
|
|
1
|
+
{"version":3,"file":"eventloop.test.d.ts","sourceRoot":"","sources":["eventloop.test.js"],"names":[],"mappings":"AAOO,wCAFI,EAAE,QAAQ,yBAkBpB;AAKM,iCAFI,EAAE,QAAQ,iBAYpB;AAKM,kCAFI,EAAE,QAAQ,iBAepB;AAKM,wCAFI,EAAE,QAAQ,iBAOpB;AAKM,sCAFI,EAAE,QAAQ,iBAMpB;AAKM,mCAFI,EAAE,QAAQ,iBAcpB;AAKM,+CAFI,EAAE,QAAQ,iBAyBpB;AAKM,wCAFI,EAAE,QAAQ,iBAyBpB;mBAnJkB,cAAc"}
|
package/package.json
CHANGED
package/test.html
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lib0/component": "./component.js",
|
|
29
29
|
"lib0/conditions.js": "./conditions.js",
|
|
30
30
|
"lib0/dist/conditions.cjs": "./dist/conditions.cjs",
|
|
31
|
-
"lib0/conditions": "./
|
|
31
|
+
"lib0/conditions": "./conditions.js",
|
|
32
32
|
"lib0/crypto/jwt": "./crypto/jwt.js",
|
|
33
33
|
"lib0/crypto/aes-gcm": "./crypto/aes-gcm.js",
|
|
34
34
|
"lib0/crypto/ecdsa": "./crypto/ecdsa.js",
|