tsu 2.9.1 → 2.10.1
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/index.cjs +1 -1
- package/dist/index.d.cts +148 -50
- package/dist/index.d.ts +148 -50
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var x=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var M=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var S=(e,r)=>{for(var t in r)x(e,t,{get:r[t],enumerable:!0})},U=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of M(r))!F.call(e,o)&&o!==t&&x(e,o,{get:()=>r[o],enumerable:!(n=E(r,o))||n.enumerable});return e};var L=e=>U(x({},"__esModule",{value:!0}),e);var We={};S(We,{average:()=>W,capitalise:()=>N,capitalize:()=>Me,ceil:()=>X,chars:()=>Fe,clamp:()=>d,clone:()=>p,copyToClipboard:()=>ge,debounce:()=>ve,drop:()=>D,es:()=>me,floor:()=>z,groups:()=>R,head:()=>q,init:()=>B,isArray:()=>f,isBlank:()=>Se,isBoolean:()=>ee,isBrowser:()=>m,isDefined:()=>re,isEmpty:()=>Ue,isEmptyArray:()=>te,isEmptyObject:()=>ne,isEven:()=>H,isFunction:()=>oe,isNull:()=>s,isNumber:()=>g,isObject:()=>T,isObjectLike:()=>l,isOdd:()=>_,isString:()=>a,isTouchDevice:()=>ie,isUndefined:()=>ue,isWindow:()=>fe,ks:()=>se,last:()=>I,max:()=>V,memoise:()=>k,memoize:()=>ke,min:()=>J,noop:()=>Ae,once:()=>Oe,partition:()=>$,product:()=>K,randomChance:()=>Y,randomNumber:()=>u,range:()=>P,replaceChar:()=>Le,round:()=>Z,scroll:()=>je,shuffle:()=>pe,sleep:()=>Ce,splitArray:()=>ce,splitString:()=>De,sum:()=>b,tail:()=>ae,take:()=>xe,throttle:()=>Ne,toArray:()=>be,toCamel:()=>Re,toDp:()=>G,toKebab:()=>qe,toNumber:()=>Q,toOrdinal:()=>Be,toRomanNumerals:()=>Ie,truncate:()=>$e,unchars:()=>Pe,uniq:()=>de,uuid:()=>Ee,vs:()=>le});module.exports=L(We);function D(e,r){return e<=0?[...r]:r.slice(e)}function R(e,r){if(r<=0)throw new Error("[tsu] Invalid group size. Is it greater than 0?");if(r>=e.length)return[[...e]];let t=[];for(let n=0;n<e.length;n+=r)t.push(e.slice(n,n+r));return t}function q(e){return e[0]}function B(e){return e.slice(0,e.length-1)}function I(e){return e[e.length-1]}function $(e,r){let t=[],n=[];for(let o=0;o<e.length;o++){let i=e[o];r(i,o,e)?t.push(i):n.push(i)}return[t,n]}function P(...e){let r,t,n;e.length===1?(t=e[0],r=0,n=1):(r=e[0],t=e[1],n=e[2]||1),n<=0&&(console.warn("[tsu] warning: a step less than or equal to 0 will be set to 1."),n=1);let o=[],i=r;for(;i<t;)o.push(i),i+=n||1;return o}function W(e){return e.length<1?0:b(e)/e.length}function X(e,r=1){let t=e/r;return Math.ceil(t)*r}function d(e,r,t){return Math.min(t,Math.max(r,e))}function z(e,r=1){let t=e/r;return Math.floor(t)*r}function H(e){return e%2===0}function _(e){return e%2!==0}function V(...e){let r;return e.length===1&&Array.isArray(e[0])?r=e[0]:r=e,Math.max(...r)}function J(...e){let r;return e.length===1&&Array.isArray(e[0])?r=e[0]:r=e,Math.min(...r)}function K(e){if(e.length<1)return 0;let r=1;for(let t=0;t<e.length;t++)r*=e[t];return r}function u(...e){let r,t;return e.length===1?(r=0,t=e[0]):(r=e[0],t=e[1]),Math.floor(Math.random()*(t-r))+r}function Y(e){return u(e)===0}function Z(e,r=1){let t=e/r;return Math.round(t)*r}function b(e){let r=0;for(let t=0;t<e.length;t++)r+=e[t];return r}function G(e,r=0){r<0&&console.warn("[tsu] warning: decimalPlaces less than 0 are set to 0."),r>100&&console.warn("[tsu] warning: decimalPlaces greater than 100 are set to 100.");let t=d(r,0,100);return Number(e.toFixed(t))}function Q(e,r=[]){if(!e.length)return NaN;let t=["#","\xA3","\u20AC","$","%",",",...r],n=new RegExp(`[${t.join("")}]`,"g");return Number(e.replace(n,""))}function f(e){return Array.isArray(e)}function ee(e){return typeof e=="boolean"}function m(){return typeof window<"u"}function re(e){return typeof e<"u"}function te(e){return f(e)&&e.length===0}function ne(e){if(!T(e))return!1;for(let r in e)return!1;return!0}function oe(e){return typeof e=="function"}function s(e){return Object.prototype.toString.call(e)==="[object Null]"}function g(e){return typeof e=="number"}function T(e){return Object.prototype.toString.call(e)==="[object Object]"}function l(e){return typeof e=="object"}function a(e){return typeof e=="string"}function ie(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function ue(e){return typeof e>"u"}function fe(e){return m()&&Object.prototype.toString.call(e)==="[object Window]"}function p(e){if(f(e)){let r=[];for(let t=0;t<e.length;t++)l(e[t])&&!s(e[t])?r[t]=p(e[t]):r[t]=e[t];return r}if(l(e)&&!s(e)){let r={};for(let t in e)l(e[t])&&!s(e[t])?r[t]=p(e[t]):r[t]=e[t];return r}return e}function me(e){return Object.entries(e)}function se(e){return Object.keys(e)}function le(e){return Object.values(e)}function pe(e){let r=p(e),t,n,o;for(t=r.length;t;t-=1)n=u(t),o=r[t-1],r[t-1]=r[n],r[n]=o;return r}function ce(e,r){return r<=0?[[],[...e]]:r>e.length?[[...e],[]]:[e.slice(0,r),e.slice(r)]}function ae(e){return e.slice(1)}function xe(e,r){return e<=0?[]:r.slice(0,e)}function be(e){return e?Array.isArray(e)?e:[e]:[]}function de(e){return Array.from(new Set(e))}function Te(e){let r=document.createElement("textarea");r.value=e??"",r.style.position="absolute",r.style.opacity="0",document.body.appendChild(r),r.select(),document.execCommand("copy"),r.remove()}function ge(e){m()&&(window.navigator&&"clipboard"in window.navigator?navigator.clipboard.writeText(e):Te(e))}function ye(e){return e<.5?4*Math.pow(e,3):(e-1)*(2*e-2)*(2*e-2)+1}function he(e,r,t,n){return e+(r-e)*ye(t/n)}function we(e,r){return e.nodeName==="HTML"?-r:e.getBoundingClientRect().top+r}function je({to:e,offset:r=0,duration:t=1e3,container:n=null}){let o=a(e)?document.querySelector(e):e,i=a(n)?document.querySelector(n):n,c=i?.scrollTop||window?.pageYOffset||0,y=(g(o)?o:we(o,c))+r,C=Date.now();function h(){let w=Date.now()-C,j=w<t,v=j?he(c,y,w,t):y;j&&requestAnimationFrame(h),i?i.scrollTop=v:window.scrollTo(0,v)}h()}function ve(e,r){r<0&&console.warn("[tsu] warning: debounce delays less than 0 will be set to 0.");let t;return function(...n){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),e(...n)},r)}}function k(e){let r={};return function(...t){let n=JSON.stringify(t);if(n in r)return r[n];let o=e(...t);return r[n]=o,o}}var ke=k;function Oe(e){let r=!1;return(...t)=>{r||(e(...t),r=!0)}}function Ne(e,r){r<0&&console.warn("[tsu] warning: throttle limits less than 0 will be set to 0.");let t=!1;return function(...n){t||(e(...n),t=!0,setTimeout(()=>{t=!1},r))}}function Ae(){}async function Ce(e){return e<0&&console.warn("[tsu] warning: sleep durations less than 0 are set to 0."),new Promise(r=>{setTimeout(r,e)})}var O="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function Ee(e=16){let r=O.length,t=e,n="";for(;t--;)n+=O[u(r)];return n}function N(e,r=!1,t=" "){return r?e.split(t).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(t):e.charAt(0).toUpperCase()+e.slice(1)}var Me=N;function Fe(e){return e.split("")}function Se(e){return e.trim().length===0}function Ue(e){return e.length===0}function Le(e,r,t){return r<0||r>e.length-1?e:e.slice(0,r)+t+e.slice(r+1)}function De(e,r){return r<=0?["",e]:r>e.length?[e,""]:[e.slice(0,r),e.slice(r)]}function Re(e){let r=/-(\w)/g;return e.replace(r,(t,n)=>n?n.toUpperCase():"")}function qe(e){let r=/\B([A-Z])/g;return e.replace(r,"-$1").toLowerCase()}function Be(e){let t=["st","nd","rd"][(Math.abs(e)/10%10^1&&Math.abs(e)%10)-1]||"th";return`${e}${t}`}var A={1:"I",4:"IV",5:"V",9:"IX",10:"X",40:"XL",50:"L",90:"XC",100:"C",400:"CD",500:"D",900:"CM",1e3:"M"};function Ie(e,r=!1){let t=e,n="",o=Object.keys(A).map(Number).sort((i,c)=>c-i);for(let i of o)for(;t>=i;)n+=A[i],t-=i;return r?n.toLowerCase():n}function $e(e,r,t="..."){return r<=0?t:e.slice(0,r)+t}function Pe(e){return e.join("")}0&&(module.exports={average,capitalise,capitalize,ceil,chars,clamp,clone,copyToClipboard,debounce,drop,es,floor,groups,head,init,isArray,isBlank,isBoolean,isBrowser,isDefined,isEmpty,isEmptyArray,isEmptyObject,isEven,isFunction,isNull,isNumber,isObject,isObjectLike,isOdd,isString,isTouchDevice,isUndefined,isWindow,ks,last,max,memoise,memoize,min,noop,once,partition,product,randomChance,randomNumber,range,replaceChar,round,scroll,shuffle,sleep,splitArray,splitString,sum,tail,take,throttle,toArray,toCamel,toDp,toKebab,toNumber,toOrdinal,toRomanNumerals,truncate,unchars,uniq,uuid,vs});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
type Arrayable<T> = T | Array<T>;
|
|
2
|
-
type Nullable<T> = T | null | undefined;
|
|
3
|
-
type Fn<T = any> = (...args: any[]) => T;
|
|
4
|
-
type VoidFn = Fn<void>;
|
|
5
|
-
type Obj<V = unknown> = Record<string | symbol | number, V>;
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
2
|
* Removes the first `n` items of an array.
|
|
9
3
|
*
|
|
@@ -12,14 +6,16 @@ type Obj<V = unknown> = Record<string | symbol | number, V>;
|
|
|
12
6
|
* @returns The remaining items.
|
|
13
7
|
*/
|
|
14
8
|
declare function drop<T>(n: number, array: readonly T[]): T[];
|
|
9
|
+
|
|
15
10
|
/**
|
|
16
11
|
* Splits an array into groups of equal size.
|
|
17
12
|
*
|
|
18
|
-
* @param s - The size of each group.
|
|
19
13
|
* @param array - The array.
|
|
14
|
+
* @param n - The size of each group.
|
|
20
15
|
* @returns The array split into groups.
|
|
21
16
|
*/
|
|
22
|
-
declare function
|
|
17
|
+
declare function groups<T>(array: readonly T[], n: number): T[][];
|
|
18
|
+
|
|
23
19
|
/**
|
|
24
20
|
* Returns the first item of an array.
|
|
25
21
|
*
|
|
@@ -28,6 +24,7 @@ declare function groupsOf<T>(s: number, array: readonly T[]): T[][];
|
|
|
28
24
|
*/
|
|
29
25
|
declare function head(array: readonly []): undefined;
|
|
30
26
|
declare function head<T>(array: readonly T[]): T;
|
|
27
|
+
|
|
31
28
|
/**
|
|
32
29
|
* Returns all but the last item of an array.
|
|
33
30
|
*
|
|
@@ -35,6 +32,7 @@ declare function head<T>(array: readonly T[]): T;
|
|
|
35
32
|
* @returns The array without the last item.
|
|
36
33
|
*/
|
|
37
34
|
declare function init<T>(array: readonly T[]): T[];
|
|
35
|
+
|
|
38
36
|
/**
|
|
39
37
|
* Returns the last item of an array.
|
|
40
38
|
*
|
|
@@ -43,6 +41,7 @@ declare function init<T>(array: readonly T[]): T[];
|
|
|
43
41
|
*/
|
|
44
42
|
declare function last(array: readonly []): undefined;
|
|
45
43
|
declare function last<T>(array: readonly T[]): T;
|
|
44
|
+
|
|
46
45
|
/**
|
|
47
46
|
* Splits an array into two based on a predicate function.
|
|
48
47
|
*
|
|
@@ -51,6 +50,7 @@ declare function last<T>(array: readonly T[]): T;
|
|
|
51
50
|
* @returns The tuple of values that satisfy the predicate and those that don't.
|
|
52
51
|
*/
|
|
53
52
|
declare function partition<T, U = T>(array: readonly (T | U)[], filter: (current: T | U, idx: number, array: readonly (T | U)[]) => boolean): [T[], U[]];
|
|
53
|
+
|
|
54
54
|
/**
|
|
55
55
|
* Generates a range of numbers.
|
|
56
56
|
*
|
|
@@ -61,6 +61,7 @@ declare function partition<T, U = T>(array: readonly (T | U)[], filter: (current
|
|
|
61
61
|
*/
|
|
62
62
|
declare function range(stop: number): number[];
|
|
63
63
|
declare function range(start: number, stop: number, step?: number): number[];
|
|
64
|
+
|
|
64
65
|
/**
|
|
65
66
|
* Randomly shuffles items in an array.
|
|
66
67
|
*
|
|
@@ -68,14 +69,16 @@ declare function range(start: number, stop: number, step?: number): number[];
|
|
|
68
69
|
* @returns A copy of the array with its items randomly shuffled.
|
|
69
70
|
*/
|
|
70
71
|
declare function shuffle<T>(array: T[]): T[];
|
|
72
|
+
|
|
71
73
|
/**
|
|
72
74
|
* Splits an array into two at a specified index.
|
|
73
75
|
*
|
|
74
|
-
* @param i - The position to split at.
|
|
75
76
|
* @param array - The array.
|
|
77
|
+
* @param i - The position to split at.
|
|
76
78
|
* @returns The tuple of values before and after the split.
|
|
77
79
|
*/
|
|
78
|
-
declare function
|
|
80
|
+
declare function splitArray<T>(array: readonly T[], i: number): [T[], T[]];
|
|
81
|
+
|
|
79
82
|
/**
|
|
80
83
|
* Returns all but the first item of an array.
|
|
81
84
|
*
|
|
@@ -83,6 +86,7 @@ declare function splitAt<T>(i: number, array: readonly T[]): [T[], T[]];
|
|
|
83
86
|
* @returns The array without the first item.
|
|
84
87
|
*/
|
|
85
88
|
declare function tail<T>(array: readonly T[]): T[];
|
|
89
|
+
|
|
86
90
|
/**
|
|
87
91
|
* Returns the first `n` items of an array.
|
|
88
92
|
*
|
|
@@ -91,6 +95,13 @@ declare function tail<T>(array: readonly T[]): T[];
|
|
|
91
95
|
* @returns The first `n` items.
|
|
92
96
|
*/
|
|
93
97
|
declare function take<T>(n: number, array: readonly T[]): T[];
|
|
98
|
+
|
|
99
|
+
type Arrayable<T> = T | Array<T>;
|
|
100
|
+
type Nullable<T> = T | null | undefined;
|
|
101
|
+
type Fn<T = any> = (...args: any[]) => T;
|
|
102
|
+
type VoidFn = Fn<void>;
|
|
103
|
+
type Obj<V = unknown> = Record<string | symbol | number, V>;
|
|
104
|
+
|
|
94
105
|
/**
|
|
95
106
|
* Wraps a single value in an array, if not already an array.
|
|
96
107
|
*
|
|
@@ -98,6 +109,7 @@ declare function take<T>(n: number, array: readonly T[]): T[];
|
|
|
98
109
|
* @returns The item wrapped in an array, or the provided array.
|
|
99
110
|
*/
|
|
100
111
|
declare function toArray<T>(maybeArray: Nullable<Arrayable<T>>): T[];
|
|
112
|
+
|
|
101
113
|
/**
|
|
102
114
|
* Removes duplicate primitive values from an array.
|
|
103
115
|
*
|
|
@@ -112,6 +124,7 @@ declare function uniq<T>(array: readonly T[]): T[];
|
|
|
112
124
|
* @param str - The string to be copied to the clipboard.
|
|
113
125
|
*/
|
|
114
126
|
declare function copyToClipboard(str: string): void;
|
|
127
|
+
|
|
115
128
|
interface ScrollConfig {
|
|
116
129
|
to: Element | string | number;
|
|
117
130
|
offset?: number;
|
|
@@ -136,21 +149,25 @@ declare function scroll({ to, offset, duration, container }: ScrollConfig): void
|
|
|
136
149
|
* @param delay - The time period (in ms).
|
|
137
150
|
* @returns The debounced function.
|
|
138
151
|
*/
|
|
139
|
-
declare function debounce(fn:
|
|
152
|
+
declare function debounce(fn: Fn<void>, delay: number): Fn<void>;
|
|
153
|
+
|
|
140
154
|
/**
|
|
141
155
|
* Optimises subsequent calls of a function by caching return values.
|
|
142
156
|
*
|
|
143
157
|
* @param fn - The function.
|
|
144
|
-
* @returns The
|
|
158
|
+
* @returns The memoised function.
|
|
145
159
|
*/
|
|
146
|
-
declare function
|
|
160
|
+
declare function memoise<T>(fn: Fn<T>): Fn<T>;
|
|
161
|
+
declare const memoize: typeof memoise;
|
|
162
|
+
|
|
147
163
|
/**
|
|
148
164
|
* Enforces that a function is only callable one time.
|
|
149
165
|
*
|
|
150
166
|
* @param fn - The function.
|
|
151
167
|
* @returns The one-time callable function.
|
|
152
168
|
*/
|
|
153
|
-
declare function once(fn:
|
|
169
|
+
declare function once(fn: Fn<void>): Fn<void>;
|
|
170
|
+
|
|
154
171
|
/**
|
|
155
172
|
* Prevents function execution for a specified time period after it was last called.
|
|
156
173
|
*
|
|
@@ -158,7 +175,7 @@ declare function once(fn: VoidFn): VoidFn;
|
|
|
158
175
|
* @param limit - The time period.
|
|
159
176
|
* @returns The throttled function.
|
|
160
177
|
*/
|
|
161
|
-
declare function throttle(fn:
|
|
178
|
+
declare function throttle(fn: Fn<void>, limit: number): Fn<void>;
|
|
162
179
|
|
|
163
180
|
/**
|
|
164
181
|
* Identifies if a value is an array.
|
|
@@ -167,6 +184,7 @@ declare function throttle(fn: VoidFn, limit: number): VoidFn;
|
|
|
167
184
|
* @returns If the value is an array.
|
|
168
185
|
*/
|
|
169
186
|
declare function isArray(val: unknown): val is any[];
|
|
187
|
+
|
|
170
188
|
/**
|
|
171
189
|
* Identifies if a value is a boolean.
|
|
172
190
|
*
|
|
@@ -174,12 +192,14 @@ declare function isArray(val: unknown): val is any[];
|
|
|
174
192
|
* @returns If the value is a boolean.
|
|
175
193
|
*/
|
|
176
194
|
declare function isBoolean(val: unknown): val is boolean;
|
|
195
|
+
|
|
177
196
|
/**
|
|
178
197
|
* Identifies if the code is being run in a browser.
|
|
179
198
|
*
|
|
180
199
|
* @returns If the code is being run in a browser.
|
|
181
200
|
*/
|
|
182
201
|
declare function isBrowser(): boolean;
|
|
202
|
+
|
|
183
203
|
/**
|
|
184
204
|
* Identifies if a value is defined.
|
|
185
205
|
*
|
|
@@ -187,6 +207,7 @@ declare function isBrowser(): boolean;
|
|
|
187
207
|
* @returns If the value is defined.
|
|
188
208
|
*/
|
|
189
209
|
declare function isDefined<T>(val: T): val is Exclude<T, null | undefined>;
|
|
210
|
+
|
|
190
211
|
/**
|
|
191
212
|
* Identifies if a value is an empty array.
|
|
192
213
|
*
|
|
@@ -194,13 +215,15 @@ declare function isDefined<T>(val: T): val is Exclude<T, null | undefined>;
|
|
|
194
215
|
* @returns If the value is an empty array.
|
|
195
216
|
*/
|
|
196
217
|
declare function isEmptyArray(val: unknown): val is [];
|
|
218
|
+
|
|
197
219
|
/**
|
|
198
220
|
* Identifies if a value is an empty object.
|
|
199
221
|
*
|
|
200
222
|
* @param val - The value.
|
|
201
223
|
* @returns If the value is an empty object.
|
|
202
224
|
*/
|
|
203
|
-
declare function isEmptyObject(val: unknown): val is
|
|
225
|
+
declare function isEmptyObject(val: unknown): val is Obj<never>;
|
|
226
|
+
|
|
204
227
|
/**
|
|
205
228
|
* Identifies if a value is a function.
|
|
206
229
|
*
|
|
@@ -208,6 +231,7 @@ declare function isEmptyObject(val: unknown): val is Record<string, never>;
|
|
|
208
231
|
* @returns If the value is a function.
|
|
209
232
|
*/
|
|
210
233
|
declare function isFunction<T extends Fn>(val: unknown): val is T;
|
|
234
|
+
|
|
211
235
|
/**
|
|
212
236
|
* Identifies if a value is null.
|
|
213
237
|
*
|
|
@@ -215,6 +239,7 @@ declare function isFunction<T extends Fn>(val: unknown): val is T;
|
|
|
215
239
|
* @returns If the value is null.
|
|
216
240
|
*/
|
|
217
241
|
declare function isNull(val: unknown): val is null;
|
|
242
|
+
|
|
218
243
|
/**
|
|
219
244
|
* Identifies if a value is a number.
|
|
220
245
|
*
|
|
@@ -222,6 +247,7 @@ declare function isNull(val: unknown): val is null;
|
|
|
222
247
|
* @returns If the value is a number.
|
|
223
248
|
*/
|
|
224
249
|
declare function isNumber(val: unknown): val is number;
|
|
250
|
+
|
|
225
251
|
/**
|
|
226
252
|
* Identifies if a value is an object.
|
|
227
253
|
*
|
|
@@ -229,6 +255,7 @@ declare function isNumber(val: unknown): val is number;
|
|
|
229
255
|
* @returns If the value is an object.
|
|
230
256
|
*/
|
|
231
257
|
declare function isObject(val: unknown): val is Obj;
|
|
258
|
+
|
|
232
259
|
/**
|
|
233
260
|
* Identifies if a value is an array, an object, a date, or null.
|
|
234
261
|
*
|
|
@@ -236,6 +263,7 @@ declare function isObject(val: unknown): val is Obj;
|
|
|
236
263
|
* @returns If the value is an array, an object, a date, or null.
|
|
237
264
|
*/
|
|
238
265
|
declare function isObjectLike(val: unknown): val is object;
|
|
266
|
+
|
|
239
267
|
/**
|
|
240
268
|
* Identifies if a value is a string.
|
|
241
269
|
*
|
|
@@ -243,12 +271,14 @@ declare function isObjectLike(val: unknown): val is object;
|
|
|
243
271
|
* @returns If the value is a string.
|
|
244
272
|
*/
|
|
245
273
|
declare function isString(val: unknown): val is string;
|
|
274
|
+
|
|
246
275
|
/**
|
|
247
276
|
* Identifies if the code is being run on a touch device.
|
|
248
277
|
*
|
|
249
278
|
* @returns If the code is being run on a touch device.
|
|
250
279
|
*/
|
|
251
280
|
declare function isTouchDevice(): boolean;
|
|
281
|
+
|
|
252
282
|
/**
|
|
253
283
|
* Identifies if a value is undefined.
|
|
254
284
|
*
|
|
@@ -256,6 +286,7 @@ declare function isTouchDevice(): boolean;
|
|
|
256
286
|
* @returns If the value is undefined.
|
|
257
287
|
*/
|
|
258
288
|
declare function isUndefined(val: unknown): val is undefined;
|
|
289
|
+
|
|
259
290
|
/**
|
|
260
291
|
* Identifies if a value is the global window.
|
|
261
292
|
*
|
|
@@ -264,6 +295,37 @@ declare function isUndefined(val: unknown): val is undefined;
|
|
|
264
295
|
*/
|
|
265
296
|
declare function isWindow(val: unknown): val is Window;
|
|
266
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Does nothing.
|
|
300
|
+
*
|
|
301
|
+
* @returns Nothing.
|
|
302
|
+
*/
|
|
303
|
+
declare function noop(): void;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Halts thread execution for a specified time period.
|
|
307
|
+
*
|
|
308
|
+
* @param duration - The time period (in ms).
|
|
309
|
+
* @returns The halting promise.
|
|
310
|
+
*/
|
|
311
|
+
declare function sleep(duration: number): Promise<void>;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Generates a random string of a specified length.
|
|
315
|
+
*
|
|
316
|
+
* @param length - The length of the randomly generated string.
|
|
317
|
+
* @returns The randomly generated string.
|
|
318
|
+
*/
|
|
319
|
+
declare function uuid(length?: number): string;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Returns the average of a number array.
|
|
323
|
+
*
|
|
324
|
+
* @param ns - The number array.
|
|
325
|
+
* @returns The average.
|
|
326
|
+
*/
|
|
327
|
+
declare function average(ns: readonly number[]): number;
|
|
328
|
+
|
|
267
329
|
/**
|
|
268
330
|
* Rounds a number up to the nearest multiple of the specified factor.
|
|
269
331
|
*
|
|
@@ -272,6 +334,7 @@ declare function isWindow(val: unknown): val is Window;
|
|
|
272
334
|
* @returns The rounded number.
|
|
273
335
|
*/
|
|
274
336
|
declare function ceil(n: number, factor?: number): number;
|
|
337
|
+
|
|
275
338
|
/**
|
|
276
339
|
* Restricts a number between two bounds.
|
|
277
340
|
*
|
|
@@ -281,6 +344,7 @@ declare function ceil(n: number, factor?: number): number;
|
|
|
281
344
|
* @returns The number restricted between the specified bounds.
|
|
282
345
|
*/
|
|
283
346
|
declare function clamp(n: number, min: number, max: number): number;
|
|
347
|
+
|
|
284
348
|
/**
|
|
285
349
|
* Rounds a number down to the nearest multiple of the specified factor.
|
|
286
350
|
*
|
|
@@ -289,6 +353,7 @@ declare function clamp(n: number, min: number, max: number): number;
|
|
|
289
353
|
* @returns The rounded number.
|
|
290
354
|
*/
|
|
291
355
|
declare function floor(n: number, factor?: number): number;
|
|
356
|
+
|
|
292
357
|
/**
|
|
293
358
|
* Identifies if a number is even.
|
|
294
359
|
*
|
|
@@ -296,6 +361,7 @@ declare function floor(n: number, factor?: number): number;
|
|
|
296
361
|
* @returns If the number is even.
|
|
297
362
|
*/
|
|
298
363
|
declare function isEven(n: number): boolean;
|
|
364
|
+
|
|
299
365
|
/**
|
|
300
366
|
* Identifies if a number is odd.
|
|
301
367
|
*
|
|
@@ -303,6 +369,7 @@ declare function isEven(n: number): boolean;
|
|
|
303
369
|
* @returns If the number is odd.
|
|
304
370
|
*/
|
|
305
371
|
declare function isOdd(n: number): boolean;
|
|
372
|
+
|
|
306
373
|
/**
|
|
307
374
|
* Returns the maximum number of provided numbers or array of numbers.
|
|
308
375
|
*
|
|
@@ -310,6 +377,7 @@ declare function isOdd(n: number): boolean;
|
|
|
310
377
|
* @returns The maximum number.
|
|
311
378
|
*/
|
|
312
379
|
declare function max(...ns: number[] | [number[]]): number;
|
|
380
|
+
|
|
313
381
|
/**
|
|
314
382
|
* Returns the minimum number of provided numbers or array of numbers.
|
|
315
383
|
*
|
|
@@ -317,6 +385,7 @@ declare function max(...ns: number[] | [number[]]): number;
|
|
|
317
385
|
* @returns The minimum number.
|
|
318
386
|
*/
|
|
319
387
|
declare function min(...ns: number[] | [number[]]): number;
|
|
388
|
+
|
|
320
389
|
/**
|
|
321
390
|
* Returns the product of a number array.
|
|
322
391
|
*
|
|
@@ -324,6 +393,7 @@ declare function min(...ns: number[] | [number[]]): number;
|
|
|
324
393
|
* @returns The product.
|
|
325
394
|
*/
|
|
326
395
|
declare function product(ns: readonly number[]): number;
|
|
396
|
+
|
|
327
397
|
/**
|
|
328
398
|
* Rolls an n-sided die.
|
|
329
399
|
*
|
|
@@ -331,6 +401,7 @@ declare function product(ns: readonly number[]): number;
|
|
|
331
401
|
* @returns If the die roll was 0.
|
|
332
402
|
*/
|
|
333
403
|
declare function randomChance(n: number): boolean;
|
|
404
|
+
|
|
334
405
|
/**
|
|
335
406
|
* Generates a random integer between bounds.
|
|
336
407
|
*
|
|
@@ -340,6 +411,7 @@ declare function randomChance(n: number): boolean;
|
|
|
340
411
|
*/
|
|
341
412
|
declare function randomNumber(max: number): number;
|
|
342
413
|
declare function randomNumber(min: number, max: number): number;
|
|
414
|
+
|
|
343
415
|
/**
|
|
344
416
|
* Rounds a number to the nearest multiple of the specified factor.
|
|
345
417
|
*
|
|
@@ -348,6 +420,7 @@ declare function randomNumber(min: number, max: number): number;
|
|
|
348
420
|
* @returns The rounded number.
|
|
349
421
|
*/
|
|
350
422
|
declare function round(n: number, factor?: number): number;
|
|
423
|
+
|
|
351
424
|
/**
|
|
352
425
|
* Returns the sum of a number array.
|
|
353
426
|
*
|
|
@@ -355,14 +428,24 @@ declare function round(n: number, factor?: number): number;
|
|
|
355
428
|
* @returns The sum.
|
|
356
429
|
*/
|
|
357
430
|
declare function sum(ns: readonly number[]): number;
|
|
431
|
+
|
|
358
432
|
/**
|
|
359
|
-
*
|
|
433
|
+
* Rounds a number to a specified number of decimal places.
|
|
360
434
|
*
|
|
361
|
-
* @param n - The number to
|
|
362
|
-
* @param
|
|
363
|
-
* @returns
|
|
435
|
+
* @param n - The number to round.
|
|
436
|
+
* @param decimalPlaces - The number of decimal places to round to.
|
|
437
|
+
* @returns The rounded number.
|
|
364
438
|
*/
|
|
365
|
-
declare function
|
|
439
|
+
declare function toDp(n: number, decimalPlaces?: number): number;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Converts a string which contains a number into the number itself.
|
|
443
|
+
*
|
|
444
|
+
* @param str - The string.
|
|
445
|
+
* @param extensions - Additional symbols to consider in the conversion.
|
|
446
|
+
* @returns The number.
|
|
447
|
+
*/
|
|
448
|
+
declare function toNumber(str: string, extensions?: string[]): number;
|
|
366
449
|
|
|
367
450
|
/**
|
|
368
451
|
* Deep clones an array or object.
|
|
@@ -371,35 +454,30 @@ declare function toRomanNumerals(n: number, lowerCase?: boolean): string;
|
|
|
371
454
|
* @returns A deep clone of the input array or object.
|
|
372
455
|
*/
|
|
373
456
|
declare function clone<T>(input: T): T;
|
|
457
|
+
|
|
374
458
|
/**
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
* @returns Nothing.
|
|
378
|
-
*/
|
|
379
|
-
declare function noop(): void;
|
|
380
|
-
/**
|
|
381
|
-
* Halts thread execution for a specified time period.
|
|
459
|
+
* Strict-typed, shorthand `Object.entries`
|
|
382
460
|
*
|
|
383
|
-
* @param
|
|
384
|
-
* @returns The
|
|
461
|
+
* @param obj - The object to extract the entries from.
|
|
462
|
+
* @returns The entries.
|
|
385
463
|
*/
|
|
386
|
-
declare function
|
|
464
|
+
declare function es<T extends object>(obj: T): [keyof T, T[keyof T]][];
|
|
465
|
+
|
|
387
466
|
/**
|
|
388
|
-
*
|
|
467
|
+
* Strict-typed, shorthand `Object.keys`
|
|
389
468
|
*
|
|
390
|
-
* @param
|
|
391
|
-
* @returns The
|
|
469
|
+
* @param obj - The object to extract the keys from.
|
|
470
|
+
* @returns The keys.
|
|
392
471
|
*/
|
|
393
|
-
declare function
|
|
472
|
+
declare function ks<T extends object>(obj: T): Array<`${keyof T & (string | number | boolean | null | undefined)}`>;
|
|
394
473
|
|
|
395
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
396
474
|
/**
|
|
397
|
-
*
|
|
475
|
+
* Shorthand `Object.values`
|
|
398
476
|
*
|
|
399
|
-
* @param
|
|
400
|
-
* @returns The
|
|
477
|
+
* @param obj - The object to extract the values from.
|
|
478
|
+
* @returns The values.
|
|
401
479
|
*/
|
|
402
|
-
declare function
|
|
480
|
+
declare function vs<T>(obj: Obj<T>): T[];
|
|
403
481
|
|
|
404
482
|
/**
|
|
405
483
|
* Capitalises the first letter of one word, or all words, in a string.
|
|
@@ -410,6 +488,8 @@ declare function deepMerge<T extends Obj<any>[]>(...objects: T): UnionToIntersec
|
|
|
410
488
|
* @returns The capitalised string.
|
|
411
489
|
*/
|
|
412
490
|
declare function capitalise(str: string, allWords?: boolean, delimiter?: string): string;
|
|
491
|
+
declare const capitalize: typeof capitalise;
|
|
492
|
+
|
|
413
493
|
/**
|
|
414
494
|
* Separates a string into an array of characters.
|
|
415
495
|
*
|
|
@@ -417,6 +497,7 @@ declare function capitalise(str: string, allWords?: boolean, delimiter?: string)
|
|
|
417
497
|
* @returns The string's characters.
|
|
418
498
|
*/
|
|
419
499
|
declare function chars(str: string): string[];
|
|
500
|
+
|
|
420
501
|
/**
|
|
421
502
|
* Identifies strings which only contain whitespace.
|
|
422
503
|
*
|
|
@@ -424,6 +505,7 @@ declare function chars(str: string): string[];
|
|
|
424
505
|
* @returns If the string is blank.
|
|
425
506
|
*/
|
|
426
507
|
declare function isBlank(str: string): boolean;
|
|
508
|
+
|
|
427
509
|
/**
|
|
428
510
|
* Identifies empty strings.
|
|
429
511
|
*
|
|
@@ -431,15 +513,17 @@ declare function isBlank(str: string): boolean;
|
|
|
431
513
|
* @returns If the string is empty.
|
|
432
514
|
*/
|
|
433
515
|
declare function isEmpty(str: string): boolean;
|
|
516
|
+
|
|
434
517
|
/**
|
|
435
518
|
* Replaces a character at a specified index in a string with a new character.
|
|
436
519
|
*
|
|
437
520
|
* @param str - The string.
|
|
438
521
|
* @param i - The index of the character to replace.
|
|
439
522
|
* @param char - The character to replace with.
|
|
440
|
-
* @returns
|
|
523
|
+
* @returns The modified string with the character replaced.
|
|
441
524
|
*/
|
|
442
525
|
declare function replaceChar(str: string, i: number, char: string): string;
|
|
526
|
+
|
|
443
527
|
/**
|
|
444
528
|
* Splits a string into two at a specified index.
|
|
445
529
|
*
|
|
@@ -447,7 +531,8 @@ declare function replaceChar(str: string, i: number, char: string): string;
|
|
|
447
531
|
* @param i - The position to split at.
|
|
448
532
|
* @returns The tuple of strings before and after the split.
|
|
449
533
|
*/
|
|
450
|
-
declare function
|
|
534
|
+
declare function splitString(str: string, i: number): [string, string];
|
|
535
|
+
|
|
451
536
|
/**
|
|
452
537
|
* Converts a kebab case string to camel case.
|
|
453
538
|
*
|
|
@@ -455,6 +540,7 @@ declare function splitStrAt(str: string, i: number): [string, string];
|
|
|
455
540
|
* @returns The camel case string.
|
|
456
541
|
*/
|
|
457
542
|
declare function toCamel(str: string): string;
|
|
543
|
+
|
|
458
544
|
/**
|
|
459
545
|
* Converts a camel case string to kebab case.
|
|
460
546
|
*
|
|
@@ -462,13 +548,7 @@ declare function toCamel(str: string): string;
|
|
|
462
548
|
* @returns The kebab case string.
|
|
463
549
|
*/
|
|
464
550
|
declare function toKebab(str: string): string;
|
|
465
|
-
|
|
466
|
-
* Converts a string which contains a number into the number itself.
|
|
467
|
-
*
|
|
468
|
-
* @param str - The string.
|
|
469
|
-
* @returns The number.
|
|
470
|
-
*/
|
|
471
|
-
declare function toNumber(str: string): number;
|
|
551
|
+
|
|
472
552
|
/**
|
|
473
553
|
* Adds the respective ordinal suffix (-st, -nd, -rd or -th) to a number.
|
|
474
554
|
*
|
|
@@ -476,6 +556,16 @@ declare function toNumber(str: string): number;
|
|
|
476
556
|
* @returns The number with the ordinal suffix appended.
|
|
477
557
|
*/
|
|
478
558
|
declare function toOrdinal(n: number): string;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Converts a given number to Roman numerals.
|
|
562
|
+
*
|
|
563
|
+
* @param n - The number to convert to Roman numerals.
|
|
564
|
+
* @param lowerCase - If the numerals should be in lowercase.
|
|
565
|
+
* @returns The Roman numeral representation of the given number.
|
|
566
|
+
*/
|
|
567
|
+
declare function toRomanNumerals(n: number, lowerCase?: boolean): string;
|
|
568
|
+
|
|
479
569
|
/**
|
|
480
570
|
* Truncates a string to a provided length.
|
|
481
571
|
*
|
|
@@ -486,4 +576,12 @@ declare function toOrdinal(n: number): string;
|
|
|
486
576
|
*/
|
|
487
577
|
declare function truncate(str: string, length: number, suffix?: string): string;
|
|
488
578
|
|
|
489
|
-
|
|
579
|
+
/**
|
|
580
|
+
* Joins an array of characters into a string.
|
|
581
|
+
*
|
|
582
|
+
* @param chars - The characters.
|
|
583
|
+
* @returns The string.
|
|
584
|
+
*/
|
|
585
|
+
declare function unchars(chars: string[]): string;
|
|
586
|
+
|
|
587
|
+
export { type Arrayable, type Fn, type Nullable, type Obj, type VoidFn, average, capitalise, capitalize, ceil, chars, clamp, clone, copyToClipboard, debounce, drop, es, floor, groups, head, init, isArray, isBlank, isBoolean, isBrowser, isDefined, isEmpty, isEmptyArray, isEmptyObject, isEven, isFunction, isNull, isNumber, isObject, isObjectLike, isOdd, isString, isTouchDevice, isUndefined, isWindow, ks, last, max, memoise, memoize, min, noop, once, partition, product, randomChance, randomNumber, range, replaceChar, round, scroll, shuffle, sleep, splitArray, splitString, sum, tail, take, throttle, toArray, toCamel, toDp, toKebab, toNumber, toOrdinal, toRomanNumerals, truncate, unchars, uniq, uuid, vs };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
type Arrayable<T> = T | Array<T>;
|
|
2
|
-
type Nullable<T> = T | null | undefined;
|
|
3
|
-
type Fn<T = any> = (...args: any[]) => T;
|
|
4
|
-
type VoidFn = Fn<void>;
|
|
5
|
-
type Obj<V = unknown> = Record<string | symbol | number, V>;
|
|
6
|
-
|
|
7
1
|
/**
|
|
8
2
|
* Removes the first `n` items of an array.
|
|
9
3
|
*
|
|
@@ -12,14 +6,16 @@ type Obj<V = unknown> = Record<string | symbol | number, V>;
|
|
|
12
6
|
* @returns The remaining items.
|
|
13
7
|
*/
|
|
14
8
|
declare function drop<T>(n: number, array: readonly T[]): T[];
|
|
9
|
+
|
|
15
10
|
/**
|
|
16
11
|
* Splits an array into groups of equal size.
|
|
17
12
|
*
|
|
18
|
-
* @param s - The size of each group.
|
|
19
13
|
* @param array - The array.
|
|
14
|
+
* @param n - The size of each group.
|
|
20
15
|
* @returns The array split into groups.
|
|
21
16
|
*/
|
|
22
|
-
declare function
|
|
17
|
+
declare function groups<T>(array: readonly T[], n: number): T[][];
|
|
18
|
+
|
|
23
19
|
/**
|
|
24
20
|
* Returns the first item of an array.
|
|
25
21
|
*
|
|
@@ -28,6 +24,7 @@ declare function groupsOf<T>(s: number, array: readonly T[]): T[][];
|
|
|
28
24
|
*/
|
|
29
25
|
declare function head(array: readonly []): undefined;
|
|
30
26
|
declare function head<T>(array: readonly T[]): T;
|
|
27
|
+
|
|
31
28
|
/**
|
|
32
29
|
* Returns all but the last item of an array.
|
|
33
30
|
*
|
|
@@ -35,6 +32,7 @@ declare function head<T>(array: readonly T[]): T;
|
|
|
35
32
|
* @returns The array without the last item.
|
|
36
33
|
*/
|
|
37
34
|
declare function init<T>(array: readonly T[]): T[];
|
|
35
|
+
|
|
38
36
|
/**
|
|
39
37
|
* Returns the last item of an array.
|
|
40
38
|
*
|
|
@@ -43,6 +41,7 @@ declare function init<T>(array: readonly T[]): T[];
|
|
|
43
41
|
*/
|
|
44
42
|
declare function last(array: readonly []): undefined;
|
|
45
43
|
declare function last<T>(array: readonly T[]): T;
|
|
44
|
+
|
|
46
45
|
/**
|
|
47
46
|
* Splits an array into two based on a predicate function.
|
|
48
47
|
*
|
|
@@ -51,6 +50,7 @@ declare function last<T>(array: readonly T[]): T;
|
|
|
51
50
|
* @returns The tuple of values that satisfy the predicate and those that don't.
|
|
52
51
|
*/
|
|
53
52
|
declare function partition<T, U = T>(array: readonly (T | U)[], filter: (current: T | U, idx: number, array: readonly (T | U)[]) => boolean): [T[], U[]];
|
|
53
|
+
|
|
54
54
|
/**
|
|
55
55
|
* Generates a range of numbers.
|
|
56
56
|
*
|
|
@@ -61,6 +61,7 @@ declare function partition<T, U = T>(array: readonly (T | U)[], filter: (current
|
|
|
61
61
|
*/
|
|
62
62
|
declare function range(stop: number): number[];
|
|
63
63
|
declare function range(start: number, stop: number, step?: number): number[];
|
|
64
|
+
|
|
64
65
|
/**
|
|
65
66
|
* Randomly shuffles items in an array.
|
|
66
67
|
*
|
|
@@ -68,14 +69,16 @@ declare function range(start: number, stop: number, step?: number): number[];
|
|
|
68
69
|
* @returns A copy of the array with its items randomly shuffled.
|
|
69
70
|
*/
|
|
70
71
|
declare function shuffle<T>(array: T[]): T[];
|
|
72
|
+
|
|
71
73
|
/**
|
|
72
74
|
* Splits an array into two at a specified index.
|
|
73
75
|
*
|
|
74
|
-
* @param i - The position to split at.
|
|
75
76
|
* @param array - The array.
|
|
77
|
+
* @param i - The position to split at.
|
|
76
78
|
* @returns The tuple of values before and after the split.
|
|
77
79
|
*/
|
|
78
|
-
declare function
|
|
80
|
+
declare function splitArray<T>(array: readonly T[], i: number): [T[], T[]];
|
|
81
|
+
|
|
79
82
|
/**
|
|
80
83
|
* Returns all but the first item of an array.
|
|
81
84
|
*
|
|
@@ -83,6 +86,7 @@ declare function splitAt<T>(i: number, array: readonly T[]): [T[], T[]];
|
|
|
83
86
|
* @returns The array without the first item.
|
|
84
87
|
*/
|
|
85
88
|
declare function tail<T>(array: readonly T[]): T[];
|
|
89
|
+
|
|
86
90
|
/**
|
|
87
91
|
* Returns the first `n` items of an array.
|
|
88
92
|
*
|
|
@@ -91,6 +95,13 @@ declare function tail<T>(array: readonly T[]): T[];
|
|
|
91
95
|
* @returns The first `n` items.
|
|
92
96
|
*/
|
|
93
97
|
declare function take<T>(n: number, array: readonly T[]): T[];
|
|
98
|
+
|
|
99
|
+
type Arrayable<T> = T | Array<T>;
|
|
100
|
+
type Nullable<T> = T | null | undefined;
|
|
101
|
+
type Fn<T = any> = (...args: any[]) => T;
|
|
102
|
+
type VoidFn = Fn<void>;
|
|
103
|
+
type Obj<V = unknown> = Record<string | symbol | number, V>;
|
|
104
|
+
|
|
94
105
|
/**
|
|
95
106
|
* Wraps a single value in an array, if not already an array.
|
|
96
107
|
*
|
|
@@ -98,6 +109,7 @@ declare function take<T>(n: number, array: readonly T[]): T[];
|
|
|
98
109
|
* @returns The item wrapped in an array, or the provided array.
|
|
99
110
|
*/
|
|
100
111
|
declare function toArray<T>(maybeArray: Nullable<Arrayable<T>>): T[];
|
|
112
|
+
|
|
101
113
|
/**
|
|
102
114
|
* Removes duplicate primitive values from an array.
|
|
103
115
|
*
|
|
@@ -112,6 +124,7 @@ declare function uniq<T>(array: readonly T[]): T[];
|
|
|
112
124
|
* @param str - The string to be copied to the clipboard.
|
|
113
125
|
*/
|
|
114
126
|
declare function copyToClipboard(str: string): void;
|
|
127
|
+
|
|
115
128
|
interface ScrollConfig {
|
|
116
129
|
to: Element | string | number;
|
|
117
130
|
offset?: number;
|
|
@@ -136,21 +149,25 @@ declare function scroll({ to, offset, duration, container }: ScrollConfig): void
|
|
|
136
149
|
* @param delay - The time period (in ms).
|
|
137
150
|
* @returns The debounced function.
|
|
138
151
|
*/
|
|
139
|
-
declare function debounce(fn:
|
|
152
|
+
declare function debounce(fn: Fn<void>, delay: number): Fn<void>;
|
|
153
|
+
|
|
140
154
|
/**
|
|
141
155
|
* Optimises subsequent calls of a function by caching return values.
|
|
142
156
|
*
|
|
143
157
|
* @param fn - The function.
|
|
144
|
-
* @returns The
|
|
158
|
+
* @returns The memoised function.
|
|
145
159
|
*/
|
|
146
|
-
declare function
|
|
160
|
+
declare function memoise<T>(fn: Fn<T>): Fn<T>;
|
|
161
|
+
declare const memoize: typeof memoise;
|
|
162
|
+
|
|
147
163
|
/**
|
|
148
164
|
* Enforces that a function is only callable one time.
|
|
149
165
|
*
|
|
150
166
|
* @param fn - The function.
|
|
151
167
|
* @returns The one-time callable function.
|
|
152
168
|
*/
|
|
153
|
-
declare function once(fn:
|
|
169
|
+
declare function once(fn: Fn<void>): Fn<void>;
|
|
170
|
+
|
|
154
171
|
/**
|
|
155
172
|
* Prevents function execution for a specified time period after it was last called.
|
|
156
173
|
*
|
|
@@ -158,7 +175,7 @@ declare function once(fn: VoidFn): VoidFn;
|
|
|
158
175
|
* @param limit - The time period.
|
|
159
176
|
* @returns The throttled function.
|
|
160
177
|
*/
|
|
161
|
-
declare function throttle(fn:
|
|
178
|
+
declare function throttle(fn: Fn<void>, limit: number): Fn<void>;
|
|
162
179
|
|
|
163
180
|
/**
|
|
164
181
|
* Identifies if a value is an array.
|
|
@@ -167,6 +184,7 @@ declare function throttle(fn: VoidFn, limit: number): VoidFn;
|
|
|
167
184
|
* @returns If the value is an array.
|
|
168
185
|
*/
|
|
169
186
|
declare function isArray(val: unknown): val is any[];
|
|
187
|
+
|
|
170
188
|
/**
|
|
171
189
|
* Identifies if a value is a boolean.
|
|
172
190
|
*
|
|
@@ -174,12 +192,14 @@ declare function isArray(val: unknown): val is any[];
|
|
|
174
192
|
* @returns If the value is a boolean.
|
|
175
193
|
*/
|
|
176
194
|
declare function isBoolean(val: unknown): val is boolean;
|
|
195
|
+
|
|
177
196
|
/**
|
|
178
197
|
* Identifies if the code is being run in a browser.
|
|
179
198
|
*
|
|
180
199
|
* @returns If the code is being run in a browser.
|
|
181
200
|
*/
|
|
182
201
|
declare function isBrowser(): boolean;
|
|
202
|
+
|
|
183
203
|
/**
|
|
184
204
|
* Identifies if a value is defined.
|
|
185
205
|
*
|
|
@@ -187,6 +207,7 @@ declare function isBrowser(): boolean;
|
|
|
187
207
|
* @returns If the value is defined.
|
|
188
208
|
*/
|
|
189
209
|
declare function isDefined<T>(val: T): val is Exclude<T, null | undefined>;
|
|
210
|
+
|
|
190
211
|
/**
|
|
191
212
|
* Identifies if a value is an empty array.
|
|
192
213
|
*
|
|
@@ -194,13 +215,15 @@ declare function isDefined<T>(val: T): val is Exclude<T, null | undefined>;
|
|
|
194
215
|
* @returns If the value is an empty array.
|
|
195
216
|
*/
|
|
196
217
|
declare function isEmptyArray(val: unknown): val is [];
|
|
218
|
+
|
|
197
219
|
/**
|
|
198
220
|
* Identifies if a value is an empty object.
|
|
199
221
|
*
|
|
200
222
|
* @param val - The value.
|
|
201
223
|
* @returns If the value is an empty object.
|
|
202
224
|
*/
|
|
203
|
-
declare function isEmptyObject(val: unknown): val is
|
|
225
|
+
declare function isEmptyObject(val: unknown): val is Obj<never>;
|
|
226
|
+
|
|
204
227
|
/**
|
|
205
228
|
* Identifies if a value is a function.
|
|
206
229
|
*
|
|
@@ -208,6 +231,7 @@ declare function isEmptyObject(val: unknown): val is Record<string, never>;
|
|
|
208
231
|
* @returns If the value is a function.
|
|
209
232
|
*/
|
|
210
233
|
declare function isFunction<T extends Fn>(val: unknown): val is T;
|
|
234
|
+
|
|
211
235
|
/**
|
|
212
236
|
* Identifies if a value is null.
|
|
213
237
|
*
|
|
@@ -215,6 +239,7 @@ declare function isFunction<T extends Fn>(val: unknown): val is T;
|
|
|
215
239
|
* @returns If the value is null.
|
|
216
240
|
*/
|
|
217
241
|
declare function isNull(val: unknown): val is null;
|
|
242
|
+
|
|
218
243
|
/**
|
|
219
244
|
* Identifies if a value is a number.
|
|
220
245
|
*
|
|
@@ -222,6 +247,7 @@ declare function isNull(val: unknown): val is null;
|
|
|
222
247
|
* @returns If the value is a number.
|
|
223
248
|
*/
|
|
224
249
|
declare function isNumber(val: unknown): val is number;
|
|
250
|
+
|
|
225
251
|
/**
|
|
226
252
|
* Identifies if a value is an object.
|
|
227
253
|
*
|
|
@@ -229,6 +255,7 @@ declare function isNumber(val: unknown): val is number;
|
|
|
229
255
|
* @returns If the value is an object.
|
|
230
256
|
*/
|
|
231
257
|
declare function isObject(val: unknown): val is Obj;
|
|
258
|
+
|
|
232
259
|
/**
|
|
233
260
|
* Identifies if a value is an array, an object, a date, or null.
|
|
234
261
|
*
|
|
@@ -236,6 +263,7 @@ declare function isObject(val: unknown): val is Obj;
|
|
|
236
263
|
* @returns If the value is an array, an object, a date, or null.
|
|
237
264
|
*/
|
|
238
265
|
declare function isObjectLike(val: unknown): val is object;
|
|
266
|
+
|
|
239
267
|
/**
|
|
240
268
|
* Identifies if a value is a string.
|
|
241
269
|
*
|
|
@@ -243,12 +271,14 @@ declare function isObjectLike(val: unknown): val is object;
|
|
|
243
271
|
* @returns If the value is a string.
|
|
244
272
|
*/
|
|
245
273
|
declare function isString(val: unknown): val is string;
|
|
274
|
+
|
|
246
275
|
/**
|
|
247
276
|
* Identifies if the code is being run on a touch device.
|
|
248
277
|
*
|
|
249
278
|
* @returns If the code is being run on a touch device.
|
|
250
279
|
*/
|
|
251
280
|
declare function isTouchDevice(): boolean;
|
|
281
|
+
|
|
252
282
|
/**
|
|
253
283
|
* Identifies if a value is undefined.
|
|
254
284
|
*
|
|
@@ -256,6 +286,7 @@ declare function isTouchDevice(): boolean;
|
|
|
256
286
|
* @returns If the value is undefined.
|
|
257
287
|
*/
|
|
258
288
|
declare function isUndefined(val: unknown): val is undefined;
|
|
289
|
+
|
|
259
290
|
/**
|
|
260
291
|
* Identifies if a value is the global window.
|
|
261
292
|
*
|
|
@@ -264,6 +295,37 @@ declare function isUndefined(val: unknown): val is undefined;
|
|
|
264
295
|
*/
|
|
265
296
|
declare function isWindow(val: unknown): val is Window;
|
|
266
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Does nothing.
|
|
300
|
+
*
|
|
301
|
+
* @returns Nothing.
|
|
302
|
+
*/
|
|
303
|
+
declare function noop(): void;
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Halts thread execution for a specified time period.
|
|
307
|
+
*
|
|
308
|
+
* @param duration - The time period (in ms).
|
|
309
|
+
* @returns The halting promise.
|
|
310
|
+
*/
|
|
311
|
+
declare function sleep(duration: number): Promise<void>;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Generates a random string of a specified length.
|
|
315
|
+
*
|
|
316
|
+
* @param length - The length of the randomly generated string.
|
|
317
|
+
* @returns The randomly generated string.
|
|
318
|
+
*/
|
|
319
|
+
declare function uuid(length?: number): string;
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Returns the average of a number array.
|
|
323
|
+
*
|
|
324
|
+
* @param ns - The number array.
|
|
325
|
+
* @returns The average.
|
|
326
|
+
*/
|
|
327
|
+
declare function average(ns: readonly number[]): number;
|
|
328
|
+
|
|
267
329
|
/**
|
|
268
330
|
* Rounds a number up to the nearest multiple of the specified factor.
|
|
269
331
|
*
|
|
@@ -272,6 +334,7 @@ declare function isWindow(val: unknown): val is Window;
|
|
|
272
334
|
* @returns The rounded number.
|
|
273
335
|
*/
|
|
274
336
|
declare function ceil(n: number, factor?: number): number;
|
|
337
|
+
|
|
275
338
|
/**
|
|
276
339
|
* Restricts a number between two bounds.
|
|
277
340
|
*
|
|
@@ -281,6 +344,7 @@ declare function ceil(n: number, factor?: number): number;
|
|
|
281
344
|
* @returns The number restricted between the specified bounds.
|
|
282
345
|
*/
|
|
283
346
|
declare function clamp(n: number, min: number, max: number): number;
|
|
347
|
+
|
|
284
348
|
/**
|
|
285
349
|
* Rounds a number down to the nearest multiple of the specified factor.
|
|
286
350
|
*
|
|
@@ -289,6 +353,7 @@ declare function clamp(n: number, min: number, max: number): number;
|
|
|
289
353
|
* @returns The rounded number.
|
|
290
354
|
*/
|
|
291
355
|
declare function floor(n: number, factor?: number): number;
|
|
356
|
+
|
|
292
357
|
/**
|
|
293
358
|
* Identifies if a number is even.
|
|
294
359
|
*
|
|
@@ -296,6 +361,7 @@ declare function floor(n: number, factor?: number): number;
|
|
|
296
361
|
* @returns If the number is even.
|
|
297
362
|
*/
|
|
298
363
|
declare function isEven(n: number): boolean;
|
|
364
|
+
|
|
299
365
|
/**
|
|
300
366
|
* Identifies if a number is odd.
|
|
301
367
|
*
|
|
@@ -303,6 +369,7 @@ declare function isEven(n: number): boolean;
|
|
|
303
369
|
* @returns If the number is odd.
|
|
304
370
|
*/
|
|
305
371
|
declare function isOdd(n: number): boolean;
|
|
372
|
+
|
|
306
373
|
/**
|
|
307
374
|
* Returns the maximum number of provided numbers or array of numbers.
|
|
308
375
|
*
|
|
@@ -310,6 +377,7 @@ declare function isOdd(n: number): boolean;
|
|
|
310
377
|
* @returns The maximum number.
|
|
311
378
|
*/
|
|
312
379
|
declare function max(...ns: number[] | [number[]]): number;
|
|
380
|
+
|
|
313
381
|
/**
|
|
314
382
|
* Returns the minimum number of provided numbers or array of numbers.
|
|
315
383
|
*
|
|
@@ -317,6 +385,7 @@ declare function max(...ns: number[] | [number[]]): number;
|
|
|
317
385
|
* @returns The minimum number.
|
|
318
386
|
*/
|
|
319
387
|
declare function min(...ns: number[] | [number[]]): number;
|
|
388
|
+
|
|
320
389
|
/**
|
|
321
390
|
* Returns the product of a number array.
|
|
322
391
|
*
|
|
@@ -324,6 +393,7 @@ declare function min(...ns: number[] | [number[]]): number;
|
|
|
324
393
|
* @returns The product.
|
|
325
394
|
*/
|
|
326
395
|
declare function product(ns: readonly number[]): number;
|
|
396
|
+
|
|
327
397
|
/**
|
|
328
398
|
* Rolls an n-sided die.
|
|
329
399
|
*
|
|
@@ -331,6 +401,7 @@ declare function product(ns: readonly number[]): number;
|
|
|
331
401
|
* @returns If the die roll was 0.
|
|
332
402
|
*/
|
|
333
403
|
declare function randomChance(n: number): boolean;
|
|
404
|
+
|
|
334
405
|
/**
|
|
335
406
|
* Generates a random integer between bounds.
|
|
336
407
|
*
|
|
@@ -340,6 +411,7 @@ declare function randomChance(n: number): boolean;
|
|
|
340
411
|
*/
|
|
341
412
|
declare function randomNumber(max: number): number;
|
|
342
413
|
declare function randomNumber(min: number, max: number): number;
|
|
414
|
+
|
|
343
415
|
/**
|
|
344
416
|
* Rounds a number to the nearest multiple of the specified factor.
|
|
345
417
|
*
|
|
@@ -348,6 +420,7 @@ declare function randomNumber(min: number, max: number): number;
|
|
|
348
420
|
* @returns The rounded number.
|
|
349
421
|
*/
|
|
350
422
|
declare function round(n: number, factor?: number): number;
|
|
423
|
+
|
|
351
424
|
/**
|
|
352
425
|
* Returns the sum of a number array.
|
|
353
426
|
*
|
|
@@ -355,14 +428,24 @@ declare function round(n: number, factor?: number): number;
|
|
|
355
428
|
* @returns The sum.
|
|
356
429
|
*/
|
|
357
430
|
declare function sum(ns: readonly number[]): number;
|
|
431
|
+
|
|
358
432
|
/**
|
|
359
|
-
*
|
|
433
|
+
* Rounds a number to a specified number of decimal places.
|
|
360
434
|
*
|
|
361
|
-
* @param n - The number to
|
|
362
|
-
* @param
|
|
363
|
-
* @returns
|
|
435
|
+
* @param n - The number to round.
|
|
436
|
+
* @param decimalPlaces - The number of decimal places to round to.
|
|
437
|
+
* @returns The rounded number.
|
|
364
438
|
*/
|
|
365
|
-
declare function
|
|
439
|
+
declare function toDp(n: number, decimalPlaces?: number): number;
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Converts a string which contains a number into the number itself.
|
|
443
|
+
*
|
|
444
|
+
* @param str - The string.
|
|
445
|
+
* @param extensions - Additional symbols to consider in the conversion.
|
|
446
|
+
* @returns The number.
|
|
447
|
+
*/
|
|
448
|
+
declare function toNumber(str: string, extensions?: string[]): number;
|
|
366
449
|
|
|
367
450
|
/**
|
|
368
451
|
* Deep clones an array or object.
|
|
@@ -371,35 +454,30 @@ declare function toRomanNumerals(n: number, lowerCase?: boolean): string;
|
|
|
371
454
|
* @returns A deep clone of the input array or object.
|
|
372
455
|
*/
|
|
373
456
|
declare function clone<T>(input: T): T;
|
|
457
|
+
|
|
374
458
|
/**
|
|
375
|
-
*
|
|
376
|
-
*
|
|
377
|
-
* @returns Nothing.
|
|
378
|
-
*/
|
|
379
|
-
declare function noop(): void;
|
|
380
|
-
/**
|
|
381
|
-
* Halts thread execution for a specified time period.
|
|
459
|
+
* Strict-typed, shorthand `Object.entries`
|
|
382
460
|
*
|
|
383
|
-
* @param
|
|
384
|
-
* @returns The
|
|
461
|
+
* @param obj - The object to extract the entries from.
|
|
462
|
+
* @returns The entries.
|
|
385
463
|
*/
|
|
386
|
-
declare function
|
|
464
|
+
declare function es<T extends object>(obj: T): [keyof T, T[keyof T]][];
|
|
465
|
+
|
|
387
466
|
/**
|
|
388
|
-
*
|
|
467
|
+
* Strict-typed, shorthand `Object.keys`
|
|
389
468
|
*
|
|
390
|
-
* @param
|
|
391
|
-
* @returns The
|
|
469
|
+
* @param obj - The object to extract the keys from.
|
|
470
|
+
* @returns The keys.
|
|
392
471
|
*/
|
|
393
|
-
declare function
|
|
472
|
+
declare function ks<T extends object>(obj: T): Array<`${keyof T & (string | number | boolean | null | undefined)}`>;
|
|
394
473
|
|
|
395
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
396
474
|
/**
|
|
397
|
-
*
|
|
475
|
+
* Shorthand `Object.values`
|
|
398
476
|
*
|
|
399
|
-
* @param
|
|
400
|
-
* @returns The
|
|
477
|
+
* @param obj - The object to extract the values from.
|
|
478
|
+
* @returns The values.
|
|
401
479
|
*/
|
|
402
|
-
declare function
|
|
480
|
+
declare function vs<T>(obj: Obj<T>): T[];
|
|
403
481
|
|
|
404
482
|
/**
|
|
405
483
|
* Capitalises the first letter of one word, or all words, in a string.
|
|
@@ -410,6 +488,8 @@ declare function deepMerge<T extends Obj<any>[]>(...objects: T): UnionToIntersec
|
|
|
410
488
|
* @returns The capitalised string.
|
|
411
489
|
*/
|
|
412
490
|
declare function capitalise(str: string, allWords?: boolean, delimiter?: string): string;
|
|
491
|
+
declare const capitalize: typeof capitalise;
|
|
492
|
+
|
|
413
493
|
/**
|
|
414
494
|
* Separates a string into an array of characters.
|
|
415
495
|
*
|
|
@@ -417,6 +497,7 @@ declare function capitalise(str: string, allWords?: boolean, delimiter?: string)
|
|
|
417
497
|
* @returns The string's characters.
|
|
418
498
|
*/
|
|
419
499
|
declare function chars(str: string): string[];
|
|
500
|
+
|
|
420
501
|
/**
|
|
421
502
|
* Identifies strings which only contain whitespace.
|
|
422
503
|
*
|
|
@@ -424,6 +505,7 @@ declare function chars(str: string): string[];
|
|
|
424
505
|
* @returns If the string is blank.
|
|
425
506
|
*/
|
|
426
507
|
declare function isBlank(str: string): boolean;
|
|
508
|
+
|
|
427
509
|
/**
|
|
428
510
|
* Identifies empty strings.
|
|
429
511
|
*
|
|
@@ -431,15 +513,17 @@ declare function isBlank(str: string): boolean;
|
|
|
431
513
|
* @returns If the string is empty.
|
|
432
514
|
*/
|
|
433
515
|
declare function isEmpty(str: string): boolean;
|
|
516
|
+
|
|
434
517
|
/**
|
|
435
518
|
* Replaces a character at a specified index in a string with a new character.
|
|
436
519
|
*
|
|
437
520
|
* @param str - The string.
|
|
438
521
|
* @param i - The index of the character to replace.
|
|
439
522
|
* @param char - The character to replace with.
|
|
440
|
-
* @returns
|
|
523
|
+
* @returns The modified string with the character replaced.
|
|
441
524
|
*/
|
|
442
525
|
declare function replaceChar(str: string, i: number, char: string): string;
|
|
526
|
+
|
|
443
527
|
/**
|
|
444
528
|
* Splits a string into two at a specified index.
|
|
445
529
|
*
|
|
@@ -447,7 +531,8 @@ declare function replaceChar(str: string, i: number, char: string): string;
|
|
|
447
531
|
* @param i - The position to split at.
|
|
448
532
|
* @returns The tuple of strings before and after the split.
|
|
449
533
|
*/
|
|
450
|
-
declare function
|
|
534
|
+
declare function splitString(str: string, i: number): [string, string];
|
|
535
|
+
|
|
451
536
|
/**
|
|
452
537
|
* Converts a kebab case string to camel case.
|
|
453
538
|
*
|
|
@@ -455,6 +540,7 @@ declare function splitStrAt(str: string, i: number): [string, string];
|
|
|
455
540
|
* @returns The camel case string.
|
|
456
541
|
*/
|
|
457
542
|
declare function toCamel(str: string): string;
|
|
543
|
+
|
|
458
544
|
/**
|
|
459
545
|
* Converts a camel case string to kebab case.
|
|
460
546
|
*
|
|
@@ -462,13 +548,7 @@ declare function toCamel(str: string): string;
|
|
|
462
548
|
* @returns The kebab case string.
|
|
463
549
|
*/
|
|
464
550
|
declare function toKebab(str: string): string;
|
|
465
|
-
|
|
466
|
-
* Converts a string which contains a number into the number itself.
|
|
467
|
-
*
|
|
468
|
-
* @param str - The string.
|
|
469
|
-
* @returns The number.
|
|
470
|
-
*/
|
|
471
|
-
declare function toNumber(str: string): number;
|
|
551
|
+
|
|
472
552
|
/**
|
|
473
553
|
* Adds the respective ordinal suffix (-st, -nd, -rd or -th) to a number.
|
|
474
554
|
*
|
|
@@ -476,6 +556,16 @@ declare function toNumber(str: string): number;
|
|
|
476
556
|
* @returns The number with the ordinal suffix appended.
|
|
477
557
|
*/
|
|
478
558
|
declare function toOrdinal(n: number): string;
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Converts a given number to Roman numerals.
|
|
562
|
+
*
|
|
563
|
+
* @param n - The number to convert to Roman numerals.
|
|
564
|
+
* @param lowerCase - If the numerals should be in lowercase.
|
|
565
|
+
* @returns The Roman numeral representation of the given number.
|
|
566
|
+
*/
|
|
567
|
+
declare function toRomanNumerals(n: number, lowerCase?: boolean): string;
|
|
568
|
+
|
|
479
569
|
/**
|
|
480
570
|
* Truncates a string to a provided length.
|
|
481
571
|
*
|
|
@@ -486,4 +576,12 @@ declare function toOrdinal(n: number): string;
|
|
|
486
576
|
*/
|
|
487
577
|
declare function truncate(str: string, length: number, suffix?: string): string;
|
|
488
578
|
|
|
489
|
-
|
|
579
|
+
/**
|
|
580
|
+
* Joins an array of characters into a string.
|
|
581
|
+
*
|
|
582
|
+
* @param chars - The characters.
|
|
583
|
+
* @returns The string.
|
|
584
|
+
*/
|
|
585
|
+
declare function unchars(chars: string[]): string;
|
|
586
|
+
|
|
587
|
+
export { type Arrayable, type Fn, type Nullable, type Obj, type VoidFn, average, capitalise, capitalize, ceil, chars, clamp, clone, copyToClipboard, debounce, drop, es, floor, groups, head, init, isArray, isBlank, isBoolean, isBrowser, isDefined, isEmpty, isEmptyArray, isEmptyObject, isEven, isFunction, isNull, isNumber, isObject, isObjectLike, isOdd, isString, isTouchDevice, isUndefined, isWindow, ks, last, max, memoise, memoize, min, noop, once, partition, product, randomChance, randomNumber, range, replaceChar, round, scroll, shuffle, sleep, splitArray, splitString, sum, tail, take, throttle, toArray, toCamel, toDp, toKebab, toNumber, toOrdinal, toRomanNumerals, truncate, unchars, uniq, uuid, vs };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function S(e,r){return e<=0?[...r]:r.slice(e)}function L(e,r){if(r<=0)throw new Error("[tsu] Invalid group size. Is it greater than 0?");if(r>=e.length)return[[...e]];let t=[];for(let n=0;n<e.length;n+=r)t.push(e.slice(n,n+r));return t}function R(e){return e[0]}function B(e){return e.slice(0,e.length-1)}function $(e){return e[e.length-1]}function W(e,r){let t=[],n=[];for(let o=0;o<e.length;o++){let i=e[o];r(i,o,e)?t.push(i):n.push(i)}return[t,n]}function z(...e){let r,t,n;e.length===1?(t=e[0],r=0,n=1):(r=e[0],t=e[1],n=e[2]||1),n<=0&&(console.warn("[tsu] warning: a step less than or equal to 0 will be set to 1."),n=1);let o=[],i=r;for(;i<t;)o.push(i),i+=n||1;return o}function V(e){return e.length<1?0:y(e)/e.length}function K(e,r=1){let t=e/r;return Math.ceil(t)*r}function h(e,r,t){return Math.min(t,Math.max(r,e))}function G(e,r=1){let t=e/r;return Math.floor(t)*r}function ee(e){return e%2===0}function te(e){return e%2!==0}function oe(...e){let r;return e.length===1&&Array.isArray(e[0])?r=e[0]:r=e,Math.max(...r)}function ue(...e){let r;return e.length===1&&Array.isArray(e[0])?r=e[0]:r=e,Math.min(...r)}function me(e){if(e.length<1)return 0;let r=1;for(let t=0;t<e.length;t++)r*=e[t];return r}function u(...e){let r,t;return e.length===1?(r=0,t=e[0]):(r=e[0],t=e[1]),Math.floor(Math.random()*(t-r))+r}function ce(e){return u(e)===0}function xe(e,r=1){let t=e/r;return Math.round(t)*r}function y(e){let r=0;for(let t=0;t<e.length;t++)r+=e[t];return r}function ge(e,r=0){r<0&&console.warn("[tsu] warning: decimalPlaces less than 0 are set to 0."),r>100&&console.warn("[tsu] warning: decimalPlaces greater than 100 are set to 100.");let t=h(r,0,100);return Number(e.toFixed(t))}function he(e,r=[]){if(!e.length)return NaN;let t=["#","\xA3","\u20AC","$","%",",",...r],n=new RegExp(`[${t.join("")}]`,"g");return Number(e.replace(n,""))}function m(e){return Array.isArray(e)}function Ie(e){return typeof e=="boolean"}function s(){return typeof window<"u"}function We(e){return typeof e<"u"}function He(e){return m(e)&&e.length===0}function Je(e){if(!w(e))return!1;for(let r in e)return!1;return!0}function Ye(e){return typeof e=="function"}function l(e){return Object.prototype.toString.call(e)==="[object Null]"}function j(e){return typeof e=="number"}function w(e){return Object.prototype.toString.call(e)==="[object Object]"}function p(e){return typeof e=="object"}function a(e){return typeof e=="string"}function nr(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function ir(e){return typeof e>"u"}function mr(e){return s()&&Object.prototype.toString.call(e)==="[object Window]"}function c(e){if(m(e)){let r=[];for(let t=0;t<e.length;t++)p(e[t])&&!l(e[t])?r[t]=c(e[t]):r[t]=e[t];return r}if(p(e)&&!l(e)){let r={};for(let t in e)p(e[t])&&!l(e[t])?r[t]=c(e[t]):r[t]=e[t];return r}return e}function Cr(e){return Object.entries(e)}function Mr(e){return Object.keys(e)}function Sr(e){return Object.values(e)}function Pr(e){let r=c(e),t,n,o;for(t=r.length;t;t-=1)n=u(t),o=r[t-1],r[t-1]=r[n],r[n]=o;return r}function Xr(e,r){return r<=0?[[],[...e]]:r>e.length?[[...e],[]]:[e.slice(0,r),e.slice(r)]}function Hr(e){return e.slice(1)}function Vr(e,r){return e<=0?[]:r.slice(0,e)}function Kr(e){return e?Array.isArray(e)?e:[e]:[]}function Zr(e){return Array.from(new Set(e))}function N(e){let r=document.createElement("textarea");r.value=e??"",r.style.position="absolute",r.style.opacity="0",document.body.appendChild(r),r.select(),document.execCommand("copy"),r.remove()}function xt(e){s()&&(window.navigator&&"clipboard"in window.navigator?navigator.clipboard.writeText(e):N(e))}function A(e){return e<.5?4*Math.pow(e,3):(e-1)*(2*e-2)*(2*e-2)+1}function C(e,r,t,n){return e+(r-e)*A(t/n)}function E(e,r){return e.nodeName==="HTML"?-r:e.getBoundingClientRect().top+r}function Tt({to:e,offset:r=0,duration:t=1e3,container:n=null}){let o=a(e)?document.querySelector(e):e,i=a(n)?document.querySelector(n):n,f=i?.scrollTop||window?.pageYOffset||0,x=(j(o)?o:E(o,f))+r,O=Date.now();function b(){let d=Date.now()-O,T=d<t,g=T?C(f,x,d,t):x;T&&requestAnimationFrame(b),i?i.scrollTop=g:window.scrollTo(0,g)}b()}function jt(e,r){r<0&&console.warn("[tsu] warning: debounce delays less than 0 will be set to 0.");let t;return function(...n){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),e(...n)},r)}}function M(e){let r={};return function(...t){let n=JSON.stringify(t);if(n in r)return r[n];let o=e(...t);return r[n]=o,o}}var kt=M;function Nt(e){let r=!1;return(...t)=>{r||(e(...t),r=!0)}}function Ct(e,r){r<0&&console.warn("[tsu] warning: throttle limits less than 0 will be set to 0.");let t=!1;return function(...n){t||(e(...n),t=!0,setTimeout(()=>{t=!1},r))}}function Dt(){}async function qt(e){return e<0&&console.warn("[tsu] warning: sleep durations less than 0 are set to 0."),new Promise(r=>{setTimeout(r,e)})}var v="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function $t(e=16){let r=v.length,t=e,n="";for(;t--;)n+=v[u(r)];return n}function F(e,r=!1,t=" "){return r?e.split(t).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join(t):e.charAt(0).toUpperCase()+e.slice(1)}var _t=F;function Jt(e){return e.split("")}function Yt(e){return e.trim().length===0}function Gt(e){return e.length===0}function en(e,r,t){return r<0||r>e.length-1?e:e.slice(0,r)+t+e.slice(r+1)}function tn(e,r){return r<=0?["",e]:r>e.length?[e,""]:[e.slice(0,r),e.slice(r)]}function on(e){let r=/-(\w)/g;return e.replace(r,(t,n)=>n?n.toUpperCase():"")}function fn(e){let r=/\B([A-Z])/g;return e.replace(r,"-$1").toLowerCase()}function sn(e){let t=["st","nd","rd"][(Math.abs(e)/10%10^1&&Math.abs(e)%10)-1]||"th";return`${e}${t}`}var k={1:"I",4:"IV",5:"V",9:"IX",10:"X",40:"XL",50:"L",90:"XC",100:"C",400:"CD",500:"D",900:"CM",1e3:"M"};function pn(e,r=!1){let t=e,n="",o=Object.keys(k).map(Number).sort((i,f)=>f-i);for(let i of o)for(;t>=i;)n+=k[i],t-=i;return r?n.toLowerCase():n}function an(e,r,t="..."){return r<=0?t:e.slice(0,r)+t}function bn(e){return e.join("")}export{V as average,F as capitalise,_t as capitalize,K as ceil,Jt as chars,h as clamp,c as clone,xt as copyToClipboard,jt as debounce,S as drop,Cr as es,G as floor,L as groups,R as head,B as init,m as isArray,Yt as isBlank,Ie as isBoolean,s as isBrowser,We as isDefined,Gt as isEmpty,He as isEmptyArray,Je as isEmptyObject,ee as isEven,Ye as isFunction,l as isNull,j as isNumber,w as isObject,p as isObjectLike,te as isOdd,a as isString,nr as isTouchDevice,ir as isUndefined,mr as isWindow,Mr as ks,$ as last,oe as max,M as memoise,kt as memoize,ue as min,Dt as noop,Nt as once,W as partition,me as product,ce as randomChance,u as randomNumber,z as range,en as replaceChar,xe as round,Tt as scroll,Pr as shuffle,qt as sleep,Xr as splitArray,tn as splitString,y as sum,Hr as tail,Vr as take,Ct as throttle,Kr as toArray,on as toCamel,ge as toDp,fn as toKebab,he as toNumber,sn as toOrdinal,pn as toRomanNumerals,an as truncate,bn as unchars,Zr as uniq,$t as uuid,Sr as vs};
|