@tempots/std 0.19.0 → 0.20.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/index.cjs +1 -1
- package/index.js +39 -37
- package/package.json +1 -1
- package/timer.cjs +1 -1
- package/timer.d.ts +14 -0
- package/timer.js +49 -27
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./array.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./array.cjs"),p=require("./async-result.cjs"),i=require("./bigint.cjs"),s=require("./boolean.cjs"),y=require("./deferred.cjs"),l=require("./equal.cjs"),c=require("./function.cjs"),o=require("./json.cjs"),t=require("./number.cjs"),a=require("./object.cjs"),u=require("./promise.cjs"),g=require("./regexp.cjs"),m=require("./result-CdwVhaAc.cjs"),e=require("./string.cjs"),n=require("./timer.cjs");exports.allElements=r.allElements;exports.anyElement=r.anyElement;exports.applyArrayDiffOperations=r.applyArrayDiffOperations;exports.areArraysEqual=r.areArraysEqual;exports.arrayDiffOperations=r.arrayDiffOperations;exports.arrayHasValues=r.arrayHasValues;exports.arrayHead=r.arrayHead;exports.arrayOfIterableIterator=r.arrayOfIterableIterator;exports.arrayTail=r.arrayTail;exports.compareArrays=r.compareArrays;exports.concatArrays=r.concatArrays;exports.createFilledArray=r.createFilledArray;exports.filterArray=r.filterArray;exports.filterMapArray=r.filterMapArray;exports.filterNullsFromArray=r.filterNullsFromArray;exports.flatMapArray=r.flatMapArray;exports.flattenArray=r.flattenArray;exports.foldLeftArray=r.foldLeftArray;exports.forEachElement=r.forEachElement;exports.generateArray=r.generateArray;exports.generateSequenceArray=r.generateSequenceArray;exports.isArrayEmpty=r.isArrayEmpty;exports.joinArrayWithConjunction=r.joinArrayWithConjunction;exports.mapArray=r.mapArray;exports.rankArray=r.rankArray;exports.removeAllFromArray=r.removeAllFromArray;exports.removeAllFromArrayByPredicate=r.removeAllFromArrayByPredicate;exports.removeOneFromArray=r.removeOneFromArray;exports.removeOneFromArrayByPredicate=r.removeOneFromArrayByPredicate;exports.sortArray=r.sortArray;exports.uniqueByPrimitive=r.uniqueByPrimitive;exports.uniquePrimitives=r.uniquePrimitives;exports.AsyncResult=p.AsyncResult;exports.biAbs=i.biAbs;exports.biCeilDiv=i.biCeilDiv;exports.biCompare=i.biCompare;exports.biFloorDiv=i.biFloorDiv;exports.biGcd=i.biGcd;exports.biIsEven=i.biIsEven;exports.biIsNegative=i.biIsNegative;exports.biIsOdd=i.biIsOdd;exports.biIsOne=i.biIsOne;exports.biIsPositive=i.biIsPositive;exports.biIsPrime=i.biIsPrime;exports.biIsZero=i.biIsZero;exports.biLcm=i.biLcm;exports.biMax=i.biMax;exports.biMin=i.biMin;exports.biNextPrime=i.biNextPrime;exports.biPow=i.biPow;exports.biPrevPrime=i.biPrevPrime;exports.booleanToInt=s.booleanToInt;exports.canParseBoolean=s.canParseBoolean;exports.compareBooleans=s.compareBooleans;exports.parseBoolean=s.parseBoolean;exports.xorBoolean=s.xorBoolean;exports.deferred=y.deferred;exports.deepEqual=l.deepEqual;exports.looseEqual=l.looseEqual;exports.strictEqual=l.strictEqual;exports.curryLeft=c.curryLeft;exports.identity=c.identity;exports.memoize=c.memoize;exports.isJSONArray=o.isJSONArray;exports.isJSONObject=o.isJSONObject;exports.isJSONPrimitive=o.isJSONPrimitive;exports.parseJSON=o.parseJSON;exports.EPSILON=t.EPSILON;exports.angleDifference=t.angleDifference;exports.ceilTo=t.ceilTo;exports.clamp=t.clamp;exports.clampInt=t.clampInt;exports.clampSym=t.clampSym;exports.compareNumbers=t.compareNumbers;exports.floorTo=t.floorTo;exports.interpolate=t.interpolate;exports.interpolateAngle=t.interpolateAngle;exports.interpolateAngleCCW=t.interpolateAngleCCW;exports.interpolateAngleCW=t.interpolateAngleCW;exports.interpolateWidestAngle=t.interpolateWidestAngle;exports.nearEqual=t.nearEqual;exports.nearEqualAngles=t.nearEqualAngles;exports.nearZero=t.nearZero;exports.root=t.root;exports.roundTo=t.roundTo;exports.sign=t.sign;exports.toHex=t.toHex;exports.widestAngleDifference=t.widestAngleDifference;exports.wrap=t.wrap;exports.wrapCircular=t.wrapCircular;exports.isEmptyObject=a.isEmptyObject;exports.isObject=a.isObject;exports.mergeObjects=a.mergeObjects;exports.objectEntries=a.objectEntries;exports.objectFromEntries=a.objectFromEntries;exports.objectKeys=a.objectKeys;exports.objectValues=a.objectValues;exports.removeObjectFields=a.removeObjectFields;exports.sameObjectKeys=a.sameObjectKeys;exports.sleep=u.sleep;exports.mapRegExp=g.mapRegExp;exports.Result=m.Result;exports.Validation=m.Validation;exports.canonicalizeNewlines=e.canonicalizeNewlines;exports.capitalize=e.capitalize;exports.capitalizeWords=e.capitalizeWords;exports.chunkString=e.chunkString;exports.collapseText=e.collapseText;exports.compareCaseInsensitive=e.compareCaseInsensitive;exports.compareStrings=e.compareStrings;exports.containsAllText=e.containsAllText;exports.containsAllTextCaseInsensitive=e.containsAllTextCaseInsensitive;exports.containsAnyText=e.containsAnyText;exports.containsAnyTextCaseInsensitive=e.containsAnyTextCaseInsensitive;exports.countStringOccurrences=e.countStringOccurrences;exports.dasherize=e.dasherize;exports.decodeBase64=e.decodeBase64;exports.deleteFirstFromString=e.deleteFirstFromString;exports.deleteStringAfter=e.deleteStringAfter;exports.deleteStringBefore=e.deleteStringBefore;exports.deleteSubstring=e.deleteSubstring;exports.ellipsis=e.ellipsis;exports.ellipsisMiddle=e.ellipsisMiddle;exports.encodeBase64=e.encodeBase64;exports.filterCharcodes=e.filterCharcodes;exports.filterChars=e.filterChars;exports.humanize=e.humanize;exports.ifEmptyString=e.ifEmptyString;exports.isAlpha=e.isAlpha;exports.isAlphaNum=e.isAlphaNum;exports.isBreakingWhitespace=e.isBreakingWhitespace;exports.isDigitsOnly=e.isDigitsOnly;exports.isEmptyString=e.isEmptyString;exports.isLowerCase=e.isLowerCase;exports.isSpaceAt=e.isSpaceAt;exports.isUpperCase=e.isUpperCase;exports.jsQuote=e.jsQuote;exports.lowerCaseFirst=e.lowerCaseFirst;exports.lpad=e.lpad;exports.mapChars=e.mapChars;exports.quote=e.quote;exports.randomString=e.randomString;exports.randomStringSequence=e.randomStringSequence;exports.randomStringSequenceBase64=e.randomStringSequenceBase64;exports.repeatString=e.repeatString;exports.replaceAll=e.replaceAll;exports.reverseString=e.reverseString;exports.rpad=e.rpad;exports.smartQuote=e.smartQuote;exports.splitStringOnFirst=e.splitStringOnFirst;exports.splitStringOnLast=e.splitStringOnLast;exports.splitStringOnce=e.splitStringOnce;exports.stringContains=e.stringContains;exports.stringEndsWith=e.stringEndsWith;exports.stringEndsWithAny=e.stringEndsWithAny;exports.stringHasContent=e.stringHasContent;exports.stringHashCode=e.stringHashCode;exports.stringStartsWith=e.stringStartsWith;exports.stringStartsWithAny=e.stringStartsWithAny;exports.stringToCharcodes=e.stringToCharcodes;exports.stringToChars=e.stringToChars;exports.stringsDifferAtIndex=e.stringsDifferAtIndex;exports.substringAfter=e.substringAfter;exports.substringAfterLast=e.substringAfterLast;exports.substringBefore=e.substringBefore;exports.substringBeforeLast=e.substringBeforeLast;exports.surroundString=e.surroundString;exports.textContainsCaseInsensitive=e.textContainsCaseInsensitive;exports.textEndsWithAnyCaseInsensitive=e.textEndsWithAnyCaseInsensitive;exports.textEndsWithCaseInsensitive=e.textEndsWithCaseInsensitive;exports.textStartsWithAnyCaseInsensitive=e.textStartsWithAnyCaseInsensitive;exports.textStartsWithCaseInsensitive=e.textStartsWithCaseInsensitive;exports.textToLines=e.textToLines;exports.trimChars=e.trimChars;exports.trimCharsLeft=e.trimCharsLeft;exports.trimCharsRight=e.trimCharsRight;exports.trimStringSlice=e.trimStringSlice;exports.underscore=e.underscore;exports.upperCaseFirst=e.upperCaseFirst;exports.wrapColumns=e.wrapColumns;exports.wrapLine=e.wrapLine;exports.debounce=n.debounce;exports.delayed=n.delayed;exports.delayedAnimationFrame=n.delayedAnimationFrame;exports.interval=n.interval;exports.intervalAnimationFrame=n.intervalAnimationFrame;exports.throttle=n.throttle;
|
package/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { allElements as t, anyElement as i, applyArrayDiffOperations as a, areArraysEqual as s, arrayDiffOperations as n, arrayHasValues as o, arrayHead as l, arrayOfIterableIterator as
|
|
1
|
+
import { allElements as t, anyElement as i, applyArrayDiffOperations as a, areArraysEqual as s, arrayDiffOperations as n, arrayHasValues as o, arrayHead as l, arrayOfIterableIterator as m, arrayTail as p, compareArrays as c, concatArrays as y, createFilledArray as A, filterArray as g, filterMapArray as d, filterNullsFromArray as f, flatMapArray as u, flattenArray as b, foldLeftArray as S, forEachElement as x, generateArray as C, generateSequenceArray as h, isArrayEmpty as v, joinArrayWithConjunction as E, mapArray as O, rankArray as I, removeAllFromArray as F, removeAllFromArrayByPredicate as B, removeOneFromArray as W, removeOneFromArrayByPredicate as j, sortArray as P, uniqueByPrimitive as T, uniquePrimitives as q } from "./array.js";
|
|
2
2
|
import { AsyncResult as N } from "./async-result.js";
|
|
3
3
|
import { biAbs as D, biCeilDiv as z, biCompare as H, biFloorDiv as M, biGcd as R, biIsEven as J, biIsNegative as V, biIsOdd as k, biIsOne as K, biIsPositive as Q, biIsPrime as Z, biIsZero as G, biLcm as U, biMax as X, biMin as Y, biNextPrime as _, biPow as $, biPrevPrime as ee } from "./bigint.js";
|
|
4
4
|
import { booleanToInt as te, canParseBoolean as ie, compareBooleans as ae, parseBoolean as se, xorBoolean as ne } from "./boolean.js";
|
|
5
5
|
import { deferred as le } from "./deferred.js";
|
|
6
|
-
import { deepEqual as
|
|
7
|
-
import { curryLeft as
|
|
6
|
+
import { deepEqual as pe, looseEqual as ce, strictEqual as ye } from "./equal.js";
|
|
7
|
+
import { curryLeft as ge, identity as de, memoize as fe } from "./function.js";
|
|
8
8
|
import { isJSONArray as be, isJSONObject as Se, isJSONPrimitive as xe, parseJSON as Ce } from "./json.js";
|
|
9
|
-
import { EPSILON as ve, angleDifference as Ee, ceilTo as Oe, clamp as Ie, clampInt as
|
|
9
|
+
import { EPSILON as ve, angleDifference as Ee, ceilTo as Oe, clamp as Ie, clampInt as Fe, clampSym as Be, compareNumbers as We, floorTo as je, interpolate as Pe, interpolateAngle as Te, interpolateAngleCCW as qe, interpolateAngleCW as Le, interpolateWidestAngle as Ne, nearEqual as we, nearEqualAngles as De, nearZero as ze, root as He, roundTo as Me, sign as Re, toHex as Je, widestAngleDifference as Ve, wrap as ke, wrapCircular as Ke } from "./number.js";
|
|
10
10
|
import { isEmptyObject as Ze, isObject as Ge, mergeObjects as Ue, objectEntries as Xe, objectFromEntries as Ye, objectKeys as _e, objectValues as $e, removeObjectFields as er, sameObjectKeys as rr } from "./object.js";
|
|
11
11
|
import { sleep as ir } from "./promise.js";
|
|
12
12
|
import { mapRegExp as sr } from "./regexp.js";
|
|
13
13
|
import { R as or, V as lr } from "./result-CGd0jCdl.js";
|
|
14
|
-
import { canonicalizeNewlines as
|
|
15
|
-
import { debounce as Nt, delayed as wt,
|
|
14
|
+
import { canonicalizeNewlines as pr, capitalize as cr, capitalizeWords as yr, chunkString as Ar, collapseText as gr, compareCaseInsensitive as dr, compareStrings as fr, containsAllText as ur, containsAllTextCaseInsensitive as br, containsAnyText as Sr, containsAnyTextCaseInsensitive as xr, countStringOccurrences as Cr, dasherize as hr, decodeBase64 as vr, deleteFirstFromString as Er, deleteStringAfter as Or, deleteStringBefore as Ir, deleteSubstring as Fr, ellipsis as Br, ellipsisMiddle as Wr, encodeBase64 as jr, filterCharcodes as Pr, filterChars as Tr, humanize as qr, ifEmptyString as Lr, isAlpha as Nr, isAlphaNum as wr, isBreakingWhitespace as Dr, isDigitsOnly as zr, isEmptyString as Hr, isLowerCase as Mr, isSpaceAt as Rr, isUpperCase as Jr, jsQuote as Vr, lowerCaseFirst as kr, lpad as Kr, mapChars as Qr, quote as Zr, randomString as Gr, randomStringSequence as Ur, randomStringSequenceBase64 as Xr, repeatString as Yr, replaceAll as _r, reverseString as $r, rpad as et, smartQuote as rt, splitStringOnFirst as tt, splitStringOnLast as it, splitStringOnce as at, stringContains as st, stringEndsWith as nt, stringEndsWithAny as ot, stringHasContent as lt, stringHashCode as mt, stringStartsWith as pt, stringStartsWithAny as ct, stringToCharcodes as yt, stringToChars as At, stringsDifferAtIndex as gt, substringAfter as dt, substringAfterLast as ft, substringBefore as ut, substringBeforeLast as bt, surroundString as St, textContainsCaseInsensitive as xt, textEndsWithAnyCaseInsensitive as Ct, textEndsWithCaseInsensitive as ht, textStartsWithAnyCaseInsensitive as vt, textStartsWithCaseInsensitive as Et, textToLines as Ot, trimChars as It, trimCharsLeft as Ft, trimCharsRight as Bt, trimStringSlice as Wt, underscore as jt, upperCaseFirst as Pt, wrapColumns as Tt, wrapLine as qt } from "./string.js";
|
|
15
|
+
import { debounce as Nt, delayed as wt, delayedAnimationFrame as Dt, interval as zt, intervalAnimationFrame as Ht, throttle as Mt } from "./timer.js";
|
|
16
16
|
export {
|
|
17
17
|
N as AsyncResult,
|
|
18
18
|
ve as EPSILON,
|
|
@@ -26,8 +26,8 @@ export {
|
|
|
26
26
|
n as arrayDiffOperations,
|
|
27
27
|
o as arrayHasValues,
|
|
28
28
|
l as arrayHead,
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
m as arrayOfIterableIterator,
|
|
30
|
+
p as arrayTail,
|
|
31
31
|
D as biAbs,
|
|
32
32
|
z as biCeilDiv,
|
|
33
33
|
H as biCompare,
|
|
@@ -48,46 +48,47 @@ export {
|
|
|
48
48
|
ee as biPrevPrime,
|
|
49
49
|
te as booleanToInt,
|
|
50
50
|
ie as canParseBoolean,
|
|
51
|
-
|
|
51
|
+
pr as canonicalizeNewlines,
|
|
52
52
|
cr as capitalize,
|
|
53
53
|
yr as capitalizeWords,
|
|
54
54
|
Oe as ceilTo,
|
|
55
|
-
|
|
55
|
+
Ar as chunkString,
|
|
56
56
|
Ie as clamp,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
Fe as clampInt,
|
|
58
|
+
Be as clampSym,
|
|
59
|
+
gr as collapseText,
|
|
60
60
|
c as compareArrays,
|
|
61
61
|
ae as compareBooleans,
|
|
62
|
-
|
|
62
|
+
dr as compareCaseInsensitive,
|
|
63
63
|
We as compareNumbers,
|
|
64
|
-
|
|
64
|
+
fr as compareStrings,
|
|
65
65
|
y as concatArrays,
|
|
66
66
|
ur as containsAllText,
|
|
67
67
|
br as containsAllTextCaseInsensitive,
|
|
68
68
|
Sr as containsAnyText,
|
|
69
69
|
xr as containsAnyTextCaseInsensitive,
|
|
70
70
|
Cr as countStringOccurrences,
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
A as createFilledArray,
|
|
72
|
+
ge as curryLeft,
|
|
73
73
|
hr as dasherize,
|
|
74
74
|
Nt as debounce,
|
|
75
75
|
vr as decodeBase64,
|
|
76
|
-
|
|
76
|
+
pe as deepEqual,
|
|
77
77
|
le as deferred,
|
|
78
78
|
wt as delayed,
|
|
79
|
+
Dt as delayedAnimationFrame,
|
|
79
80
|
Er as deleteFirstFromString,
|
|
80
81
|
Or as deleteStringAfter,
|
|
81
82
|
Ir as deleteStringBefore,
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
Fr as deleteSubstring,
|
|
84
|
+
Br as ellipsis,
|
|
84
85
|
Wr as ellipsisMiddle,
|
|
85
86
|
jr as encodeBase64,
|
|
86
|
-
|
|
87
|
+
g as filterArray,
|
|
87
88
|
Pr as filterCharcodes,
|
|
88
89
|
Tr as filterChars,
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
d as filterMapArray,
|
|
91
|
+
f as filterNullsFromArray,
|
|
91
92
|
u as flatMapArray,
|
|
92
93
|
b as flattenArray,
|
|
93
94
|
je as floorTo,
|
|
@@ -96,14 +97,15 @@ export {
|
|
|
96
97
|
C as generateArray,
|
|
97
98
|
h as generateSequenceArray,
|
|
98
99
|
qr as humanize,
|
|
99
|
-
|
|
100
|
+
de as identity,
|
|
100
101
|
Lr as ifEmptyString,
|
|
101
102
|
Pe as interpolate,
|
|
102
103
|
Te as interpolateAngle,
|
|
103
104
|
qe as interpolateAngleCCW,
|
|
104
105
|
Le as interpolateAngleCW,
|
|
105
106
|
Ne as interpolateWidestAngle,
|
|
106
|
-
|
|
107
|
+
zt as interval,
|
|
108
|
+
Ht as intervalAnimationFrame,
|
|
107
109
|
Nr as isAlpha,
|
|
108
110
|
wr as isAlphaNum,
|
|
109
111
|
v as isArrayEmpty,
|
|
@@ -126,7 +128,7 @@ export {
|
|
|
126
128
|
O as mapArray,
|
|
127
129
|
Qr as mapChars,
|
|
128
130
|
sr as mapRegExp,
|
|
129
|
-
|
|
131
|
+
fe as memoize,
|
|
130
132
|
Ue as mergeObjects,
|
|
131
133
|
we as nearEqual,
|
|
132
134
|
De as nearEqualAngles,
|
|
@@ -142,8 +144,8 @@ export {
|
|
|
142
144
|
Ur as randomStringSequence,
|
|
143
145
|
Xr as randomStringSequenceBase64,
|
|
144
146
|
I as rankArray,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
F as removeAllFromArray,
|
|
148
|
+
B as removeAllFromArrayByPredicate,
|
|
147
149
|
er as removeObjectFields,
|
|
148
150
|
W as removeOneFromArray,
|
|
149
151
|
j as removeOneFromArrayByPredicate,
|
|
@@ -166,14 +168,14 @@ export {
|
|
|
166
168
|
nt as stringEndsWith,
|
|
167
169
|
ot as stringEndsWithAny,
|
|
168
170
|
lt as stringHasContent,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
+
mt as stringHashCode,
|
|
172
|
+
pt as stringStartsWith,
|
|
171
173
|
ct as stringStartsWithAny,
|
|
172
174
|
yt as stringToCharcodes,
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
At as stringToChars,
|
|
176
|
+
gt as stringsDifferAtIndex,
|
|
177
|
+
dt as substringAfter,
|
|
178
|
+
ft as substringAfterLast,
|
|
177
179
|
ut as substringBefore,
|
|
178
180
|
bt as substringBeforeLast,
|
|
179
181
|
St as surroundString,
|
|
@@ -183,11 +185,11 @@ export {
|
|
|
183
185
|
vt as textStartsWithAnyCaseInsensitive,
|
|
184
186
|
Et as textStartsWithCaseInsensitive,
|
|
185
187
|
Ot as textToLines,
|
|
186
|
-
|
|
188
|
+
Mt as throttle,
|
|
187
189
|
Je as toHex,
|
|
188
190
|
It as trimChars,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
+
Ft as trimCharsLeft,
|
|
192
|
+
Bt as trimCharsRight,
|
|
191
193
|
Wt as trimStringSlice,
|
|
192
194
|
jt as underscore,
|
|
193
195
|
T as uniqueByPrimitive,
|
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 p=(n,e)=>{const t=setTimeout(n,e);return()=>clearTimeout(t)},b=(n,e)=>{const t=setInterval(n,e);return()=>clearInterval(t)},F=(n,e,t={})=>{const{noTrailing:o=!1,noLeading:l=!1,debounceMode:i}=t;let a,m=!1,c=0;function f(){a&&clearTimeout(a)}function T(u){const{upcomingOnly:s=!1}=u||{};f(),m=!s}function d(...u){if(m)return;const s=this,v=Date.now()-c;function r(){c=Date.now(),e.apply(s,u)}function A(){a=void 0}!l&&i&&!a&&r(),f(),i===void 0&&v>n?l?(c=Date.now(),o||(a=setTimeout(i?A:r,n))):r():o||(a=setTimeout(i?A:r,i===void 0?n-v:n))}return d.cancel=T,d},g=(n,e,{atBegin:t=!1}={})=>F(n,e,{debounceMode:t!==!1}),y=n=>{let e=null;const t=l=>{e=null,n(l)};return(()=>{e==null&&(e=requestAnimationFrame(t))})(),()=>{e!=null&&(cancelAnimationFrame(e),e=null)}},I=n=>{let e=null;const t=l=>{e=requestAnimationFrame(t),n(l)};return(()=>{e==null&&(e=requestAnimationFrame(t))})(),()=>{e!=null&&(cancelAnimationFrame(e),e=null)}};exports.debounce=g;exports.delayed=p;exports.delayedAnimationFrame=y;exports.interval=b;exports.intervalAnimationFrame=I;exports.throttle=F;
|
package/timer.d.ts
CHANGED
|
@@ -163,3 +163,17 @@ export type DebounceOptions = {
|
|
|
163
163
|
* @public
|
|
164
164
|
*/
|
|
165
165
|
export declare const debounce: <FN extends (...args: unknown[]) => void>(delay: number, callback: FN, { atBegin }?: DebounceOptions) => ThrottledFunction<Parameters<FN>>;
|
|
166
|
+
/**
|
|
167
|
+
* Delays the execution of a function using requestAnimationFrame.
|
|
168
|
+
*
|
|
169
|
+
* @param callback - The function to delay.
|
|
170
|
+
* @returns A function that, when called, will cancel the delay and prevent the original function from being executed.
|
|
171
|
+
*/
|
|
172
|
+
export declare const delayedAnimationFrame: (callback: (time: DOMHighResTimeStamp) => void) => () => void;
|
|
173
|
+
/**
|
|
174
|
+
* Executes a function repeatedly using requestAnimationFrame.
|
|
175
|
+
*
|
|
176
|
+
* @param callback - The function to execute periodically.
|
|
177
|
+
* @returns A function that, when called, will cancel the interval and stop future executions.
|
|
178
|
+
*/
|
|
179
|
+
export declare const intervalAnimationFrame: (callback: (time: DOMHighResTimeStamp) => void) => () => void;
|
package/timer.js
CHANGED
|
@@ -1,38 +1,60 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
return () => clearTimeout(
|
|
4
|
-
},
|
|
5
|
-
const
|
|
6
|
-
return () => clearInterval(
|
|
7
|
-
},
|
|
8
|
-
const { noTrailing:
|
|
9
|
-
let o, f = !1,
|
|
10
|
-
function
|
|
1
|
+
const T = (n, e) => {
|
|
2
|
+
const t = setTimeout(n, e);
|
|
3
|
+
return () => clearTimeout(t);
|
|
4
|
+
}, I = (n, e) => {
|
|
5
|
+
const t = setInterval(n, e);
|
|
6
|
+
return () => clearInterval(t);
|
|
7
|
+
}, F = (n, e, t = {}) => {
|
|
8
|
+
const { noTrailing: a = !1, noLeading: l = !1, debounceMode: i } = t;
|
|
9
|
+
let o, f = !1, c = 0;
|
|
10
|
+
function m() {
|
|
11
11
|
o && clearTimeout(o);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const { upcomingOnly:
|
|
15
|
-
|
|
13
|
+
function A(u) {
|
|
14
|
+
const { upcomingOnly: s = !1 } = u || {};
|
|
15
|
+
m(), f = !s;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
17
|
+
function d(...u) {
|
|
18
18
|
if (f) return;
|
|
19
|
-
const
|
|
20
|
-
function
|
|
21
|
-
|
|
19
|
+
const s = this, p = Date.now() - c;
|
|
20
|
+
function r() {
|
|
21
|
+
c = Date.now(), e.apply(s, u);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function v() {
|
|
24
24
|
o = void 0;
|
|
25
25
|
}
|
|
26
|
-
!
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
!l && i && !o && r(), m(), i === void 0 && p > n ? l ? (c = Date.now(), a || (o = setTimeout(i ? v : r, n))) : r() : a || (o = setTimeout(
|
|
27
|
+
i ? v : r,
|
|
28
|
+
i === void 0 ? n - p : n
|
|
29
29
|
));
|
|
30
30
|
}
|
|
31
|
-
return
|
|
32
|
-
},
|
|
31
|
+
return d.cancel = A, d;
|
|
32
|
+
}, g = (n, e, { atBegin: t = !1 } = {}) => F(n, e, { debounceMode: t !== !1 }), w = (n) => {
|
|
33
|
+
let e = null;
|
|
34
|
+
const t = (l) => {
|
|
35
|
+
e = null, n(l);
|
|
36
|
+
};
|
|
37
|
+
return (() => {
|
|
38
|
+
e == null && (e = requestAnimationFrame(t));
|
|
39
|
+
})(), () => {
|
|
40
|
+
e != null && (cancelAnimationFrame(e), e = null);
|
|
41
|
+
};
|
|
42
|
+
}, x = (n) => {
|
|
43
|
+
let e = null;
|
|
44
|
+
const t = (l) => {
|
|
45
|
+
e = requestAnimationFrame(t), n(l);
|
|
46
|
+
};
|
|
47
|
+
return (() => {
|
|
48
|
+
e == null && (e = requestAnimationFrame(t));
|
|
49
|
+
})(), () => {
|
|
50
|
+
e != null && (cancelAnimationFrame(e), e = null);
|
|
51
|
+
};
|
|
52
|
+
};
|
|
33
53
|
export {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
54
|
+
g as debounce,
|
|
55
|
+
T as delayed,
|
|
56
|
+
w as delayedAnimationFrame,
|
|
57
|
+
I as interval,
|
|
58
|
+
x as intervalAnimationFrame,
|
|
59
|
+
F as throttle
|
|
38
60
|
};
|