@t007/utils 0.0.36 → 0.0.37
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/dist/{chunk-ZOFWWRKV.js → chunk-4S4VEQL7.js} +2 -2
- package/dist/{chunk-DSDFIB5F.js → chunk-7TIUDIEW.js} +1 -1
- package/dist/hooks/react.js +5 -5
- package/dist/hooks/vanilla.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -206,10 +206,10 @@ function RAFLoop(key, fn, signal, win) {
|
|
|
206
206
|
}
|
|
207
207
|
var cancelRAFLoop = (key) => t007._RAFLoopers ? t007._RAFLoopers.delete(key) : false;
|
|
208
208
|
function limited(FN_KEY, fn, opts = {}) {
|
|
209
|
-
let count = 0, { key, maxTimes: max = 1,
|
|
209
|
+
let count = 0, { key, maxTimes: max = 1, perSession = key != null } = isStr(opts) ? { key: opts } : opts;
|
|
210
210
|
const getReg = () => JSON.parse(localStorage.getItem(FN_KEY) || "{}"), setReg = (r) => localStorage.setItem(FN_KEY, JSON.stringify(r));
|
|
211
211
|
const handle = (...args) => {
|
|
212
|
-
if (
|
|
212
|
+
if (perSession && count >= +perSession) return;
|
|
213
213
|
if (!key) return count++ < max ? fn(...args) : void 0;
|
|
214
214
|
const r = getReg(), c = r[key] || 0;
|
|
215
215
|
return c < max ? (count++, r[key] = c + 1, setReg(r), fn(...args)) : void 0;
|
package/dist/hooks/react.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useHighlight
|
|
3
|
-
} from "../chunk-RXMKMD3E.js";
|
|
4
1
|
import {
|
|
5
2
|
DEFAULT_CONFIG,
|
|
6
3
|
H_NAV_KEYS,
|
|
@@ -11,11 +8,14 @@ import {
|
|
|
11
8
|
initFocusTrap,
|
|
12
9
|
initOutsideClick,
|
|
13
10
|
rippleHandler
|
|
14
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-7TIUDIEW.js";
|
|
15
12
|
import {
|
|
16
13
|
INTERACTIVE_SELECTOR,
|
|
17
14
|
getActiveEl
|
|
18
|
-
} from "../chunk-
|
|
15
|
+
} from "../chunk-4S4VEQL7.js";
|
|
16
|
+
import {
|
|
17
|
+
useHighlight
|
|
18
|
+
} from "../chunk-RXMKMD3E.js";
|
|
19
19
|
|
|
20
20
|
// src/ts/hooks/react/useScrollAssist.ts
|
|
21
21
|
import { useEffect, useRef, useCallback } from "react";
|
package/dist/hooks/vanilla.js
CHANGED
|
@@ -11,12 +11,12 @@ import {
|
|
|
11
11
|
removeOutsideClick,
|
|
12
12
|
rippleHandler,
|
|
13
13
|
syncFocusTrap
|
|
14
|
-
} from "../chunk-
|
|
14
|
+
} from "../chunk-7TIUDIEW.js";
|
|
15
15
|
import {
|
|
16
16
|
INTERACTIVE_SELECTOR,
|
|
17
17
|
createEl,
|
|
18
18
|
getActiveEl
|
|
19
|
-
} from "../chunk-
|
|
19
|
+
} from "../chunk-4S4VEQL7.js";
|
|
20
20
|
|
|
21
21
|
// src/ts/hooks/vanilla/scrollAssist.ts
|
|
22
22
|
import { NIL } from "sia-reactor";
|
package/dist/index.cjs
CHANGED
|
@@ -292,10 +292,10 @@ function RAFLoop(key, fn, signal, win) {
|
|
|
292
292
|
}
|
|
293
293
|
var cancelRAFLoop = (key) => t007._RAFLoopers ? t007._RAFLoopers.delete(key) : false;
|
|
294
294
|
function limited(FN_KEY, fn, opts = {}) {
|
|
295
|
-
let count = 0, { key, maxTimes: max = 1,
|
|
295
|
+
let count = 0, { key, maxTimes: max = 1, perSession = key != null } = isStr(opts) ? { key: opts } : opts;
|
|
296
296
|
const getReg = () => JSON.parse(localStorage.getItem(FN_KEY) || "{}"), setReg = (r) => localStorage.setItem(FN_KEY, JSON.stringify(r));
|
|
297
297
|
const handle = (...args) => {
|
|
298
|
-
if (
|
|
298
|
+
if (perSession && count >= +perSession) return;
|
|
299
299
|
if (!key) return count++ < max ? fn(...args) : void 0;
|
|
300
300
|
const r = getReg(), c = r[key] || 0;
|
|
301
301
|
return c < max ? (count++, r[key] = c + 1, setReg(r), fn(...args)) : void 0;
|
package/dist/index.d.cts
CHANGED
|
@@ -182,8 +182,8 @@ interface LimitedOptions {
|
|
|
182
182
|
key?: string;
|
|
183
183
|
/** Maximum number of allowed calls. @default 1 */
|
|
184
184
|
maxTimes?: number;
|
|
185
|
-
/** Only allow calling
|
|
186
|
-
|
|
185
|
+
/** Only allow calling x times per session, regardless of maxTimes. @default true */
|
|
186
|
+
perSession?: boolean | number;
|
|
187
187
|
}
|
|
188
188
|
interface LimitedHandle<T extends (...args: any[]) => any> {
|
|
189
189
|
/** Call the wrapped function with the original arguments. */
|
package/dist/index.d.ts
CHANGED
|
@@ -182,8 +182,8 @@ interface LimitedOptions {
|
|
|
182
182
|
key?: string;
|
|
183
183
|
/** Maximum number of allowed calls. @default 1 */
|
|
184
184
|
maxTimes?: number;
|
|
185
|
-
/** Only allow calling
|
|
186
|
-
|
|
185
|
+
/** Only allow calling x times per session, regardless of maxTimes. @default true */
|
|
186
|
+
perSession?: boolean | number;
|
|
187
187
|
}
|
|
188
188
|
interface LimitedHandle<T extends (...args: any[]) => any> {
|
|
189
189
|
/** Call the wrapped function with the original arguments. */
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@t007/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"description": "High-performance utilities for the t007 ecosystem.",
|
|
5
5
|
"author": "Oketade Oluwatobiloba <tobioketade007@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"react-dom": "^18.3.1"
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
|
-
"sia-reactor": "^0.0.
|
|
79
|
+
"sia-reactor": "^0.0.38"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"react": "^18.0.0"
|