@tempots/std 0.16.1 → 0.18.0
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.js +4 -4
- package/deferred.d.ts +1 -1
- package/function.cjs +1 -1
- package/function.js +6 -6
- package/package.json +1 -1
- package/timer.cjs +1 -1
- package/timer.d.ts +3 -3
- package/timer.js +16 -16
package/array.js
CHANGED
|
@@ -46,7 +46,7 @@ const q = (t, n) => Array.from({ length: t.length }, (e, r) => n(t[r], r)), B =
|
|
|
46
46
|
if (a !== 0) return a;
|
|
47
47
|
}
|
|
48
48
|
return 0;
|
|
49
|
-
}, C = (t, n) => t.slice().sort(n),
|
|
49
|
+
}, C = (t, n) => t.slice().sort(n), d = (t, n) => Array.from({ length: t }, (e, r) => n(r)), L = (t, n = 0) => d(t, (e) => n + e), R = (t, n) => d(t, () => n), V = (t) => Array.from(new Set(t)), W = (t, n) => {
|
|
50
50
|
const e = {};
|
|
51
51
|
return t.forEach((r) => {
|
|
52
52
|
e[n(r)] = r;
|
|
@@ -98,8 +98,8 @@ const q = (t, n) => Array.from({ length: t.length }, (e, r) => n(t[r], r)), B =
|
|
|
98
98
|
for (let s = 0; s < A.length; s++) {
|
|
99
99
|
const o = e(A[s]), i = m.get(o);
|
|
100
100
|
if (i == null || s === i) continue;
|
|
101
|
-
const
|
|
102
|
-
m.delete(
|
|
101
|
+
const g = e(p[s]);
|
|
102
|
+
m.delete(g), u.push({ from: s, to: i });
|
|
103
103
|
}
|
|
104
104
|
return r;
|
|
105
105
|
}, U = (t, n) => {
|
|
@@ -144,7 +144,7 @@ export {
|
|
|
144
144
|
D as flattenArray,
|
|
145
145
|
P as foldLeftArray,
|
|
146
146
|
T as forEachElement,
|
|
147
|
-
|
|
147
|
+
d as generateArray,
|
|
148
148
|
L as generateSequenceArray,
|
|
149
149
|
I as isArrayEmpty,
|
|
150
150
|
X as joinArrayWithConjunction,
|
package/deferred.d.ts
CHANGED
package/function.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=e=>e,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=e=>e,n=e=>t=>(...r)=>e(t,...r),o=e=>{let t;return()=>(t===void 0&&(t=e()),t)};exports.curryLeft=n;exports.identity=i;exports.memoize=o;
|
package/function.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
let
|
|
3
|
-
return () => (
|
|
1
|
+
const r = (e) => e, i = (e) => (t) => (...n) => e(t, ...n), o = (e) => {
|
|
2
|
+
let t;
|
|
3
|
+
return () => (t === void 0 && (t = e()), t);
|
|
4
4
|
};
|
|
5
5
|
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
i as curryLeft,
|
|
7
|
+
r as identity,
|
|
8
|
+
o as memoize
|
|
9
9
|
};
|
package/package.json
CHANGED
package/timer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=(e,t)=>{const n=setTimeout(e,t);return()=>clearTimeout(n)},w=(e,t)=>{const n=setInterval(e,t);return()=>clearInterval(n)},b=(e,t,n={})=>{const{noTrailing:s=!1,noLeading:u=!1,debounceMode:c}=n;let o,f=!1,i=0;function d(){o&&clearTimeout(o)}function g(a){const{upcomingOnly:r=!1}=a||{};d(),f=!r}function m(...a){if(f)return;const r=this,T=Date.now()-i;function l(){i=Date.now(),t.apply(r,a)}function p(){o=void 0}!u&&c&&!o&&l(),d(),c===void 0&&T>e?u?(i=Date.now(),s||(o=setTimeout(c?p:l,e))):l():s||(o=setTimeout(c?p:l,c===void 0?e-T:e))}return m.cancel=g,m},D=(e,t,{atBegin:n=!1}={})=>b(e,t,{debounceMode:n!==!1});exports.debounce=D;exports.delayed=v;exports.interval=w;exports.throttle=b;
|
package/timer.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
8
|
* // Delay a function for 1 second
|
|
9
|
-
* const cancel = delayed(() => console.
|
|
9
|
+
* const cancel = delayed(() => console.warn('Hello!'), 1000);
|
|
10
10
|
*
|
|
11
11
|
* // Cancel the delayed execution if needed
|
|
12
12
|
* cancel();
|
|
@@ -22,7 +22,7 @@ export declare const delayed: (fn: () => void, ms: number) => () => void;
|
|
|
22
22
|
* @example
|
|
23
23
|
* ```ts
|
|
24
24
|
* // Execute a function every 2 seconds
|
|
25
|
-
* const stop = interval(() => console.
|
|
25
|
+
* const stop = interval(() => console.warn('Tick'), 2000);
|
|
26
26
|
*
|
|
27
27
|
* // Stop the interval after some time
|
|
28
28
|
* setTimeout(() => stop(), 10000);
|
|
@@ -102,7 +102,7 @@ export interface ThrottledFunction<T extends unknown[]> {
|
|
|
102
102
|
* ```ts
|
|
103
103
|
* // Create a throttled function that executes at most once every second
|
|
104
104
|
* const throttledScroll = throttle(1000, () => {
|
|
105
|
-
* console.
|
|
105
|
+
* console.warn('Scroll event handled');
|
|
106
106
|
* });
|
|
107
107
|
*
|
|
108
108
|
* // Attach to scroll event
|
package/timer.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
return () => clearTimeout(
|
|
4
|
-
},
|
|
5
|
-
const
|
|
6
|
-
return () => clearInterval(
|
|
7
|
-
},
|
|
8
|
-
const { noTrailing: r = !1, noLeading: u = !1, debounceMode: c } =
|
|
1
|
+
const x = (e, n) => {
|
|
2
|
+
const t = setTimeout(e, n);
|
|
3
|
+
return () => clearTimeout(t);
|
|
4
|
+
}, D = (e, n) => {
|
|
5
|
+
const t = setInterval(e, n);
|
|
6
|
+
return () => clearInterval(t);
|
|
7
|
+
}, w = (e, n, t = {}) => {
|
|
8
|
+
const { noTrailing: r = !1, noLeading: u = !1, debounceMode: c } = t;
|
|
9
9
|
let o, f = !1, l = 0;
|
|
10
10
|
function d() {
|
|
11
11
|
o && clearTimeout(o);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function g(s) {
|
|
14
14
|
const { upcomingOnly: a = !1 } = s || {};
|
|
15
15
|
d(), f = !a;
|
|
16
16
|
}
|
|
@@ -18,7 +18,7 @@ const w = (e, t) => {
|
|
|
18
18
|
if (f) return;
|
|
19
19
|
const a = this, p = Date.now() - l;
|
|
20
20
|
function i() {
|
|
21
|
-
l = Date.now(),
|
|
21
|
+
l = Date.now(), n.apply(a, s);
|
|
22
22
|
}
|
|
23
23
|
function T() {
|
|
24
24
|
o = void 0;
|
|
@@ -28,11 +28,11 @@ const w = (e, t) => {
|
|
|
28
28
|
c === void 0 ? e - p : e
|
|
29
29
|
));
|
|
30
30
|
}
|
|
31
|
-
return m.cancel =
|
|
32
|
-
},
|
|
31
|
+
return m.cancel = g, m;
|
|
32
|
+
}, b = (e, n, { atBegin: t = !1 } = {}) => w(e, n, { debounceMode: t !== !1 });
|
|
33
33
|
export {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
b as debounce,
|
|
35
|
+
x as delayed,
|
|
36
|
+
D as interval,
|
|
37
|
+
w as throttle
|
|
38
38
|
};
|