timeout-flow 0.0.18 → 0.0.19
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/ADDITIONAL_TERMS.md +122 -0
- package/LICENSE +694 -0
- package/README.md +307 -332
- package/package.json +68 -59
- package/robots.txt +79 -3
- package/src/AfterTimer.js +81 -81
- package/src/EveryTimer.js +208 -208
- package/src/TimeoutFlow.js +400 -400
- package/src/TimerBase.js +132 -132
- package/src/abort.js +74 -74
- package/src/after.js +32 -32
- package/src/debounce.js +105 -105
- package/src/every.js +34 -34
- package/src/index.js +23 -23
- package/src/now.js +22 -22
- package/src/parseDuration.js +46 -46
- package/src/raf/ReadMe-Raf.md +94 -94
- package/src/raf/afterRaf.js +203 -203
- package/src/raf/debounceRaf.js +126 -126
- package/src/raf/everyRaf.js +316 -316
- package/src/raf/index.js +27 -27
- package/src/raf/throttleRaf.js +181 -181
- package/src/raf/waitForRaf.js +100 -100
- package/src/resolveDelayAndFn.js +89 -89
- package/src/retry.js +163 -163
- package/src/throttle.js +141 -141
- package/src/waitFor.js +76 -76
- package/LICENSE.MD +0 -285
- package/src/context-js.bat +0 -58
- package/src/context.txt +0 -2604
package/package.json
CHANGED
|
@@ -1,60 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "timeout-flow",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "Fluent, composable, pauseable JavaScript timers and time control flows — plus RAF utilities for frame-based logic.",
|
|
6
|
-
"keywords": [
|
|
7
|
-
"timeout",
|
|
8
|
-
"interval",
|
|
9
|
-
"flow",
|
|
10
|
-
"raf",
|
|
11
|
-
"animationframe",
|
|
12
|
-
"debounce",
|
|
13
|
-
"retry",
|
|
14
|
-
"javascript",
|
|
15
|
-
"timers",
|
|
16
|
-
"throttle",
|
|
17
|
-
"asynchronous",
|
|
18
|
-
"control-flow",
|
|
19
|
-
"utilities"
|
|
20
|
-
],
|
|
21
|
-
"author": "
|
|
22
|
-
"license": "
|
|
23
|
-
"repository": {
|
|
24
|
-
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/iWhatty/TimeoutFlow-js.git"
|
|
26
|
-
},
|
|
27
|
-
"sideEffects": false,
|
|
28
|
-
"main": "./dist/timeout-flow.min.js",
|
|
29
|
-
"module": "./src/index.js",
|
|
30
|
-
"browser": "./dist/timeout-flow.min.js",
|
|
31
|
-
"exports": {
|
|
32
|
-
".": {
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
"src/",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"types"
|
|
53
|
-
"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "timeout-flow",
|
|
3
|
+
"version": "0.0.19",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Fluent, composable, pauseable JavaScript timers and time control flows — plus RAF utilities for frame-based logic.",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"timeout",
|
|
8
|
+
"interval",
|
|
9
|
+
"flow",
|
|
10
|
+
"raf",
|
|
11
|
+
"animationframe",
|
|
12
|
+
"debounce",
|
|
13
|
+
"retry",
|
|
14
|
+
"javascript",
|
|
15
|
+
"timers",
|
|
16
|
+
"throttle",
|
|
17
|
+
"asynchronous",
|
|
18
|
+
"control-flow",
|
|
19
|
+
"utilities"
|
|
20
|
+
],
|
|
21
|
+
"author": "WATT3D <WATT3D@protonmail.com>",
|
|
22
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/iWhatty/TimeoutFlow-js.git"
|
|
26
|
+
},
|
|
27
|
+
"sideEffects": false,
|
|
28
|
+
"main": "./dist/timeout-flow.min.js",
|
|
29
|
+
"module": "./src/index.js",
|
|
30
|
+
"browser": "./dist/timeout-flow.min.js",
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./types/index.d.ts",
|
|
34
|
+
"import": "./src/index.js",
|
|
35
|
+
"require": "./dist/timeout-flow.min.js",
|
|
36
|
+
"default": "./src/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./after": "./src/after.js",
|
|
39
|
+
"./every": "./src/every.js",
|
|
40
|
+
"./debounce": "./src/debounce.js",
|
|
41
|
+
"./throttle": "./src/throttle.js",
|
|
42
|
+
"./retry": "./src/retry.js",
|
|
43
|
+
"./wait-for": "./src/waitFor.js",
|
|
44
|
+
"./flow": "./src/TimeoutFlow.js",
|
|
45
|
+
"./parse-duration": "./src/parseDuration.js",
|
|
46
|
+
"./raf": "./src/raf/index.js",
|
|
47
|
+
"./min": "./dist/timeout-flow.min.js"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist/",
|
|
51
|
+
"src/",
|
|
52
|
+
"types/",
|
|
53
|
+
"robots.txt",
|
|
54
|
+
"ADDITIONAL_TERMS.md"
|
|
55
|
+
],
|
|
56
|
+
"types": "./types/index.d.ts",
|
|
57
|
+
"scripts": {
|
|
58
|
+
"dev": "serve testing",
|
|
59
|
+
"test:node": "node testing/node-harness.mjs",
|
|
60
|
+
"build": "node build.js",
|
|
61
|
+
"types": "tsc",
|
|
62
|
+
"prepub": "npm run build && npm run types"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"esbuild": "^0.25.3",
|
|
66
|
+
"serve": "^14.2.4",
|
|
67
|
+
"typescript": "^5.8.3"
|
|
68
|
+
}
|
|
60
69
|
}
|
package/robots.txt
CHANGED
|
@@ -1,3 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# WATT3D — AI scraping policy
|
|
2
|
+
#
|
|
3
|
+
# This file enumerates known AI / LLM training and inference crawlers
|
|
4
|
+
# that the WATT3D AI Training Rider does not consent to. See
|
|
5
|
+
# ./ADDITIONAL_TERMS.md for the legal scope and definitions.
|
|
6
|
+
#
|
|
7
|
+
# Honoring robots.txt is voluntary. The rider applies whether or not
|
|
8
|
+
# a bot respects this file. The enumeration is non-exhaustive — bots
|
|
9
|
+
# not listed here are still bound by the rider if they perform
|
|
10
|
+
# Training Use as defined in ADDITIONAL_TERMS.md §1.
|
|
11
|
+
|
|
12
|
+
User-agent: GPTBot
|
|
13
|
+
Disallow: /
|
|
14
|
+
|
|
15
|
+
User-agent: ChatGPT-User
|
|
16
|
+
Disallow: /
|
|
17
|
+
|
|
18
|
+
User-agent: OAI-SearchBot
|
|
19
|
+
Disallow: /
|
|
20
|
+
|
|
21
|
+
User-agent: anthropic-ai
|
|
22
|
+
Disallow: /
|
|
23
|
+
|
|
24
|
+
User-agent: ClaudeBot
|
|
25
|
+
Disallow: /
|
|
26
|
+
|
|
27
|
+
User-agent: Claude-Web
|
|
28
|
+
Disallow: /
|
|
29
|
+
|
|
30
|
+
User-agent: Claude-SearchBot
|
|
31
|
+
Disallow: /
|
|
32
|
+
|
|
33
|
+
User-agent: Google-Extended
|
|
34
|
+
Disallow: /
|
|
35
|
+
|
|
36
|
+
User-agent: Applebot-Extended
|
|
37
|
+
Disallow: /
|
|
38
|
+
|
|
39
|
+
User-agent: Meta-ExternalAgent
|
|
40
|
+
Disallow: /
|
|
41
|
+
|
|
42
|
+
User-agent: Meta-ExternalFetcher
|
|
43
|
+
Disallow: /
|
|
44
|
+
|
|
45
|
+
User-agent: FacebookBot
|
|
46
|
+
Disallow: /
|
|
47
|
+
|
|
48
|
+
User-agent: CCBot
|
|
49
|
+
Disallow: /
|
|
50
|
+
|
|
51
|
+
User-agent: PerplexityBot
|
|
52
|
+
Disallow: /
|
|
53
|
+
|
|
54
|
+
User-agent: Perplexity-User
|
|
55
|
+
Disallow: /
|
|
56
|
+
|
|
57
|
+
User-agent: cohere-ai
|
|
58
|
+
Disallow: /
|
|
59
|
+
|
|
60
|
+
User-agent: Bytespider
|
|
61
|
+
Disallow: /
|
|
62
|
+
|
|
63
|
+
User-agent: Amazonbot
|
|
64
|
+
Disallow: /
|
|
65
|
+
|
|
66
|
+
User-agent: Omgilibot
|
|
67
|
+
Disallow: /
|
|
68
|
+
|
|
69
|
+
User-agent: AI2Bot
|
|
70
|
+
Disallow: /
|
|
71
|
+
|
|
72
|
+
User-agent: Diffbot
|
|
73
|
+
Disallow: /
|
|
74
|
+
|
|
75
|
+
# Everyone else: full access. Search engines and human-driven crawlers
|
|
76
|
+
# remain welcome.
|
|
77
|
+
|
|
78
|
+
User-agent: *
|
|
79
|
+
Allow: /
|
package/src/AfterTimer.js
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
// ./src/AfterTimer.js
|
|
2
|
-
import { TimerBase } from './TimerBase.js';
|
|
3
|
-
import { attachAbort } from './abort.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Executes a function once after a delay.
|
|
7
|
-
*/
|
|
8
|
-
export class AfterTimer extends TimerBase {
|
|
9
|
-
/** @type {AbortSignal | null} */
|
|
10
|
-
#signal = null;
|
|
11
|
-
|
|
12
|
-
/** @type {(() => void) | null} */
|
|
13
|
-
#onAbort = null;
|
|
14
|
-
|
|
15
|
-
/** @type {() => void} */
|
|
16
|
-
#cleanupAbort = () => { };
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* @param {string|number} duration - Delay before firing (e.g., '1s', 300)
|
|
20
|
-
* @param {Function} fn - Main function to execute
|
|
21
|
-
* @param {Object} [options]
|
|
22
|
-
* @param {Function} [options.onFinish] - Optional callback when done
|
|
23
|
-
* @param {AbortSignal} [options.signal] - Optional AbortSignal to auto-cancel
|
|
24
|
-
*/
|
|
25
|
-
constructor(duration, fn, { onFinish, signal } = {}) {
|
|
26
|
-
super(duration);
|
|
27
|
-
|
|
28
|
-
this.#signal = signal ?? null;
|
|
29
|
-
this.#onAbort = () => this.cancel();
|
|
30
|
-
|
|
31
|
-
this.#attachAbort();
|
|
32
|
-
|
|
33
|
-
// If already aborted, #attachAbort() will have canceled us.
|
|
34
|
-
if (this.isFinished) return;
|
|
35
|
-
|
|
36
|
-
this.resume(() => {
|
|
37
|
-
this.#cleanupAbortListener();
|
|
38
|
-
fn?.();
|
|
39
|
-
onFinish?.();
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
#attachAbort() {
|
|
44
|
-
if (!this.#signal || !this.#onAbort) return;
|
|
45
|
-
|
|
46
|
-
// If already aborted, terminate immediately.
|
|
47
|
-
if (this.#signal.aborted) {
|
|
48
|
-
super.cancel();
|
|
49
|
-
this.#cleanupAbortListener();
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
this.#cleanupAbort = attachAbort(this.#signal, this.#onAbort);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
#cleanupAbortListener() {
|
|
57
|
-
this.#cleanupAbort();
|
|
58
|
-
this.#cleanupAbort = () => { };
|
|
59
|
-
|
|
60
|
-
// Keep signal reference so reset() can reattach.
|
|
61
|
-
this.#onAbort = null;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
cancel() {
|
|
65
|
-
if (this.isFinished) return;
|
|
66
|
-
|
|
67
|
-
// Remove listener first to avoid keeping instance alive.
|
|
68
|
-
this.#cleanupAbortListener();
|
|
69
|
-
|
|
70
|
-
super.cancel();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
reset() {
|
|
74
|
-
// Preserve AbortSignal semantics.
|
|
75
|
-
this.#cleanupAbort();
|
|
76
|
-
this.#cleanupAbort = () => { };
|
|
77
|
-
this.#onAbort = () => this.cancel();
|
|
78
|
-
|
|
79
|
-
super.reset();
|
|
80
|
-
this.#attachAbort();
|
|
81
|
-
}
|
|
1
|
+
// ./src/AfterTimer.js
|
|
2
|
+
import { TimerBase } from './TimerBase.js';
|
|
3
|
+
import { attachAbort } from './abort.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Executes a function once after a delay.
|
|
7
|
+
*/
|
|
8
|
+
export class AfterTimer extends TimerBase {
|
|
9
|
+
/** @type {AbortSignal | null} */
|
|
10
|
+
#signal = null;
|
|
11
|
+
|
|
12
|
+
/** @type {(() => void) | null} */
|
|
13
|
+
#onAbort = null;
|
|
14
|
+
|
|
15
|
+
/** @type {() => void} */
|
|
16
|
+
#cleanupAbort = () => { };
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @param {string|number} duration - Delay before firing (e.g., '1s', 300)
|
|
20
|
+
* @param {Function} fn - Main function to execute
|
|
21
|
+
* @param {Object} [options]
|
|
22
|
+
* @param {Function} [options.onFinish] - Optional callback when done
|
|
23
|
+
* @param {AbortSignal} [options.signal] - Optional AbortSignal to auto-cancel
|
|
24
|
+
*/
|
|
25
|
+
constructor(duration, fn, { onFinish, signal } = {}) {
|
|
26
|
+
super(duration);
|
|
27
|
+
|
|
28
|
+
this.#signal = signal ?? null;
|
|
29
|
+
this.#onAbort = () => this.cancel();
|
|
30
|
+
|
|
31
|
+
this.#attachAbort();
|
|
32
|
+
|
|
33
|
+
// If already aborted, #attachAbort() will have canceled us.
|
|
34
|
+
if (this.isFinished) return;
|
|
35
|
+
|
|
36
|
+
this.resume(() => {
|
|
37
|
+
this.#cleanupAbortListener();
|
|
38
|
+
fn?.();
|
|
39
|
+
onFinish?.();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
#attachAbort() {
|
|
44
|
+
if (!this.#signal || !this.#onAbort) return;
|
|
45
|
+
|
|
46
|
+
// If already aborted, terminate immediately.
|
|
47
|
+
if (this.#signal.aborted) {
|
|
48
|
+
super.cancel();
|
|
49
|
+
this.#cleanupAbortListener();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.#cleanupAbort = attachAbort(this.#signal, this.#onAbort);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
#cleanupAbortListener() {
|
|
57
|
+
this.#cleanupAbort();
|
|
58
|
+
this.#cleanupAbort = () => { };
|
|
59
|
+
|
|
60
|
+
// Keep signal reference so reset() can reattach.
|
|
61
|
+
this.#onAbort = null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
cancel() {
|
|
65
|
+
if (this.isFinished) return;
|
|
66
|
+
|
|
67
|
+
// Remove listener first to avoid keeping instance alive.
|
|
68
|
+
this.#cleanupAbortListener();
|
|
69
|
+
|
|
70
|
+
super.cancel();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
reset() {
|
|
74
|
+
// Preserve AbortSignal semantics.
|
|
75
|
+
this.#cleanupAbort();
|
|
76
|
+
this.#cleanupAbort = () => { };
|
|
77
|
+
this.#onAbort = () => this.cancel();
|
|
78
|
+
|
|
79
|
+
super.reset();
|
|
80
|
+
this.#attachAbort();
|
|
81
|
+
}
|
|
82
82
|
}
|