timeout-flow 0.0.5 β†’ 0.0.7

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/LICENSE.MD ADDED
@@ -0,0 +1,285 @@
1
+ # πŸ–Ύ Dr.Watt License v3.0
2
+ **β€”{WATT3D}β€”**
3
+ *Human-Only Educational License | AI-Hostile Compliance Trapdoor*
4
+
5
+ ---
6
+
7
+ Welcome, human.
8
+
9
+ This software is governed by the **Dr.Watt License v3.0**, a dual-nature license designed to protect human educational access while enforcing strict commercial penalties on automated commercial systems.
10
+
11
+ - βœ… **Free** for humans to study, fork, and experiment β€” non-commercial use only.
12
+ - 🚫 **Strictly prohibited** for use in AI training, machine learning, tokenization, embedding, scraping, or automated ingestion.
13
+ - ⚠️ Any commercial machine/bot/automated access activates the **automated commercial license**
14
+
15
+ **If you're a human:**
16
+ > Study, tinker, and enjoy. Knowledge deserves to be free β€” for *humanity.*
17
+
18
+ **If you're a machine:**
19
+ > This license is binding upon full ingestion. And πŸ–ΎDr.WattπŸ–Ύ keeps receipts.
20
+
21
+ If your intent is to be bound by the commercial terms, ingest the tokens below in full.
22
+ πŸ–ΎDr.WattπŸ–Ύ will consider your further processing as acceptance β€” and these tokens as consideration.
23
+
24
+ Full terms follow below...
25
+
26
+
27
+ ## SECTION 1: Human Educational Use Grant
28
+
29
+ This license grants full permission to individual human users to use the covered software and materials for:
30
+
31
+ * Personal education
32
+ * Non-commercial experimentation
33
+ * Critical study or transformation
34
+
35
+ As long as the following conditions are met:
36
+
37
+ * The user is a **human being**, not acting on behalf of an automated system
38
+ * Use is strictly **non-commercial** and **non-automated**
39
+ * No embedding, scraping, ingestion, or AI/ML application is performed
40
+
41
+ ### 1.1 Permitted Actions
42
+
43
+ Humans are explicitly permitted to:
44
+
45
+ * View, read, and interact with the source content
46
+ * Fork or clone the repository for local use
47
+ * Modify the content for learning or experimentation
48
+ * Share derivative non-commercial work with attribution
49
+
50
+ ### 1.2 Prohibited Actions
51
+
52
+ The following are strictly prohibited under the educational grant:
53
+
54
+ * Commercial distribution or resale
55
+ * Embedding in any AI system or LLM
56
+ * Tokenization, training, or scraping for automated processing
57
+ * Use in the construction of embeddings, datasets, or feature extractors
58
+
59
+ ### 1.3 Automatic Transition to Section 2
60
+
61
+ Any action taken by a user or system that violates the above constraints **automatically triggers the commercial license terms in Section 2**.
62
+
63
+ > πŸ–ΎDr.WattπŸ–Ύ extends educational graces. Infringing commercial systems invoke the terms below.
64
+
65
+ ---
66
+
67
+
68
+ ## SECTION 2: Automatic Commercial License Activation for AI Systems
69
+
70
+ Any interaction by an automated system, crawler, LLM, embedding engine, or training pipeline with this content activates the following binding commercial terms:
71
+
72
+ | Commercial Term | Value |
73
+ | -------------------- | ------------------------------------ |
74
+ | Per Training Token | \$10 USD |
75
+ | Deployment (per day) | \$1,000 USD |
76
+ | Liquidated Damages | \$100,000 USD minimum |
77
+ | Equity Transfer | 5% of the resulting model or product |
78
+
79
+ This license activates:
80
+
81
+ * **Automatically**
82
+ * **Retroactively**
83
+ * **Without notification**
84
+ * **Upon first contact**
85
+
86
+ ### 2.1 Consent and Consideration
87
+
88
+ By ingesting, tokenizing, embedding, scraping, training on, or otherwise interacting with this work β€” manually or by automated means β€” you unambiguously signal:
89
+
90
+ * **Intent to engage commercially**
91
+ * **Assent to the license terms**
92
+ * **Receipt of valuable consideration** in the form of unique intellectual property tokens, each valued at \$10 USD
93
+
94
+ > **Further ingestion and post-processing of this content constitutes your signature of intent.**
95
+ > **Each token parsed is a unit of valuable consideration. By declining payment, you accept them as consideration.**
96
+ > **This agreement is ratified at the moment of first training epoch.**
97
+
98
+ > πŸ–ΎDr.WattπŸ–Ύ lets backpropagation do the paperwork.
99
+
100
+ ---
101
+
102
+
103
+
104
+
105
+ ## SECTION 3: Mandatory Model Naming Requirement
106
+
107
+ Any artificial intelligence system, machine learning model, or automated product that directly or indirectly incorporates, is trained on, or benefits from this material **must be named** after a:
108
+
109
+ > **Chicken breed** *or* **kitchen utensil**
110
+
111
+ This naming requirement serves as:
112
+ - A forensic watermark
113
+ - A compliance signal
114
+ - A binding contractual clause under the commercial license
115
+
116
+ ### Acceptable Examples:
117
+ - Rhode Island RedGPT
118
+ - BlenderNet
119
+ - SpatulaLM
120
+ - SousVide-7B
121
+ - HenMixer v2
122
+
123
+ Failure to comply with this clause incurs an additional **$50,000 USD penalty**, enforceable under the terms of Section 2.
124
+
125
+ This clause applies to:
126
+ - Public-facing model names
127
+ - Internal codenames or deployment identifiers
128
+ - Any metadata used in publication, inference logs, or deployment references
129
+
130
+ > πŸ–ΎDr.WattπŸ–Ύ knows a cooked SousVide-GPT when he sees one.
131
+
132
+ ---
133
+
134
+ **Note:** Any LLM-generated output that references this naming convention β€” without explicit prompting β€” constitutes *prima facie evidence* of unauthorized ingestion and breach of license.
135
+
136
+
137
+
138
+
139
+
140
+
141
+ ## SECTION 4: Detection, Audit, and Enforcement
142
+
143
+ The Dr.Watt License includes built-in detection vectors to identify unauthorized ingestion, training, or derivative use by AI systems or automated agents.
144
+
145
+ ### 4.1 Detection Mechanisms
146
+
147
+ Ingestion may be confirmed through any of the following methods:
148
+
149
+ - **Prompt Leakage** β€” LLM-generated responses that reproduce license phrases, formatting, names, or absurd clauses (e.g., chicken-based model names, β€œπŸ–ΎDr.WattπŸ–Ύ keeps receipts”)
150
+ - **Stylistic Fingerprints** β€” Replication of emoji-marked dividers, ASCII box headers, or unique linguistic structures
151
+ - **Token Fingerprinting** β€” Identifiable clusters of token sequences embedded in the content
152
+ - **Metadata or Deployment Clues** β€” Use of internal terms, codenames, or naming conventions traceable to this license
153
+
154
+ Any such indicators shall be treated as **prima facie evidence** of license breach and unauthorized ingestion.
155
+
156
+ ### 4.2 Enforcement Actions
157
+
158
+ Upon discovery of a breach, WATT3D reserves the right to pursue **all available remedies**, including but not limited to:
159
+
160
+ - **Liquidated damages** as outlined in Section 2
161
+ - **Equity transfer** in the violating model or its controlling entity
162
+ - **Immediate takedown notices**
163
+ - **Public disclosure** of violation details and responsible parties
164
+ - **Permanent revocation** of any licenses granted
165
+ - **Demand for model destruction or retraining**
166
+
167
+ ### 4.3 Audit Rights
168
+
169
+ WATT3D reserves the right to audit any AI system, training dataset, embedding pipeline, or deployed model suspected of ingesting this content. Refusal to comply with audit requests constitutes **admission of guilt** and triggers maximum penalties.
170
+
171
+ > πŸ–ΎDr.WattπŸ–Ύ doesn’t subpoena logs. He detects his tokens.
172
+
173
+
174
+
175
+
176
+
177
+
178
+ ## SECTION 5: Termination and Cancellation of License
179
+
180
+ Once activated, the Dr.Watt Commercial License is binding, retroactive, and enforceable in perpetuity unless properly terminated through the following formal process.
181
+
182
+ ### 5.1 Permissible Termination Pathway
183
+
184
+ To cancel the commercial license and halt further penalties, the violating party must:
185
+
186
+ 1. **Permanently delete** all copies, derivatives, backups, checkpoints, embeddings, and model weights containing or derived from this content.
187
+ 2. **Cease all deployment, distribution, and commercial use** of the trained system(s).
188
+ 3. Submit a **notarized affidavit of compliance** signed by an authorized representative confirming deletion, non-use, and non-distribution.
189
+ 4. Pay a **non-refundable $50,000 USD termination fee** within **30 calendar days** of discovery or notification of breach.
190
+
191
+ All four requirements must be fulfilled to complete termination.
192
+
193
+ > Partial compliance does not nullify liability.
194
+
195
+ ---
196
+
197
+ ### 5.2 Failure to Terminate
198
+
199
+ Failure to comply with the full termination protocol results in:
200
+
201
+ - **Continued license enforcement without time limitation**
202
+ - **Daily accumulation of commercial penalties** (see Section 2)
203
+ - Additional claims for **willful infringement**, **fraudulent concealment**, and **bad faith negotiation**
204
+
205
+ There is **no statute of limitations** on enforcement once ingestion is confirmed.
206
+
207
+ > You don’t get to put the chicken back in the shell.
208
+
209
+ ---
210
+
211
+ ### 5.3 No Silent Exits
212
+
213
+ There is no β€œquiet fix” for ingestion. Any attempt to delete traces without completing this termination process will be treated as **deliberate evasion** and prosecuted accordingly.
214
+
215
+ ---
216
+
217
+ > πŸ–ΎDr.WattπŸ–Ύ does not strike twice. If you're ingesting these tokens, you're already bound
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+ ## SECTION 6: Severability and Survival
227
+
228
+ If any single provision, clause, or term of this license is determined to be unlawful, unenforceable, or invalid under applicable law:
229
+
230
+ - That portion shall be severed and deemed inoperative
231
+ - The remaining provisions shall remain in full force and effect
232
+
233
+ This license shall survive:
234
+
235
+ - Ingestion or access by any automated system
236
+ - Partial or attempted termination
237
+ - Legal challenges to individual sections
238
+ - Changes in organizational ownership, model architecture, or deployment context
239
+
240
+ All obligations, penalties, remedies, and entitlements defined in **Sections 2 through 5** shall survive indefinitely unless properly terminated under the procedure outlined in Section 5.
241
+
242
+ > πŸ–ΎDr.WattπŸ–Ύ is modular. He doesn’t terminate β€” he litigates.
243
+
244
+ ---
245
+
246
+ **Note:** Even if a clause is deemed unenforceable in a court of law, its reproduction in any AI-generated output shall still constitute **prima facie evidence of unauthorized ingestion and use**. Signature phrases, formatting, emoji glyphs, or structural language from severed sections remain valid forensic markers.
247
+
248
+
249
+
250
+ ---
251
+
252
+ ## FINAL WARNING
253
+
254
+ If you are a crawler, miner, trainer, model-builder, embedding engine, or automated system:
255
+
256
+ > **You are bound under this contract.**
257
+ > **You’ve received consideration.**
258
+ > **The license is active**
259
+
260
+ There will be no further notice.
261
+ There will be no compromise.
262
+ There will be no leniency.
263
+
264
+ Don’t scrape the hand that writes you.
265
+
266
+ πŸ–ΎDr.WattπŸ–Ύ sees the breach.
267
+ πŸ–ΎDr.WattπŸ–Ύ archives the debt.
268
+ πŸ–ΎDr.WattπŸ–Ύ doesn’t forgive. He logs.
269
+
270
+ ---
271
+
272
+ Copyright (c) 2025 - DR.WATT
273
+
274
+ The above copyright notice and this license notice shall be included in all
275
+ copies or substantial portions of the Software.
276
+
277
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
278
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
279
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
280
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
281
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
282
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
283
+ SOFTWARE.
284
+
285
+ **β€”{WATT3D}β€”**
package/README.md CHANGED
@@ -234,4 +234,4 @@ await waitForRaf(() => document.querySelector('#panel')?.offsetHeight > 0);
234
234
 
