tsu 2.6.1 → 2.8.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/dist/index.cjs +1 -1
- package/dist/index.d.cts +23 -18
- package/dist/index.d.ts +23 -18
- package/dist/index.js +1 -1
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var b=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var F=(n,e)=>{for(var t in e)b(n,t,{get:e[t],enumerable:!0})},M=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of N(e))!U.call(n,o)&&o!==t&&b(n,o,{get:()=>e[o],enumerable:!(r=A(e,o))||r.enumerable});return n};var S=n=>M(b({},"__esModule",{value:!0}),n);var Fn={};F(Fn,{capitalise:()=>yn,ceil:()=>E,chars:()=>hn,clamp:()=>C,clone:()=>m,debounce:()=>dn,deepMerge:()=>v,drop:()=>Q,floor:()=>q,groupsOf:()=>X,head:()=>nn,init:()=>en,isArray:()=>s,isBlank:()=>wn,isBoolean:()=>H,isBrowser:()=>j,isDefined:()=>_,isEmpty:()=>jn,isEmptyObject:()=>$,isEven:()=>I,isFunction:()=>z,isNull:()=>c,isNumber:()=>d,isObject:()=>f,isObjectLike:()=>a,isOdd:()=>V,isString:()=>p,isTouchDevice:()=>J,isWindow:()=>K,last:()=>tn,max:()=>L,memoize:()=>xn,min:()=>R,noop:()=>Y,once:()=>Tn,partition:()=>rn,product:()=>B,randomChance:()=>D,randomNumber:()=>l,range:()=>on,round:()=>P,scroll:()=>an,shuffle:()=>un,sleep:()=>Z,splitAt:()=>ln,splitStrAt:()=>On,sum:()=>W,tail:()=>sn,take:()=>cn,throttle:()=>gn,toArray:()=>fn,toCamel:()=>vn,toKebab:()=>kn,toNumber:()=>An,toOrdinal:()=>Nn,truncate:()=>Un,uniq:()=>x,uuid:()=>G});module.exports=S(Fn);function E(n,e=1){let t=n/e;return Math.ceil(t)*e}function C(n,e,t){return Math.min(t,Math.max(e,n))}function q(n,e=1){let t=n/e;return Math.floor(t)*e}function I(n){return n%2===0}function V(n){return n%2!==0}function L(...n){let e;return n.length===1&&Array.isArray(n[0])?e=n[0]:e=n,Math.max(...e)}function R(...n){let e;return n.length===1&&Array.isArray(n[0])?e=n[0]:e=n,Math.min(...e)}function B(n){let e=1;for(let t=0;t<n.length;t++)e*=n[t];return e}function D(n){return l(n)===0}function l(...n){let e,t;return n.length===1?(e=0,t=n[0]):(e=n[0],t=n[1]),Math.floor(Math.random()*(t-e))+e}function P(n,e=1){let t=n/e;return Math.round(t)*e}function W(n){let e=0;for(let t=0;t<n.length;t++)e+=n[t];return e}function s(n){return Array.isArray(n)}function H(n){return typeof n=="boolean"}function j(){return typeof window<"u"}function _(n){return typeof n<"u"}function $(n){if(!f(n))return!1;for(let e in n)return!1;return!0}function z(n){return typeof n=="function"}function c(n){return Object.prototype.toString.call(n)==="[object Null]"}function d(n){return typeof n=="number"}function f(n){return Object.prototype.toString.call(n)==="[object Object]"}function a(n){return typeof n=="object"}function p(n){return typeof n=="string"}function J(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function K(n){return j()&&Object.prototype.toString.call(n)==="[object Window]"}function m(n){if(s(n)){let e=[];for(let t=0;t<n.length;t++)a(n[t])&&!c(n[t])?e[t]=m(n[t]):e[t]=n[t];return e}if(a(n)&&!c(n)){let e={};for(let t in n)a(n[t])&&!c(n[t])?e[t]=m(n[t]):e[t]=n[t];return e}return n}function Y(){}async function Z(n){return n<0&&console.warn("[tsu] warning: a sleep duration less than 0ms will be treated as 0ms."),new Promise(e=>{setTimeout(e,n)})}var O="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function G(n=16){let e=O.length,t=n,r="";for(;t--;)r+=O[l(e)];return r}function Q(n,e){return n<=0?[...e]:e.slice(n)}function X(n,e){if(n<=0)throw new Error("[tsu] Invalid group size. Is it greater than 0?");if(n>=e.length)return[[...e]];let t=[];for(let r=0;r<e.length;r+=n)t.push(e.slice(r,r+n));return t}function nn(n){return n[0]}function en(n){return n.slice(0,n.length-1)}function tn(n){return n[n.length-1]}function rn(n,e){let t=[],r=[];for(let o=0;o<n.length;o++){let i=n[o];e(i,o,n)?t.push(i):r.push(i)}return[t,r]}function on(...n){let e,t,r;n.length===1?(t=n[0],e=0,r=1):(e=n[0],t=n[1],r=n[2]||1),r<=0&&(console.warn("[tsu] warning: a step less than or equal to 0 will be set to 1."),r=1);let o=[],i=e;for(;i<t;)o.push(i),i+=r||1;return o}function un(n){let e=m(n),t,r,o;for(t=e.length;t;t-=1)r=l(t),o=e[t-1],e[t-1]=e[r],e[r]=o;return e}function ln(n,e){return n<=0?[[],[...e]]:n>e.length?[[...e],[]]:[e.slice(0,n),e.slice(n)]}function sn(n){return n.slice(1)}function cn(n,e){return n<=0?[]:e.slice(0,n)}function fn(n){return n?Array.isArray(n)?n:[n]:[]}function x(n){return Array.from(new Set(n))}function an({to:n,offset:e=0,duration:t=1e3,container:r=null}){let o=p(n)?document.querySelector(n):n,i=p(r)?document.querySelector(r):r,u=i?.scrollTop||window?.pageYOffset||0,T=(d(o)?o:bn(o,u))+e,k=Date.now();function g(){let y=Date.now()-k,h=y<t,w=h?pn(u,T,y,t):T;h&&requestAnimationFrame(g),i?i.scrollTop=w:window.scrollTo(0,w)}g()}function mn(n){return n<.5?4*Math.pow(n,3):(n-1)*(2*n-2)*(2*n-2)+1}function pn(n,e,t,r){return n+(e-n)*mn(t/r)}function bn(n,e){return n.nodeName==="HTML"?-e:n.getBoundingClientRect().top+e}function dn(n,e){e<0&&console.warn("[tsu] warning: a debounce delay less than 0ms will be treated as 0ms.");let t;return function(...r){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),n(...r)},e)}}function xn(n){let e={};return function(...t){let r=JSON.stringify(t);if(r in e)return e[r];let o=n(...t);return e[r]=o,o}}function Tn(n){let e=!1;return(...t)=>{e||(n(...t),e=!0)}}function gn(n,e){e<0&&console.warn("[tsu] warning: a throttle limit less than 0ms will be treated as 0ms.");let t=!1;return function(...r){t||(n(...r),t=!0,setTimeout(()=>{t=!1},e))}}function v(...n){let e={};for(let t=0;t<n.length;t++){let r=n[t],o=Object.keys(r);for(let i=0;i<o.length;i++){let u=o[i];s(e[u])&&s(r[u])?e[u]=x(e[u].concat(r[u])):f(e[u])&&f(r[u])?e[u]=v(e[u],r[u]):e[u]=r[u]}}return e}function yn(n,e=!1,t=" "){return e?n.split(t).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(t):n.charAt(0).toUpperCase()+n.slice(1)}function hn(n){return n.split("")}function wn(n){return n.trim().length===0}function jn(n){return n.length===0}function On(n,e){return n<=0?["",e]:n>e.length?[e,""]:[e.slice(0,n),e.slice(n)]}function vn(n){let e=/-(\w)/g;return n.replace(e,(t,r)=>r?r.toUpperCase():"")}function kn(n){let e=/\B([A-Z])/g;return n.replace(e,"-$1").toLowerCase()}function An(n){return n.length?Number(n.replace(/[#£€$,%]/g,"")):NaN}function Nn(n){let t=["st","nd","rd"][(n/10%10^1&&n%10)-1]||"th";return`${n}${t}`}function Un(n,e,t="..."){return e<=0?t:n.slice(0,e)+t}0&&(module.exports={capitalise,ceil,chars,clamp,clone,debounce,deepMerge,drop,floor,groupsOf,head,init,isArray,isBlank,isBoolean,isBrowser,isDefined,isEmpty,isEmptyObject,isEven,isFunction,isNull,isNumber,isObject,isObjectLike,isOdd,isString,isTouchDevice,isWindow,last,max,memoize,min,noop,once,partition,product,randomChance,randomNumber,range,round,scroll,shuffle,sleep,splitAt,splitStrAt,sum,tail,take,throttle,toArray,toCamel,toKebab,toNumber,toOrdinal,truncate,uniq,uuid});
|
package/dist/index.d.cts
CHANGED
|
@@ -4,18 +4,11 @@ type Fn<T = any> = (...args: any[]) => T;
|
|
|
4
4
|
type VoidFn = Fn<void>;
|
|
5
5
|
type Obj<V = unknown> = Record<string | symbol | number, V>;
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Clones an array.
|
|
9
|
-
*
|
|
10
|
-
* @param array - The array.
|
|
11
|
-
* @returns A clone of the array.
|
|
12
|
-
*/
|
|
13
|
-
declare function clone<T>(array: readonly T[]): T[];
|
|
14
7
|
/**
|
|
15
8
|
* Removes the first `n` items of an array.
|
|
16
9
|
*
|
|
17
10
|
* @param n - The number of items to remove.
|
|
18
|
-
* @param array - The array.
|
|
11
|
+
* @param array - The array.z
|
|
19
12
|
* @returns The remaining items.
|
|
20
13
|
*/
|
|
21
14
|
declare function drop<T>(n: number, array: readonly T[]): T[];
|
|
@@ -74,7 +67,7 @@ declare function range(start: number, stop: number, step?: number): number[];
|
|
|
74
67
|
* @param array - The array.
|
|
75
68
|
* @returns A copy of the array with its items randomly shuffled.
|
|
76
69
|
*/
|
|
77
|
-
declare function shuffle<T>(array:
|
|
70
|
+
declare function shuffle<T>(array: T[]): T[];
|
|
78
71
|
/**
|
|
79
72
|
* Splits an array into two at a specified index.
|
|
80
73
|
*
|
|
@@ -223,6 +216,13 @@ declare function isNumber(val: unknown): val is number;
|
|
|
223
216
|
* @returns If the value is an object.
|
|
224
217
|
*/
|
|
225
218
|
declare function isObject(val: unknown): val is Obj;
|
|
219
|
+
/**
|
|
220
|
+
* Identifies if a value is an array, an object, a date, or null.
|
|
221
|
+
*
|
|
222
|
+
* @param val - The value.
|
|
223
|
+
* @returns If the value is an array, an object, a date, or null.
|
|
224
|
+
*/
|
|
225
|
+
declare function isObjectLike(val: unknown): val is object;
|
|
226
226
|
/**
|
|
227
227
|
* Identifies if a value is a string.
|
|
228
228
|
*
|
|
@@ -284,21 +284,19 @@ declare function isEven(n: number): boolean;
|
|
|
284
284
|
*/
|
|
285
285
|
declare function isOdd(n: number): boolean;
|
|
286
286
|
/**
|
|
287
|
-
* Returns the maximum number of
|
|
287
|
+
* Returns the maximum number of provided numbers or array of numbers.
|
|
288
288
|
*
|
|
289
|
-
* @param
|
|
289
|
+
* @param ns - The numbers or the array of numbers.
|
|
290
290
|
* @returns The maximum number.
|
|
291
291
|
*/
|
|
292
|
-
declare function max(
|
|
293
|
-
declare function max(array: readonly number[]): number;
|
|
292
|
+
declare function max(...ns: number[] | [number[]]): number;
|
|
294
293
|
/**
|
|
295
|
-
* Returns the minimum number of
|
|
294
|
+
* Returns the minimum number of provided numbers or array of numbers.
|
|
296
295
|
*
|
|
297
|
-
* @param
|
|
296
|
+
* @param ns - The numbers or the array of numbers.
|
|
298
297
|
* @returns The minimum number.
|
|
299
298
|
*/
|
|
300
|
-
declare function min(
|
|
301
|
-
declare function min(array: readonly number[]): number;
|
|
299
|
+
declare function min(...ns: number[] | [number[]]): number;
|
|
302
300
|
/**
|
|
303
301
|
* Returns the product of a number array.
|
|
304
302
|
*
|
|
@@ -338,6 +336,13 @@ declare function round(n: number, factor?: number): number;
|
|
|
338
336
|
*/
|
|
339
337
|
declare function sum(ns: readonly number[]): number;
|
|
340
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Deep clones an array or object.
|
|
341
|
+
*
|
|
342
|
+
* @param input - The array or object to clone.
|
|
343
|
+
* @returns A deep clone of the input array or object.
|
|
344
|
+
*/
|
|
345
|
+
declare function clone<T>(input: T): T;
|
|
341
346
|
/**
|
|
342
347
|
* Does nothing.
|
|
343
348
|
*
|
|
@@ -444,4 +449,4 @@ declare function toOrdinal(n: number): string;
|
|
|
444
449
|
*/
|
|
445
450
|
declare function truncate(str: string, length: number, suffix?: string): string;
|
|
446
451
|
|
|
447
|
-
export { type Arrayable, type Fn, type Nullable, type Obj, type VoidFn, capitalise, ceil, chars, clamp, clone, debounce, deepMerge, drop, floor, groupsOf, head, init, isArray, isBlank, isBoolean, isBrowser, isDefined, isEmpty, isEmptyObject, isEven, isFunction, isNull, isNumber, isObject, isOdd, isString, isTouchDevice, isWindow, last, max, memoize, min, noop, once, partition, product, randomChance, randomNumber, range, round, scroll, shuffle, sleep, splitAt, splitStrAt, sum, tail, take, throttle, toArray, toCamel, toKebab, toNumber, toOrdinal, truncate, uniq, uuid };
|
|
452
|
+
export { type Arrayable, type Fn, type Nullable, type Obj, type VoidFn, capitalise, ceil, chars, clamp, clone, debounce, deepMerge, drop, floor, groupsOf, head, init, isArray, isBlank, isBoolean, isBrowser, isDefined, isEmpty, isEmptyObject, isEven, isFunction, isNull, isNumber, isObject, isObjectLike, isOdd, isString, isTouchDevice, isWindow, last, max, memoize, min, noop, once, partition, product, randomChance, randomNumber, range, round, scroll, shuffle, sleep, splitAt, splitStrAt, sum, tail, take, throttle, toArray, toCamel, toKebab, toNumber, toOrdinal, truncate, uniq, uuid };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,18 +4,11 @@ type Fn<T = any> = (...args: any[]) => T;
|
|
|
4
4
|
type VoidFn = Fn<void>;
|
|
5
5
|
type Obj<V = unknown> = Record<string | symbol | number, V>;
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Clones an array.
|
|
9
|
-
*
|
|
10
|
-
* @param array - The array.
|
|
11
|
-
* @returns A clone of the array.
|
|
12
|
-
*/
|
|
13
|
-
declare function clone<T>(array: readonly T[]): T[];
|
|
14
7
|
/**
|
|
15
8
|
* Removes the first `n` items of an array.
|
|
16
9
|
*
|
|
17
10
|
* @param n - The number of items to remove.
|
|
18
|
-
* @param array - The array.
|
|
11
|
+
* @param array - The array.z
|
|
19
12
|
* @returns The remaining items.
|
|
20
13
|
*/
|
|
21
14
|
declare function drop<T>(n: number, array: readonly T[]): T[];
|
|
@@ -74,7 +67,7 @@ declare function range(start: number, stop: number, step?: number): number[];
|
|
|
74
67
|
* @param array - The array.
|
|
75
68
|
* @returns A copy of the array with its items randomly shuffled.
|
|
76
69
|
*/
|
|
77
|
-
declare function shuffle<T>(array:
|
|
70
|
+
declare function shuffle<T>(array: T[]): T[];
|
|
78
71
|
/**
|
|
79
72
|
* Splits an array into two at a specified index.
|
|
80
73
|
*
|
|
@@ -223,6 +216,13 @@ declare function isNumber(val: unknown): val is number;
|
|
|
223
216
|
* @returns If the value is an object.
|
|
224
217
|
*/
|
|
225
218
|
declare function isObject(val: unknown): val is Obj;
|
|
219
|
+
/**
|
|
220
|
+
* Identifies if a value is an array, an object, a date, or null.
|
|
221
|
+
*
|
|
222
|
+
* @param val - The value.
|
|
223
|
+
* @returns If the value is an array, an object, a date, or null.
|
|
224
|
+
*/
|
|
225
|
+
declare function isObjectLike(val: unknown): val is object;
|
|
226
226
|
/**
|
|
227
227
|
* Identifies if a value is a string.
|
|
228
228
|
*
|
|
@@ -284,21 +284,19 @@ declare function isEven(n: number): boolean;
|
|
|
284
284
|
*/
|
|
285
285
|
declare function isOdd(n: number): boolean;
|
|
286
286
|
/**
|
|
287
|
-
* Returns the maximum number of
|
|
287
|
+
* Returns the maximum number of provided numbers or array of numbers.
|
|
288
288
|
*
|
|
289
|
-
* @param
|
|
289
|
+
* @param ns - The numbers or the array of numbers.
|
|
290
290
|
* @returns The maximum number.
|
|
291
291
|
*/
|
|
292
|
-
declare function max(
|
|
293
|
-
declare function max(array: readonly number[]): number;
|
|
292
|
+
declare function max(...ns: number[] | [number[]]): number;
|
|
294
293
|
/**
|
|
295
|
-
* Returns the minimum number of
|
|
294
|
+
* Returns the minimum number of provided numbers or array of numbers.
|
|
296
295
|
*
|
|
297
|
-
* @param
|
|
296
|
+
* @param ns - The numbers or the array of numbers.
|
|
298
297
|
* @returns The minimum number.
|
|
299
298
|
*/
|
|
300
|
-
declare function min(
|
|
301
|
-
declare function min(array: readonly number[]): number;
|
|
299
|
+
declare function min(...ns: number[] | [number[]]): number;
|
|
302
300
|
/**
|
|
303
301
|
* Returns the product of a number array.
|
|
304
302
|
*
|
|
@@ -338,6 +336,13 @@ declare function round(n: number, factor?: number): number;
|
|
|
338
336
|
*/
|
|
339
337
|
declare function sum(ns: readonly number[]): number;
|
|
340
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Deep clones an array or object.
|
|
341
|
+
*
|
|
342
|
+
* @param input - The array or object to clone.
|
|
343
|
+
* @returns A deep clone of the input array or object.
|
|
344
|
+
*/
|
|
345
|
+
declare function clone<T>(input: T): T;
|
|
341
346
|
/**
|
|
342
347
|
* Does nothing.
|
|
343
348
|
*
|
|
@@ -444,4 +449,4 @@ declare function toOrdinal(n: number): string;
|
|
|
444
449
|
*/
|
|
445
450
|
declare function truncate(str: string, length: number, suffix?: string): string;
|
|
446
451
|
|
|
447
|
-
export { type Arrayable, type Fn, type Nullable, type Obj, type VoidFn, capitalise, ceil, chars, clamp, clone, debounce, deepMerge, drop, floor, groupsOf, head, init, isArray, isBlank, isBoolean, isBrowser, isDefined, isEmpty, isEmptyObject, isEven, isFunction, isNull, isNumber, isObject, isOdd, isString, isTouchDevice, isWindow, last, max, memoize, min, noop, once, partition, product, randomChance, randomNumber, range, round, scroll, shuffle, sleep, splitAt, splitStrAt, sum, tail, take, throttle, toArray, toCamel, toKebab, toNumber, toOrdinal, truncate, uniq, uuid };
|
|
452
|
+
export { type Arrayable, type Fn, type Nullable, type Obj, type VoidFn, capitalise, ceil, chars, clamp, clone, debounce, deepMerge, drop, floor, groupsOf, head, init, isArray, isBlank, isBoolean, isBrowser, isDefined, isEmpty, isEmptyObject, isEven, isFunction, isNull, isNumber, isObject, isObjectLike, isOdd, isString, isTouchDevice, isWindow, last, max, memoize, min, noop, once, partition, product, randomChance, randomNumber, range, round, scroll, shuffle, sleep, splitAt, splitStrAt, sum, tail, take, throttle, toArray, toCamel, toKebab, toNumber, toOrdinal, truncate, uniq, uuid };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function U(n,e=1){let t=n/e;return Math.ceil(t)*e}function F(n,e,t){return Math.min(t,Math.max(e,n))}function M(n,e=1){let t=n/e;return Math.floor(t)*e}function S(n){return n%2===0}function E(n){return n%2!==0}function C(...n){let e;return n.length===1&&Array.isArray(n[0])?e=n[0]:e=n,Math.max(...e)}function q(...n){let e;return n.length===1&&Array.isArray(n[0])?e=n[0]:e=n,Math.min(...e)}function I(n){let e=1;for(let t=0;t<n.length;t++)e*=n[t];return e}function V(n){return l(n)===0}function l(...n){let e,t;return n.length===1?(e=0,t=n[0]):(e=n[0],t=n[1]),Math.floor(Math.random()*(t-e))+e}function L(n,e=1){let t=n/e;return Math.round(t)*e}function R(n){let e=0;for(let t=0;t<n.length;t++)e+=n[t];return e}function s(n){return Array.isArray(n)}function D(n){return typeof n=="boolean"}function O(){return typeof window<"u"}function P(n){return typeof n<"u"}function W(n){if(!f(n))return!1;for(let e in n)return!1;return!0}function H(n){return typeof n=="function"}function c(n){return Object.prototype.toString.call(n)==="[object Null]"}function y(n){return typeof n=="number"}function f(n){return Object.prototype.toString.call(n)==="[object Object]"}function a(n){return typeof n=="object"}function p(n){return typeof n=="string"}function _(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function $(n){return O()&&Object.prototype.toString.call(n)==="[object Window]"}function m(n){if(s(n)){let e=[];for(let t=0;t<n.length;t++)a(n[t])&&!c(n[t])?e[t]=m(n[t]):e[t]=n[t];return e}if(a(n)&&!c(n)){let e={};for(let t in n)a(n[t])&&!c(n[t])?e[t]=m(n[t]):e[t]=n[t];return e}return n}function Y(){}async function Z(n){return n<0&&console.warn("[tsu] warning: a sleep duration less than 0ms will be treated as 0ms."),new Promise(e=>{setTimeout(e,n)})}var h="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function G(n=16){let e=h.length,t=n,r="";for(;t--;)r+=h[l(e)];return r}function en(n,e){return n<=0?[...e]:e.slice(n)}function tn(n,e){if(n<=0)throw new Error("[tsu] Invalid group size. Is it greater than 0?");if(n>=e.length)return[[...e]];let t=[];for(let r=0;r<e.length;r+=n)t.push(e.slice(r,r+n));return t}function rn(n){return n[0]}function on(n){return n.slice(0,n.length-1)}function un(n){return n[n.length-1]}function ln(n,e){let t=[],r=[];for(let o=0;o<n.length;o++){let i=n[o];e(i,o,n)?t.push(i):r.push(i)}return[t,r]}function sn(...n){let e,t,r;n.length===1?(t=n[0],e=0,r=1):(e=n[0],t=n[1],r=n[2]||1),r<=0&&(console.warn("[tsu] warning: a step less than or equal to 0 will be set to 1."),r=1);let o=[],i=e;for(;i<t;)o.push(i),i+=r||1;return o}function cn(n){let e=m(n),t,r,o;for(t=e.length;t;t-=1)r=l(t),o=e[t-1],e[t-1]=e[r],e[r]=o;return e}function fn(n,e){return n<=0?[[],[...e]]:n>e.length?[[...e],[]]:[e.slice(0,n),e.slice(n)]}function an(n){return n.slice(1)}function mn(n,e){return n<=0?[]:e.slice(0,n)}function pn(n){return n?Array.isArray(n)?n:[n]:[]}function w(n){return Array.from(new Set(n))}function xn({to:n,offset:e=0,duration:t=1e3,container:r=null}){let o=p(n)?document.querySelector(n):n,i=p(r)?document.querySelector(r):r,u=i?.scrollTop||window?.pageYOffset||0,b=(y(o)?o:A(o,u))+e,j=Date.now();function d(){let x=Date.now()-j,T=x<t,g=T?k(u,b,x,t):b;T&&requestAnimationFrame(d),i?i.scrollTop=g:window.scrollTo(0,g)}d()}function v(n){return n<.5?4*Math.pow(n,3):(n-1)*(2*n-2)*(2*n-2)+1}function k(n,e,t,r){return n+(e-n)*v(t/r)}function A(n,e){return n.nodeName==="HTML"?-e:n.getBoundingClientRect().top+e}function gn(n,e){e<0&&console.warn("[tsu] warning: a debounce delay less than 0ms will be treated as 0ms.");let t;return function(...r){clearTimeout(t),t=setTimeout(()=>{clearTimeout(t),n(...r)},e)}}function yn(n){let e={};return function(...t){let r=JSON.stringify(t);if(r in e)return e[r];let o=n(...t);return e[r]=o,o}}function hn(n){let e=!1;return(...t)=>{e||(n(...t),e=!0)}}function wn(n,e){e<0&&console.warn("[tsu] warning: a throttle limit less than 0ms will be treated as 0ms.");let t=!1;return function(...r){t||(n(...r),t=!0,setTimeout(()=>{t=!1},e))}}function N(...n){let e={};for(let t=0;t<n.length;t++){let r=n[t],o=Object.keys(r);for(let i=0;i<o.length;i++){let u=o[i];s(e[u])&&s(r[u])?e[u]=w(e[u].concat(r[u])):f(e[u])&&f(r[u])?e[u]=N(e[u],r[u]):e[u]=r[u]}}return e}function An(n,e=!1,t=" "){return e?n.split(t).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(t):n.charAt(0).toUpperCase()+n.slice(1)}function Nn(n){return n.split("")}function Un(n){return n.trim().length===0}function Fn(n){return n.length===0}function Mn(n,e){return n<=0?["",e]:n>e.length?[e,""]:[e.slice(0,n),e.slice(n)]}function Sn(n){let e=/-(\w)/g;return n.replace(e,(t,r)=>r?r.toUpperCase():"")}function En(n){let e=/\B([A-Z])/g;return n.replace(e,"-$1").toLowerCase()}function Cn(n){return n.length?Number(n.replace(/[#£€$,%]/g,"")):NaN}function qn(n){let t=["st","nd","rd"][(n/10%10^1&&n%10)-1]||"th";return`${n}${t}`}function In(n,e,t="..."){return e<=0?t:n.slice(0,e)+t}export{An as capitalise,U as ceil,Nn as chars,F as clamp,m as clone,gn as debounce,N as deepMerge,en as drop,M as floor,tn as groupsOf,rn as head,on as init,s as isArray,Un as isBlank,D as isBoolean,O as isBrowser,P as isDefined,Fn as isEmpty,W as isEmptyObject,S as isEven,H as isFunction,c as isNull,y as isNumber,f as isObject,a as isObjectLike,E as isOdd,p as isString,_ as isTouchDevice,$ as isWindow,un as last,C as max,yn as memoize,q as min,Y as noop,hn as once,ln as partition,I as product,V as randomChance,l as randomNumber,sn as range,L as round,xn as scroll,cn as shuffle,Z as sleep,fn as splitAt,Mn as splitStrAt,R as sum,an as tail,mn as take,wn as throttle,pn as toArray,Sn as toCamel,En as toKebab,Cn as toNumber,qn as toOrdinal,In as truncate,w as uniq,G as uuid};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsu",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "TypeScript utilities",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@antfu/ni": "^0.21.12",
|
|
39
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
40
|
-
"@typescript-eslint/parser": "^
|
|
41
|
-
"eslint": "^8.
|
|
39
|
+
"@typescript-eslint/eslint-plugin": "^7.4.0",
|
|
40
|
+
"@typescript-eslint/parser": "^7.4.0",
|
|
41
|
+
"eslint": "^8.57.0",
|
|
42
42
|
"eslint-config-prettier": "^9.1.0",
|
|
43
|
-
"eslint-plugin-prettier": "^5.1.
|
|
44
|
-
"prettier": "^3.
|
|
45
|
-
"tsup": "^8.0.
|
|
46
|
-
"typescript": "^5.
|
|
47
|
-
"vite": "^5.
|
|
48
|
-
"vitepress": "^1.0.
|
|
49
|
-
"vitest": "^1.
|
|
43
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
44
|
+
"prettier": "^3.2.5",
|
|
45
|
+
"tsup": "^8.0.2",
|
|
46
|
+
"typescript": "^5.4.3",
|
|
47
|
+
"vite": "^5.2.6",
|
|
48
|
+
"vitepress": "^1.0.1",
|
|
49
|
+
"vitest": "^1.4.0"
|
|
50
50
|
}
|
|
51
51
|
}
|