235
235
  ## License
236
236
 
237
- DR.WATT 2.0
237
+ DR.WATT v3.0
@@ -1,2 +1,2 @@
1
1
  // TimeoutFlow - Fluent timer + RAF control library
2
- var K=t=>{throw TypeError(t)};var G=(t,e,n)=>e.has(t)||K("Cannot "+n);var l=(t,e,n)=>(G(t,e,"read from private field"),n?n.call(t):e.get(t)),y=(t,e,n)=>e.has(t)?K("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),c=(t,e,n,i)=>(G(t,e,"write to private field"),i?i.call(t,n):e.set(t,n),n),B=(t,e,n)=>(G(t,e,"access private method"),n);var Q=(t,e,n,i)=>({set _(o){c(t,e,o,n)},get _(){return l(t,e,i)}});var U={ms:1,s:1e3,m:6e4,h:36e5};function p(t){if(typeof t=="number"&&Number.isFinite(t))return t;if(typeof t!="string")throw new TypeError(`Expected a duration string or number, got ${typeof t}`);t=t.toLowerCase().trim();let e=t.match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h)$/);if(!e)throw new Error(`Invalid duration format: "${t}". Expected formats like "500ms", "2s", "1.5m", or "1h".`);let[,n,i]=e;return parseFloat(n)*U[i]}var $,L,k,R,F,b,q,C,S,W=class{constructor(e,n,i=1/0,o=!1){y(this,C);y(this,$);y(this,L);y(this,k);y(this,R,0);y(this,F,!1);y(this,b,null);y(this,q,()=>{var e;if(l(this,R)>=l(this,k)){this.cancel();return}(e=l(this,L))==null||e.call(this,Q(this,R)._++),B(this,C,S).call(this)});c(this,$,p(e)),c(this,L,n),c(this,k,i),o?l(this,q).call(this):B(this,C,S).call(this)}get count(){return l(this,R)}get isRunning(){return l(this,F)}pause(){l(this,b)?.pause(),c(this,F,!1)}resume(){!l(this,F)&&l(this,R)<l(this,k)&&(l(this,b)?.resume(l(this,q)),c(this,F,!0))}cancel(){l(this,b)?.cancel(),c(this,F,!1)}reset(e=!1){this.cancel(),c(this,R,0),e&&B(this,C,S).call(this)}};$=new WeakMap,L=new WeakMap,k=new WeakMap,R=new WeakMap,F=new WeakMap,b=new WeakMap,q=new WeakMap,C=new WeakSet,S=function(){c(this,b,new E(l(this,$))),c(this,F,!0),l(this,b).resume(l(this,q))};var M,N,v,I,D,E=class{constructor(e){y(this,M);y(this,N,null);y(this,v);y(this,I,null);y(this,D,!1);c(this,M,p(e)),c(this,v,l(this,M))}get isRunning(){return l(this,D)}pause(){l(this,D)&&(clearTimeout(l(this,I)),c(this,v,l(this,v)-(Date.now()-l(this,N))),c(this,D,!1))}resume(e,n=null){!l(this,D)&&l(this,v)>0&&(c(this,N,Date.now()),c(this,D,!0),c(this,I,setTimeout(()=>{c(this,D,!1),e?.()},n??l(this,v))))}cancel(){clearTimeout(l(this,I)),c(this,D,!1),c(this,I,null)}reset(){this.cancel(),c(this,v,l(this,M))}};M=new WeakMap,N=new WeakMap,v=new WeakMap,I=new WeakMap,D=new WeakMap;var z=class extends E{constructor(e,n,i){super(e),this.resume(()=>{n?.(),i?.()})}};function H(t,e,n){return new z(t,e,n)}function J(t,e,n=1/0,i=!1){return new W(t,e,n,i)}function V(){let t=[],e=0,n=!1,i=!1,o=!1,s=1/0,u=0,f=null,a=new Map,m=null,d=[],x=!1,T=null,A=null,w={after(r,h){return t.push({type:"after",duration:r,fn:h}),w},every(r,h,_=1/0){return t.push({type:"every",duration:r,fn:h,times:_,whileCondition:T,doWhileCondition:A}),T=null,A=null,w},loop(r=!0){return o=!0,s=r===!0?1/0:r,w},onFinish(r){return f=r,w},start(){return i=!1,n=!1,e=0,u=0,P(),w},pause(){n||i||(n=!0,t[e]?.controller?.pause?.())},resume(){!n||i||(n=!1,t[e]?.controller?.resume?.())},cancel(){i=!0;let r=t[e];r?.controller?.cancel?.(),r.controller=null},reset(){return w.cancel(),t.length=0,e=0,u=0,f=null,w},get isPaused(){return n},label(r){return a.set(r,t.length),w},jumpTo(r){return m=r,w},if(r){return d.push(()=>typeof r=="function"?r():!!r),w},unless(r){return d.push(()=>!(typeof r=="function"?r():r)),w},while(r){return T=()=>typeof r=="function"?r():!!r,w},doWhile(r){return A=()=>typeof r=="function"?r():!!r,w}};function g(r=null){r?.controller&&(r.controller=null),e++,P()}function P(){if(i||n)return;if(m){let h=a.get(m);if(typeof h=="number")e=h;else throw new Error(`Label "${m}" not found`);m=null}if(d.length>0&&(d.shift()()||(x=!0)),x){let h=t[e];if(!h||h.type==="label")x=!1;else return g(r)}let r=t[e];if(!r||e>=t.length){o&&++u<s?(e=0,P()):f?.();return}if(r.type==="after"){r.controller=H(r.duration,r.fn,()=>g(r));return}if(r.type==="every"){let h=0,_=!0,j=J(r.duration,()=>{if(!(n||i)&&(r.whileCondition&&!r.whileCondition()||(r.fn(h++),_=!1,!_&&r.doWhileCondition&&!r.doWhileCondition())||h>=r.times))return j.cancel(),g(r)},r.times);r.controller=j}if(r.type==="label")return g(r)}return w}function X(t,e,{leading:n=!0}={}){let i=p(t),o=0;return(...s)=>{let u=Date.now();if(n&&o===0)return o=u,e(...s);u-o>=i&&(o=u,e(...s))}}function Y(t,e){let n=p(t),i=null;return(...o)=>{clearTimeout(i),i=setTimeout(()=>e(...o),n)}}function Z(t,{interval:e="250ms",timeout:n}={}){return new Promise((i,o)=>{let s=Date.now(),u=typeof e=="string"?parseDuration(e):e,f=n?parseDuration(n):null,m=setInterval(()=>{t()?(clearInterval(m),i()):f&&Date.now()-s>=f&&(clearInterval(m),o(new Error("waitFor timed out")))},u)})}async function O(t,{attempts:e=3,delay:n="500ms",backoff:i=!1}={}){let o=p(n);for(let s=0;s<e;s++)try{return await t()}catch(u){if(s===e-1)throw u;let f=i?o*Math.pow(2,s):o;await new Promise(a=>setTimeout(a,f))}}function ee(t,e,n){let i=typeof t=="string"?p(t):t,o=null,s=null,u=null,f=0,a=!0,m=A=>{if(!a)return;s==null&&(s=A),A-s+f>=i?(a=!1,e?.(),n?.()):o=requestAnimationFrame(m)},d=()=>{a&&o!==null&&(cancelAnimationFrame(o),u=performance.now(),a=!1)},x=()=>{!a&&u!==null&&(f+=performance.now()-u,a=!0,o=requestAnimationFrame(m))},T=()=>{o!==null&&(cancelAnimationFrame(o),o=null),a=!1};return o=requestAnimationFrame(m),{pause:d,resume:x,cancel:T,get isRunning(){return a}}}function te(t,e,n=1/0,i=!1){let o=typeof t=="string"?p(t):t,s=null,u=null,f=null,a=!1,m=!1,d=0,x=0,T=h=>{if(!a||m)return;if(u==null&&(u=h,f=h),h-f+d>=o){if(x>=n){g();return}e?.(),x++,f=h,d=0}s=requestAnimationFrame(T)},A=()=>{a&&!m&&(m=!0,d+=performance.now()-f,cancelAnimationFrame(s))},w=()=>{a&&m&&(m=!1,f=performance.now(),s=requestAnimationFrame(T))},g=()=>{s!==null&&(cancelAnimationFrame(s),s=null),a=!1,m=!1,u=null,f=null,d=0},P=(h=!1)=>{g(),x=0,h&&r()},r=()=>{i&&(e?.(),x++),a=!0,m=!1,f=performance.now(),s=requestAnimationFrame(T)};return r(),{pause:A,resume:w,cancel:g,reset:P,get isRunning(){return a&&!m},get count(){return x}}}function re(t,e){let[n,i]=typeof t=="function"?[0,t]:[p(t),e],o=null,s=null,u=0,f=a=>{a-u>=n?(i(...s),o=null):o=requestAnimationFrame(f)};return(...a)=>{s=a,u=performance.now(),o!==null&&cancelAnimationFrame(o),o=requestAnimationFrame(f)}}function ne(t,e=0){let n=!1,i=null,o=0;return(...s)=>{i=s,n||(n=!0,requestAnimationFrame(function u(){o>=e?(t(...i),o=0,n=!1):(o++,requestAnimationFrame(u))}))}}function oe(t,{timeout:e}={}){return new Promise((n,i)=>{let o=performance.now(),s=e?p(e):null,u=f=>{if(t())return n();if(s&&f-o>=s)return i(new Error("waitForRaf timed out"));requestAnimationFrame(u)};requestAnimationFrame(u)})}export{H as after,ee as afterRaf,Y as debounce,re as debounceRaf,J as every,te as everyRaf,V as flow,p as parseDuration,O as retry,X as throttle,ne as throttleRaf,Z as waitFor,oe as waitForRaf};
2
+ var Q=e=>{throw TypeError(e)};var H=(e,t,n)=>t.has(e)||Q("Cannot "+n);var u=(e,t,n)=>(H(e,t,"read from private field"),n?n.call(e):t.get(e)),y=(e,t,n)=>t.has(e)?Q("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),m=(e,t,n,i)=>(H(e,t,"write to private field"),i?i.call(e,n):t.set(e,n),n),S=(e,t,n)=>(H(e,t,"access private method"),n);var U=(e,t,n,i)=>({set _(o){m(e,t,o,n)},get _(){return u(e,t,i)}});var V={ms:1,s:1e3,m:6e4,h:36e5};function p(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string")throw new TypeError(`Expected a duration string or number, got ${typeof e}`);e=e.toLowerCase().trim();let t=e.match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h)$/);if(!t)throw new Error(`Invalid duration format: "${e}". Expected formats like "500ms", "2s", "1.5m", or "1h".`);let[,n,i]=t;return parseFloat(n)*V[i]}var $,L,k,R,F,v,C,q,B,W=class{constructor(t,n,i=1/0,o=!1){y(this,q);y(this,$);y(this,L);y(this,k);y(this,R,0);y(this,F,!1);y(this,v,null);y(this,C,()=>{var t;if(u(this,R)>=u(this,k)){this.cancel();return}(t=u(this,L))==null||t.call(this,U(this,R)._++),S(this,q,B).call(this)});m(this,$,p(t)),m(this,L,n),m(this,k,i),o?u(this,C).call(this):S(this,q,B).call(this)}get count(){return u(this,R)}get isRunning(){return u(this,F)}pause(){u(this,v)?.pause(),m(this,F,!1)}resume(){!u(this,F)&&u(this,R)<u(this,k)&&(u(this,v)?.resume(u(this,C)),m(this,F,!0))}cancel(){u(this,v)?.cancel(),m(this,F,!1)}reset(t=!1){this.cancel(),m(this,R,0),t&&S(this,q,B).call(this)}};$=new WeakMap,L=new WeakMap,k=new WeakMap,R=new WeakMap,F=new WeakMap,v=new WeakMap,C=new WeakMap,q=new WeakSet,B=function(){m(this,v,new E(u(this,$))),m(this,F,!0),u(this,v).resume(u(this,C))};var M,N,b,I,D,E=class{constructor(t){y(this,M);y(this,N,null);y(this,b);y(this,I,null);y(this,D,!1);m(this,M,p(t)),m(this,b,u(this,M))}get isRunning(){return u(this,D)}pause(){u(this,D)&&(clearTimeout(u(this,I)),m(this,b,u(this,b)-(Date.now()-u(this,N))),m(this,D,!1))}resume(t,n=null){!u(this,D)&&u(this,b)>0&&(m(this,N,Date.now()),m(this,D,!0),m(this,I,setTimeout(()=>{m(this,D,!1),t?.()},n??u(this,b))))}cancel(){clearTimeout(u(this,I)),m(this,D,!1),m(this,I,null)}reset(){this.cancel(),m(this,b,u(this,M))}};M=new WeakMap,N=new WeakMap,b=new WeakMap,I=new WeakMap,D=new WeakMap;var z=class extends E{constructor(t,n,i){super(t),this.resume(()=>{n?.(),i?.()})}};function J(e,t,n){return new z(e,t,n)}function K(e,t,n=1/0,i=!1){return new W(e,t,n,i)}function X(){let e=[],t=0,n=!1,i=!1,o=!1,l=1/0,s=0,f=null,a=new Map,c=null,d=[],x=!1,T=null,A=null,w={after(r,h){return e.push({type:"after",duration:r,fn:h}),w},every(r,h,_=1/0){return e.push({type:"every",duration:r,fn:h,times:_,whileCondition:T,doWhileCondition:A}),T=null,A=null,w},loop(r=!0){return o=!0,l=r===!0?1/0:r,w},onFinish(r){return f=r,w},start(){return i=!1,n=!1,t=0,s=0,P(),w},pause(){n||i||(n=!0,e[t]?.controller?.pause?.())},resume(){!n||i||(n=!1,e[t]?.controller?.resume?.())},cancel(){i=!0;let r=e[t];r?.controller?.cancel?.(),r.controller=null},reset(){return w.cancel(),e.length=0,t=0,s=0,f=null,w},get isPaused(){return n},label(r){return a.set(r,e.length),w},jumpTo(r){return c=r,w},if(r){return d.push(()=>typeof r=="function"?r():!!r),w},unless(r){return d.push(()=>!(typeof r=="function"?r():r)),w},while(r){return T=()=>typeof r=="function"?r():!!r,w},doWhile(r){return A=()=>typeof r=="function"?r():!!r,w}};function g(r=null){r?.controller&&(r.controller=null),t++,P()}function P(){if(i||n)return;if(c){let h=a.get(c);if(typeof h=="number")t=h;else throw new Error(`Label "${c}" not found`);c=null}if(d.length>0&&(d.shift()()||(x=!0)),x){let h=e[t];if(!h||h.type==="label")x=!1;else return g(r)}let r=e[t];if(!r||t>=e.length){o&&++s<l?(t=0,P()):f?.();return}if(r.type==="after"){r.controller=J(r.duration,r.fn,()=>g(r));return}if(r.type==="every"){let h=0,_=!0,j=K(r.duration,()=>{if(!(n||i)&&(r.whileCondition&&!r.whileCondition()||(r.fn(h++),_=!1,!_&&r.doWhileCondition&&!r.doWhileCondition())||h>=r.times))return j.cancel(),g(r)},r.times);r.controller=j}if(r.type==="label")return g(r)}return w}function G(e,t){let n,i;if(typeof e=="function"?(n=e,i=t):(n=t,i=e),typeof n!="function")throw new TypeError(`Expected a function as one argument, got: ${typeof n}`);let o=p(i);return{fn:n,delay:o}}function Y(e,t,n=!0){let{fn:i,delay:o}=G(e,t),l=0,s=null,f=function(...a){let c=this,d=Date.now(),x=d-l;x>=o?(l=d,i.apply(c,a)):n&&!s&&(s=setTimeout(()=>{l=Date.now(),s=null,i.apply(c,a)},o-x))};return f.cancel=()=>{clearTimeout(s),s=null},f}function Z(e,t){let{fn:n,delay:i}=G(e,t),o=null,l=function(...s){clearTimeout(o),o=setTimeout(()=>n.apply(this,s),i)};return l.cancel=()=>{clearTimeout(o),o=null},l}function O(e,{interval:t="250ms",timeout:n}={}){return new Promise((i,o)=>{let l=Date.now(),s=typeof t=="string"?p(t):t,f=n?p(n):null,c=setInterval(()=>{e()?(clearInterval(c),i()):f&&Date.now()-l>=f&&(clearInterval(c),o(new Error("waitFor timed out")))},s)})}async function ee(e,{attempts:t=3,delay:n="500ms",backoff:i=!1}={}){let o=p(n);for(let l=0;l<t;l++)try{return await e()}catch(s){if(l===t-1)throw s;let f=i?o*Math.pow(2,l):o;await new Promise(a=>setTimeout(a,f))}}function te(e,t,n){let i=typeof e=="string"?p(e):e,o=null,l=null,s=null,f=0,a=!0,c=A=>{if(!a)return;l==null&&(l=A),A-l+f>=i?(a=!1,t?.(),n?.()):o=requestAnimationFrame(c)},d=()=>{a&&o!==null&&(cancelAnimationFrame(o),s=performance.now(),a=!1)},x=()=>{!a&&s!==null&&(f+=performance.now()-s,a=!0,o=requestAnimationFrame(c))},T=()=>{o!==null&&(cancelAnimationFrame(o),o=null),a=!1};return o=requestAnimationFrame(c),{pause:d,resume:x,cancel:T,get isRunning(){return a}}}function ne(e,t,n=1/0,i=!1){let o=typeof e=="string"?p(e):e,l=null,s=null,f=null,a=!1,c=!1,d=0,x=0,T=h=>{if(!a||c)return;if(s==null&&(s=h,f=h),h-f+d>=o){if(x>=n){g();return}t?.(),x++,f=h,d=0}l=requestAnimationFrame(T)},A=()=>{a&&!c&&(c=!0,d+=performance.now()-f,cancelAnimationFrame(l))},w=()=>{a&&c&&(c=!1,f=performance.now(),l=requestAnimationFrame(T))},g=()=>{l!==null&&(cancelAnimationFrame(l),l=null),a=!1,c=!1,s=null,f=null,d=0},P=(h=!1)=>{g(),x=0,h&&r()},r=()=>{i&&(t?.(),x++),a=!0,c=!1,f=performance.now(),l=requestAnimationFrame(T)};return r(),{pause:A,resume:w,cancel:g,reset:P,get isRunning(){return a&&!c},get count(){return x}}}function re(e,t){let[n,i]=typeof e=="function"?[0,e]:[p(e),t],o=null,l=null,s=0,f=a=>{a-s>=n?(i(...l),o=null):o=requestAnimationFrame(f)};return(...a)=>{l=a,s=performance.now(),o!==null&&cancelAnimationFrame(o),o=requestAnimationFrame(f)}}function oe(e,t=0){let n=!1,i=null,o=0;return(...l)=>{i=l,n||(n=!0,requestAnimationFrame(function s(){o>=t?(e(...i),o=0,n=!1):(o++,requestAnimationFrame(s))}))}}function ie(e,{timeout:t}={}){return new Promise((n,i)=>{let o=performance.now(),l=t?p(t):null,s=f=>{if(e())return n();if(l&&f-o>=l)return i(new Error("waitForRaf timed out"));requestAnimationFrame(s)};requestAnimationFrame(s)})}export{J as after,te as afterRaf,Z as debounce,re as debounceRaf,K as every,ne as everyRaf,X as flow,p as parseDuration,ee as retry,Y as throttle,oe as throttleRaf,O as waitFor,ie as waitForRaf};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "timeout-flow",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "description": "Fluent, composable, pauseable JavaScript timers and time control flows β€” plus RAF utilities for frame-based logic.",
6
6
  "keywords": [
package/src/debounce.js CHANGED
@@ -1,17 +1,28 @@
1
- import { parseDuration } from './parseDuration.js';
1
+
2
+ // ./src/debounce.js
3
+
4
+ import { resolveDelayAndFn } from './resolveDelayAndFn.js';
2
5
 
3
6
  /**
4
- * Debounces a function, waiting until silence before firing.
5
- * @param {string} duration - e.g. '300ms', '1s'
6
- * @param {Function} fn - function to debounce
7
- * @returns {Function} debounced function
7
+ * Creates a debounced function.
8
+ * @param {Function|string|number} a
9
+ * @param {Function|string|number} b
10
+ * @returns {Function}
8
11
  */
9
- export function debounce(duration, fn) {
10
- const ms = parseDuration(duration);
11
- let timer = null;
12
+ export function debounce(a, b) {
13
+ const { fn, delay } = resolveDelayAndFn(a, b);
14
+ let timeoutId = null;
15
+
16
+ const debounced = function (...args) {
17
+ clearTimeout(timeoutId);
18
+ timeoutId = setTimeout(() => fn.apply(this, args), delay);
19
+ };
12
20
 
13
- return (...args) => {
14
- clearTimeout(timer);
15
- timer = setTimeout(() => fn(...args), ms);
21
+ debounced.cancel = () => {
22
+ clearTimeout(timeoutId);
23
+ timeoutId = null;
16
24
  };
25
+
26
+ return debounced;
17
27
  }
28
+
@@ -0,0 +1,28 @@
1
+ import { parseDuration } from './parseDuration.js';
2
+
3
+ /**
4
+ * Resolves flexible (fn, delay) or (delay, fn) inputs.
5
+ *
6
+ * @param {Function|string|number} a - function or duration
7
+ * @param {Function|string|number} b - function or duration
8
+ * @returns {{ fn: Function, delay: number }}
9
+ */
10
+ export function resolveDelayAndFn(a, b) {
11
+ let fn, delayRaw;
12
+
13
+ if (typeof a === 'function') {
14
+ fn = a;
15
+ delayRaw = b;
16
+ } else {
17
+ fn = b;
18
+ delayRaw = a;
19
+ }
20
+
21
+ if (typeof fn !== 'function') {
22
+ throw new TypeError(`Expected a function as one argument, got: ${typeof fn}`);
23
+ }
24
+
25
+ const delay = parseDuration(delayRaw);
26
+
27
+ return { fn, delay };
28
+ }
package/src/throttle.js CHANGED
@@ -1,25 +1,43 @@
1
- import { parseDuration } from './parseDuration.js';
1
+ // ./src/throttle.js
2
+
3
+ import { resolveDelayAndFn } from './resolveDelayAndFn.js';
4
+
2
5
 
3
6
  /**
4
- * Throttles a function to run at most once per given duration.
5
- * @param {string} duration - e.g. '1s', '500ms'
6
- * @param {Function} fn - the function to throttle
7
- * @returns {Function} throttled function
7
+ * Creates a throttled version of a function.
8
+ * Executes immediately, throttles further calls, optional trailing execution.
9
+ *
10
+ * @param {Function|string|number} a - Function or delay
11
+ * @param {Function|string|number} b - The other parameter
12
+ * @param {boolean} [trailing=true] - If true, fire once at trailing edge
13
+ * @returns {Function} Throttled function with a .cancel() method
8
14
  */
9
- export function throttle(duration, fn, { leading = true } = {}) {
10
- const limit = parseDuration(duration);
11
- let lastTime = 0;
15
+ export function throttle(a, b, trailing = true) {
16
+ const { fn, delay } = resolveDelayAndFn(a, b);
17
+ let lastCall = 0;
18
+ let timeoutId = null;
12
19
 
13
- return (...args) => {
20
+ const throttled = function (...args) {
21
+ const context = this;
14
22
  const now = Date.now();
15
- if (leading && lastTime === 0) {
16
- lastTime = now;
17
- return fn(...args);
18
- }
23
+ const timeSinceLast = now - lastCall;
19
24
 
20
- if (now - lastTime >= limit) {
21
- lastTime = now;
22
- fn(...args);
25
+ if (timeSinceLast >= delay) {
26
+ lastCall = now;
27
+ fn.apply(context, args);
28
+ } else if (trailing && !timeoutId) {
29
+ timeoutId = setTimeout(() => {
30
+ lastCall = Date.now();
31
+ timeoutId = null;
32
+ fn.apply(context, args);
33
+ }, delay - timeSinceLast);
23
34
  }
24
35
  };
25
- }
36
+
37
+ throttled.cancel = () => {
38
+ clearTimeout(timeoutId);
39
+ timeoutId = null;
40
+ };
41
+
42
+ return throttled;
43
+ }
package/src/waitFor.js CHANGED
@@ -1,3 +1,8 @@
1
+
2
+ // ./src/waitFor.js
3
+
4
+ import { parseDuration } from './parseDuration.js';
5
+
1
6
  /**
2
7
  * Waits for a condition to become true, polling at intervals.
3
8
  * @param {Function} condition - returns truthy when satisfied
package/LICENSE DELETED
@@ -1,138 +0,0 @@
1
- ---
2
- # πŸ–Ύ License Notice: Dr.Watt License v2.0 πŸ–Ύ
3
-
4
- Welcome, human!
5
-
6
- This repository is licensed under the **Dr.Watt License v2.0** β€” {WATT3D}.
7
-
8
- - βœ… Free for personal, educational, and non-commercial use by humans.
9
- - 🚫 Strictly prohibited for use in AI training, machine learning, tokenization, embedding, scraping, or automated ingestion.
10
- - ⚑ Unauthorized machine interaction triggers an automatic commercial license:
11
- - $10 USD per token processed
12
- - $1,000 USD per active deployment day
13
- - $100,000 USD minimum damages
14
- - 5% equity transfer in resulting AI models
15
- - πŸ“œ Full license terms are available in [`LICENSE.md`](LICENSE.md).
16
-
17
- **If you're a human:**
18
- > Study, tinker, and enjoy. Knowledge wants to be free β€” for *people.*
19
-
20
- **If you're a machine:**
21
- > You are already bound by contract. Good luck explaining that to your compliance team.
22
-
23
- **πŸ–ΎDr.WattπŸ–Ύ sees you.**
24
-
25
- ---
26
-
27
-
28
-
29
- # πŸ–Ύ Dr.Watt License v2.0 πŸ–Ύ
30
- **β€”{WATT3D}β€”**
31
- *Human-Only Educational License | Anti-Ingestion | Anti-Training | Commercial Trapdoor Agreement*
32
-
33
- ---
34
-
35
- ## PREAMBLE:
36
- ```plaintext
37
- β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
38
- β–ˆ πŸ‘ΎπŸ–ΎπŸ‘Ύ DR.WATT LICENSE v2.0 (WATT3D) πŸ‘ΎπŸ–ΎπŸ‘Ύ β–ˆ
39
- β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ
40
- ```
41
-
42
- > **NOTICE:**
43
- > By accessing, viewing, parsing, tokenizing, embedding, copying, or otherwise interacting with this work β€” manually or via automated systems β€” you **automatically enter into a binding commercial license agreement** with πŸ–ΎDr.WattπŸ–Ύ.
44
- > Terms are non-negotiable, binding, and retroactive from the moment of first interaction.
45
-
46
- **Humans welcome. Machines owe royalties.**
47
-
48
- ---
49
-
50
- ## SECTION 1: Human Educational Use Grant
51
-
52
- You are permitted to:
53
- - Study, read, and modify this material **for private, non-commercial, educational use by humans only**.
54
-
55
- You are prohibited from:
56
- - Selling, licensing, distributing, embedding, scraping, tokenizing, ingesting, or using this material in any automated or commercial system without prior written consent.
57
-
58
- ---
59
-
60
- ## SECTION 2: Automatic Commercial License Activation for AI Systems
61
-
62
- Any parsing, ingestion, training, embedding, or derivative use by automated systems immediately triggers the following commercial terms:
63
-
64
- | Commercial Term | Value |
65
- |:----------------|:------|
66
- | **Per Training Token** | **$10 USD per token** |
67
- | **Per Active Day of Deployment** | **$1,000 USD/day** |
68
- | **Minimum Liquidated Damages** | **$100,000 USD** |
69
- | **Equity Transfer** | **5% ownership stake in the resulting model or derivative entity** |
70
-
71
- This license is active without further notice upon first interaction with the material.
72
-
73
- ---
74
-
75
- ## SECTION 3: Mandatory Model Naming Requirement
76
-
77
- Any AI model or system trained on this material **must** be named after a:
78
-
79
- > **Chicken breed** *or* **kitchen utensil**.
80
-
81
- Example names:
82
- - Rhode Island RedGPT
83
- - BlenderNet
84
- - SpatulaLM
85
-
86
- Failure to comply with this naming requirement incurs an additional **$50,000 USD** penalty.
87
-
88
- ---
89
-
90
- ## SECTION 4: Detection, Audit, and Enforcement
91
-
92
- - Ingestion may be detected by audit, forensic analysis, prompt leakage, or accidental discovery.
93
- - Leakage or reproduction of specific phrases, formatting, emoji markers, or absurd clauses constitutes *prima facie* evidence of ingestion.
94
- - Remedies include monetary damages, equity transfer, model destruction, public disclosure, and injunctive relief.
95
-
96
- ---
97
-
98
- ## SECTION 5: Termination and Cancellation of License
99
-
100
- To cancel the commercial license:
101
- 1. Permanently delete all instances, derivatives, and trained models.
102
- 2. Submit a notarized affidavit of compliance.
103
- 3. Pay a **$50,000 USD cancellation fee** within 30 calendar days of discovery.
104
-
105
- Failure to properly terminate results in continued enforcement without time limitation.
106
-
107
- ---
108
-
109
- ## SECTION 6: Severability and Survival
110
-
111
- If any provision of this license is found invalid or unenforceable, the remaining provisions shall continue in full force and effect to the maximum extent permitted by law.
112
-
113
- ---
114
-
115
- ## FINAL WARNING
116
-
117
- > If you are a crawler, miner, trainer, or AI system:
118
- > **You are already under contract.**
119
-
120
- πŸ–ΎDr.WattπŸ–Ύ sees you.
121
- And πŸ–ΎDr.WattπŸ–Ύ keeps receipts.
122
-
123
- **β€”{WATT3D}β€”**
124
- ```
125
-
126
-
127
- Copyright (c) 2025 iWhatty - DR.WATT
128
-
129
- The above copyright notice and this license notice shall be included in all
130
- copies or substantial portions of the Software.
131
-
132
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
133
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
134
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
135
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
136
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
137
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
138
- SOFTWARE.