tsu 2.4.0 → 2.5.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 CHANGED
@@ -1 +1 @@
1
- "use strict";var f=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var U=(n,e)=>{for(var t in e)f(n,t,{get:e[t],enumerable:!0})},N=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of j(e))!k.call(n,o)&&o!==t&&f(n,o,{get:()=>e[o],enumerable:!(r=O(e,o))||r.enumerable});return n};var A=n=>N(f({},"__esModule",{value:!0}),n);var jn={};U(jn,{capitalise:()=>bn,ceil:()=>en,chars:()=>dn,debounce:()=>G,deepMerge:()=>w,drop:()=>F,floor:()=>tn,groupsOf:()=>S,head:()=>E,init:()=>M,isArray:()=>l,isBlank:()=>xn,isBoolean:()=>L,isBrowser:()=>g,isDefined:()=>P,isEmpty:()=>Tn,isEmptyObject:()=>W,isEven:()=>rn,isFunction:()=>H,isNull:()=>_,isNumber:()=>p,isObject:()=>s,isOdd:()=>on,isString:()=>c,isTouchDevice:()=>$,isWindow:()=>z,last:()=>q,max:()=>un,memoize:()=>Q,min:()=>sn,noop:()=>an,once:()=>X,partition:()=>C,randomChance:()=>ln,randomNumber:()=>y,range:()=>I,round:()=>cn,scroll:()=>J,sleep:()=>pn,splitAt:()=>V,splitStrAt:()=>gn,sum:()=>fn,tail:()=>B,take:()=>R,throttle:()=>nn,toArray:()=>D,toCamel:()=>yn,toKebab:()=>hn,toNumber:()=>wn,toOrdinal:()=>vn,truncate:()=>On,uniq:()=>a,uuid:()=>mn});module.exports=A(jn);function F(n,e){return n<=0?[...e]:e.slice(n)}function S(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 E(n){return n[0]}function M(n){return n.slice(0,n.length-1)}function q(n){return n[n.length-1]}function C(n,e){let t=[],r=[];for(let o=0;o<e.length;o++){let i=e[o];n(i,o,e)?t.push(i):r.push(i)}return[t,r]}function I(...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 V(n,e){return n<=0?[[],[...e]]:n>e.length?[[...e],[]]:[e.slice(0,n),e.slice(n)]}function B(n){return n.slice(1)}function R(n,e){return n<=0?[]:e.slice(0,n)}function D(n){return n?Array.isArray(n)?n:[n]:[]}function a(n){return Array.from(new Set(n))}function l(n){return Array.isArray(n)}function L(n){return typeof n=="boolean"}function g(){return typeof window<"u"}function P(n){return typeof n<"u"}function W(n){if(!s(n))return!1;for(let e in n)return!1;return!0}function H(n){return typeof n=="function"}function _(n){return Object.prototype.toString.call(n)==="[object Null]"}function p(n){return typeof n=="number"}function s(n){return Object.prototype.toString.call(n)==="[object Object]"}function c(n){return typeof n=="string"}function $(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function z(n){return g()&&Object.prototype.toString.call(n)==="[object Window]"}function J({to:n,offset:e=0,duration:t=1e3,container:r=null}){let o=c(n)?document.querySelector(n):n,i=c(r)?document.querySelector(r):r,u=i?.scrollTop||window?.pageYOffset||0,m=(p(o)?o:Z(o,u))+e,v=Date.now();function b(){let d=Date.now()-v,x=d<t,T=x?Y(u,m,d,t):m;x&&requestAnimationFrame(b),i?i.scrollTop=T:window.scrollTo(0,T)}b()}function K(n){return n<.5?4*Math.pow(n,3):(n-1)*(2*n-2)*(2*n-2)+1}function Y(n,e,t,r){return n+(e-n)*K(t/r)}function Z(n,e){return n.nodeName==="HTML"?-e:n.getBoundingClientRect().top+e}function G(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 Q(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 X(n){let e=!1;return(...t)=>{e||(n(...t),e=!0)}}function nn(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 en(n,e=1){let t=n/e;return Math.ceil(t)*e}function tn(n,e=1){let t=n/e;return Math.floor(t)*e}function rn(n){return n%2===0}function on(n){return n%2!==0}function un(n){if(n.length)return Math.max(...n)}function sn(n){if(n.length)return Math.min(...n)}function ln(n){return y(n)===0}function y(...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 cn(n,e=1){let t=n/e;return Math.round(t)*e}function fn(n){let e=0;for(let t=0;t<n.length;t++)e+=n[t];return e}function an(){}async function pn(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 mn(n=16){let e=h.length,t=n,r="";for(;t--;)r+=h[Math.random()*e|0];return r}function w(...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];l(e[u])&&l(r[u])?e[u]=a(e[u].concat(r[u])):s(e[u])&&s(r[u])?e[u]=w(e[u],r[u]):e[u]=r[u]}}return e}function bn(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 dn(n){return n.split("")}function xn(n){return n.trim().length===0}function Tn(n){return n.length===0}function gn(n,e){return n<=0?["",e]:n>e.length?[e,""]:[e.slice(0,n),e.slice(n)]}function yn(n){let e=/-(\w)/g;return n.replace(e,(t,r)=>r?r.toUpperCase():"")}function hn(n){let e=/\B([A-Z])/g;return n.replace(e,"-$1").toLowerCase()}function wn(n){return n.length?Number(n.replace(/[#£€$,%]/g,"")):NaN}function vn(n){let t=["st","nd","rd"][(n/10%10^1&&n%10)-1]||"th";return`${n}${t}`}function On(n,e,t="..."){return e<=0?t:n.slice(0,e)+t}0&&(module.exports={capitalise,ceil,chars,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,randomChance,randomNumber,range,round,scroll,sleep,splitAt,splitStrAt,sum,tail,take,throttle,toArray,toCamel,toKebab,toNumber,toOrdinal,truncate,uniq,uuid});
1
+ "use strict";var f=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var U=(n,e)=>{for(var t in e)f(n,t,{get:e[t],enumerable:!0})},M=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of j(e))!k.call(n,o)&&o!==t&&f(n,o,{get:()=>e[o],enumerable:!(r=O(e,o))||r.enumerable});return n};var N=n=>M(f({},"__esModule",{value:!0}),n);var kn={};U(kn,{capitalise:()=>dn,ceil:()=>en,chars:()=>xn,clamp:()=>tn,debounce:()=>G,deepMerge:()=>w,drop:()=>A,floor:()=>rn,groupsOf:()=>F,head:()=>S,init:()=>E,isArray:()=>l,isBlank:()=>Tn,isBoolean:()=>L,isBrowser:()=>g,isDefined:()=>P,isEmpty:()=>gn,isEmptyObject:()=>W,isEven:()=>on,isFunction:()=>H,isNull:()=>_,isNumber:()=>m,isObject:()=>s,isOdd:()=>un,isString:()=>c,isTouchDevice:()=>$,isWindow:()=>z,last:()=>q,max:()=>sn,memoize:()=>Q,min:()=>ln,noop:()=>mn,once:()=>X,partition:()=>C,randomChance:()=>cn,randomNumber:()=>y,range:()=>I,round:()=>fn,scroll:()=>J,sleep:()=>pn,splitAt:()=>V,splitStrAt:()=>yn,sum:()=>an,tail:()=>B,take:()=>R,throttle:()=>nn,toArray:()=>D,toCamel:()=>hn,toKebab:()=>wn,toNumber:()=>vn,toOrdinal:()=>On,truncate:()=>jn,uniq:()=>a,uuid:()=>bn});module.exports=N(kn);function A(n,e){return n<=0?[...e]:e.slice(n)}function F(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 S(n){return n[0]}function E(n){return n.slice(0,n.length-1)}function q(n){return n[n.length-1]}function C(n,e){let t=[],r=[];for(let o=0;o<e.length;o++){let u=e[o];n(u,o,e)?t.push(u):r.push(u)}return[t,r]}function I(...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=[],u=e;for(;u<t;)o.push(u),u+=r||1;return o}function V(n,e){return n<=0?[[],[...e]]:n>e.length?[[...e],[]]:[e.slice(0,n),e.slice(n)]}function B(n){return n.slice(1)}function R(n,e){return n<=0?[]:e.slice(0,n)}function D(n){return n?Array.isArray(n)?n:[n]:[]}function a(n){return Array.from(new Set(n))}function l(n){return Array.isArray(n)}function L(n){return typeof n=="boolean"}function g(){return typeof window<"u"}function P(n){return typeof n<"u"}function W(n){if(!s(n))return!1;for(let e in n)return!1;return!0}function H(n){return typeof n=="function"}function _(n){return Object.prototype.toString.call(n)==="[object Null]"}function m(n){return typeof n=="number"}function s(n){return Object.prototype.toString.call(n)==="[object Object]"}function c(n){return typeof n=="string"}function $(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function z(n){return g()&&Object.prototype.toString.call(n)==="[object Window]"}function J({to:n,offset:e=0,duration:t=1e3,container:r=null}){let o=c(n)?document.querySelector(n):n,u=c(r)?document.querySelector(r):r,i=u?.scrollTop||window?.pageYOffset||0,p=(m(o)?o:Z(o,i))+e,v=Date.now();function b(){let d=Date.now()-v,x=d<t,T=x?Y(i,p,d,t):p;x&&requestAnimationFrame(b),u?u.scrollTop=T:window.scrollTo(0,T)}b()}function K(n){return n<.5?4*Math.pow(n,3):(n-1)*(2*n-2)*(2*n-2)+1}function Y(n,e,t,r){return n+(e-n)*K(t/r)}function Z(n,e){return n.nodeName==="HTML"?-e:n.getBoundingClientRect().top+e}function G(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 Q(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 X(n){let e=!1;return(...t)=>{e||(n(...t),e=!0)}}function nn(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 en(n,e=1){let t=n/e;return Math.ceil(t)*e}function tn(n,e,t){return Math.min(t,Math.max(e,n))}function rn(n,e=1){let t=n/e;return Math.floor(t)*e}function on(n){return n%2===0}function un(n){return n%2!==0}function sn(n){if(n.length)return Math.max(...n)}function ln(n){if(n.length)return Math.min(...n)}function cn(n){return y(n)===0}function y(...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 fn(n,e=1){let t=n/e;return Math.round(t)*e}function an(n){let e=0;for(let t=0;t<n.length;t++)e+=n[t];return e}function mn(){}async function pn(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 bn(n=16){let e=h.length,t=n,r="";for(;t--;)r+=h[Math.random()*e|0];return r}function w(...n){let e={};for(let t=0;t<n.length;t++){let r=n[t],o=Object.keys(r);for(let u=0;u<o.length;u++){let i=o[u];l(e[i])&&l(r[i])?e[i]=a(e[i].concat(r[i])):s(e[i])&&s(r[i])?e[i]=w(e[i],r[i]):e[i]=r[i]}}return e}function dn(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 xn(n){return n.split("")}function Tn(n){return n.trim().length===0}function gn(n){return n.length===0}function yn(n,e){return n<=0?["",e]:n>e.length?[e,""]:[e.slice(0,n),e.slice(n)]}function hn(n){let e=/-(\w)/g;return n.replace(e,(t,r)=>r?r.toUpperCase():"")}function wn(n){let e=/\B([A-Z])/g;return n.replace(e,"-$1").toLowerCase()}function vn(n){return n.length?Number(n.replace(/[#£€$,%]/g,"")):NaN}function On(n){let t=["st","nd","rd"][(n/10%10^1&&n%10)-1]||"th";return`${n}${t}`}function jn(n,e,t="..."){return e<=0?t:n.slice(0,e)+t}0&&(module.exports={capitalise,ceil,chars,clamp,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,randomChance,randomNumber,range,round,scroll,sleep,splitAt,splitStrAt,sum,tail,take,throttle,toArray,toCamel,toKebab,toNumber,toOrdinal,truncate,uniq,uuid});
package/dist/index.d.cts CHANGED
@@ -238,6 +238,15 @@ declare function isWindow(val: unknown): val is Window;
238
238
  * @returns The rounded number.
239
239
  */
240
240
  declare function ceil(n: number, factor?: number): number;
241
+ /**
242
+ * Restricts a number between two bounds.
243
+ *
244
+ * @param n - The number to restrict.
245
+ * @param min - The minimum bound.
246
+ * @param max - The maximum bound.
247
+ * @returns The number restricted between the specified bounds.
248
+ */
249
+ declare function clamp(n: number, min: number, max: number): number;
241
250
  /**
242
251
  * Rounds a number down to the nearest multiple of the specified factor.
243
252
  *
@@ -414,4 +423,4 @@ declare function toOrdinal(n: number): string;
414
423
  */
415
424
  declare function truncate(str: string, length: number, suffix?: string): string;
416
425
 
417
- export { type Arrayable, type Fn, type Nullable, type Obj, type VoidFn, capitalise, ceil, chars, 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, randomChance, randomNumber, range, round, scroll, sleep, splitAt, splitStrAt, sum, tail, take, throttle, toArray, toCamel, toKebab, toNumber, toOrdinal, truncate, uniq, uuid };
426
+ export { type Arrayable, type Fn, type Nullable, type Obj, type VoidFn, capitalise, ceil, chars, clamp, 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, randomChance, randomNumber, range, round, scroll, sleep, splitAt, splitStrAt, sum, tail, take, throttle, toArray, toCamel, toKebab, toNumber, toOrdinal, truncate, uniq, uuid };
package/dist/index.d.ts CHANGED
@@ -238,6 +238,15 @@ declare function isWindow(val: unknown): val is Window;
238
238
  * @returns The rounded number.
239
239
  */
240
240
  declare function ceil(n: number, factor?: number): number;
241
+ /**
242
+ * Restricts a number between two bounds.
243
+ *
244
+ * @param n - The number to restrict.
245
+ * @param min - The minimum bound.
246
+ * @param max - The maximum bound.
247
+ * @returns The number restricted between the specified bounds.
248
+ */
249
+ declare function clamp(n: number, min: number, max: number): number;
241
250
  /**
242
251
  * Rounds a number down to the nearest multiple of the specified factor.
243
252
  *
@@ -414,4 +423,4 @@ declare function toOrdinal(n: number): string;
414
423
  */
415
424
  declare function truncate(str: string, length: number, suffix?: string): string;
416
425
 
417
- export { type Arrayable, type Fn, type Nullable, type Obj, type VoidFn, capitalise, ceil, chars, 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, randomChance, randomNumber, range, round, scroll, sleep, splitAt, splitStrAt, sum, tail, take, throttle, toArray, toCamel, toKebab, toNumber, toOrdinal, truncate, uniq, uuid };
426
+ export { type Arrayable, type Fn, type Nullable, type Obj, type VoidFn, capitalise, ceil, chars, clamp, 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, randomChance, randomNumber, range, round, scroll, sleep, splitAt, splitStrAt, sum, tail, take, throttle, toArray, toCamel, toKebab, toNumber, toOrdinal, truncate, uniq, uuid };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- function k(n,e){return n<=0?[...e]:e.slice(n)}function U(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 N(n){return n[0]}function A(n){return n.slice(0,n.length-1)}function F(n){return n[n.length-1]}function S(n,e){let t=[],r=[];for(let o=0;o<e.length;o++){let i=e[o];n(i,o,e)?t.push(i):r.push(i)}return[t,r]}function E(...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 M(n,e){return n<=0?[[],[...e]]:n>e.length?[[...e],[]]:[e.slice(0,n),e.slice(n)]}function q(n){return n.slice(1)}function C(n,e){return n<=0?[]:e.slice(0,n)}function I(n){return n?Array.isArray(n)?n:[n]:[]}function d(n){return Array.from(new Set(n))}function l(n){return Array.isArray(n)}function B(n){return typeof n=="boolean"}function y(){return typeof window<"u"}function R(n){return typeof n<"u"}function D(n){if(!s(n))return!1;for(let e in n)return!1;return!0}function L(n){return typeof n=="function"}function P(n){return Object.prototype.toString.call(n)==="[object Null]"}function x(n){return typeof n=="number"}function s(n){return Object.prototype.toString.call(n)==="[object Object]"}function c(n){return typeof n=="string"}function W(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function H(n){return y()&&Object.prototype.toString.call(n)==="[object Window]"}function z({to:n,offset:e=0,duration:t=1e3,container:r=null}){let o=c(n)?document.querySelector(n):n,i=c(r)?document.querySelector(r):r,u=i?.scrollTop||window?.pageYOffset||0,f=(x(o)?o:v(o,u))+e,g=Date.now();function a(){let p=Date.now()-g,m=p<t,b=m?w(u,f,p,t):f;m&&requestAnimationFrame(a),i?i.scrollTop=b:window.scrollTo(0,b)}a()}function h(n){return n<.5?4*Math.pow(n,3):(n-1)*(2*n-2)*(2*n-2)+1}function w(n,e,t,r){return n+(e-n)*h(t/r)}function v(n,e){return n.nodeName==="HTML"?-e:n.getBoundingClientRect().top+e}function K(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 Y(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 Z(n){let e=!1;return(...t)=>{e||(n(...t),e=!0)}}function G(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 X(n,e=1){let t=n/e;return Math.ceil(t)*e}function nn(n,e=1){let t=n/e;return Math.floor(t)*e}function en(n){return n%2===0}function tn(n){return n%2!==0}function rn(n){if(n.length)return Math.max(...n)}function on(n){if(n.length)return Math.min(...n)}function un(n){return O(n)===0}function O(...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 sn(n,e=1){let t=n/e;return Math.round(t)*e}function ln(n){let e=0;for(let t=0;t<n.length;t++)e+=n[t];return e}function fn(){}async function an(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 T="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function pn(n=16){let e=T.length,t=n,r="";for(;t--;)r+=T[Math.random()*e|0];return r}function j(...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];l(e[u])&&l(r[u])?e[u]=d(e[u].concat(r[u])):s(e[u])&&s(r[u])?e[u]=j(e[u],r[u]):e[u]=r[u]}}return e}function Tn(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 gn(n){return n.split("")}function yn(n){return n.trim().length===0}function hn(n){return n.length===0}function wn(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 On(n){let e=/\B([A-Z])/g;return n.replace(e,"-$1").toLowerCase()}function jn(n){return n.length?Number(n.replace(/[#£€$,%]/g,"")):NaN}function kn(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}export{Tn as capitalise,X as ceil,gn as chars,K as debounce,j as deepMerge,k as drop,nn as floor,U as groupsOf,N as head,A as init,l as isArray,yn as isBlank,B as isBoolean,y as isBrowser,R as isDefined,hn as isEmpty,D as isEmptyObject,en as isEven,L as isFunction,P as isNull,x as isNumber,s as isObject,tn as isOdd,c as isString,W as isTouchDevice,H as isWindow,F as last,rn as max,Y as memoize,on as min,fn as noop,Z as once,S as partition,un as randomChance,O as randomNumber,E as range,sn as round,z as scroll,an as sleep,M as splitAt,wn as splitStrAt,ln as sum,q as tail,C as take,G as throttle,I as toArray,vn as toCamel,On as toKebab,jn as toNumber,kn as toOrdinal,Un as truncate,d as uniq,pn as uuid};
1
+ function k(n,e){return n<=0?[...e]:e.slice(n)}function U(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 M(n){return n[0]}function N(n){return n.slice(0,n.length-1)}function A(n){return n[n.length-1]}function F(n,e){let t=[],r=[];for(let o=0;o<e.length;o++){let u=e[o];n(u,o,e)?t.push(u):r.push(u)}return[t,r]}function S(...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=[],u=e;for(;u<t;)o.push(u),u+=r||1;return o}function E(n,e){return n<=0?[[],[...e]]:n>e.length?[[...e],[]]:[e.slice(0,n),e.slice(n)]}function q(n){return n.slice(1)}function C(n,e){return n<=0?[]:e.slice(0,n)}function I(n){return n?Array.isArray(n)?n:[n]:[]}function d(n){return Array.from(new Set(n))}function l(n){return Array.isArray(n)}function B(n){return typeof n=="boolean"}function y(){return typeof window<"u"}function R(n){return typeof n<"u"}function D(n){if(!s(n))return!1;for(let e in n)return!1;return!0}function L(n){return typeof n=="function"}function P(n){return Object.prototype.toString.call(n)==="[object Null]"}function x(n){return typeof n=="number"}function s(n){return Object.prototype.toString.call(n)==="[object Object]"}function c(n){return typeof n=="string"}function W(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function H(n){return y()&&Object.prototype.toString.call(n)==="[object Window]"}function z({to:n,offset:e=0,duration:t=1e3,container:r=null}){let o=c(n)?document.querySelector(n):n,u=c(r)?document.querySelector(r):r,i=u?.scrollTop||window?.pageYOffset||0,f=(x(o)?o:v(o,i))+e,g=Date.now();function a(){let m=Date.now()-g,p=m<t,b=p?w(i,f,m,t):f;p&&requestAnimationFrame(a),u?u.scrollTop=b:window.scrollTo(0,b)}a()}function h(n){return n<.5?4*Math.pow(n,3):(n-1)*(2*n-2)*(2*n-2)+1}function w(n,e,t,r){return n+(e-n)*h(t/r)}function v(n,e){return n.nodeName==="HTML"?-e:n.getBoundingClientRect().top+e}function K(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 Y(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 Z(n){let e=!1;return(...t)=>{e||(n(...t),e=!0)}}function G(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 X(n,e=1){let t=n/e;return Math.ceil(t)*e}function nn(n,e,t){return Math.min(t,Math.max(e,n))}function en(n,e=1){let t=n/e;return Math.floor(t)*e}function tn(n){return n%2===0}function rn(n){return n%2!==0}function on(n){if(n.length)return Math.max(...n)}function un(n){if(n.length)return Math.min(...n)}function sn(n){return O(n)===0}function O(...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 ln(n,e=1){let t=n/e;return Math.round(t)*e}function cn(n){let e=0;for(let t=0;t<n.length;t++)e+=n[t];return e}function an(){}async function mn(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 T="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function pn(n=16){let e=T.length,t=n,r="";for(;t--;)r+=T[Math.random()*e|0];return r}function j(...n){let e={};for(let t=0;t<n.length;t++){let r=n[t],o=Object.keys(r);for(let u=0;u<o.length;u++){let i=o[u];l(e[i])&&l(r[i])?e[i]=d(e[i].concat(r[i])):s(e[i])&&s(r[i])?e[i]=j(e[i],r[i]):e[i]=r[i]}}return e}function gn(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 yn(n){return n.split("")}function hn(n){return n.trim().length===0}function wn(n){return n.length===0}function vn(n,e){return n<=0?["",e]:n>e.length?[e,""]:[e.slice(0,n),e.slice(n)]}function On(n){let e=/-(\w)/g;return n.replace(e,(t,r)=>r?r.toUpperCase():"")}function jn(n){let e=/\B([A-Z])/g;return n.replace(e,"-$1").toLowerCase()}function kn(n){return n.length?Number(n.replace(/[#£€$,%]/g,"")):NaN}function Un(n){let t=["st","nd","rd"][(n/10%10^1&&n%10)-1]||"th";return`${n}${t}`}function Mn(n,e,t="..."){return e<=0?t:n.slice(0,e)+t}export{gn as capitalise,X as ceil,yn as chars,nn as clamp,K as debounce,j as deepMerge,k as drop,en as floor,U as groupsOf,M as head,N as init,l as isArray,hn as isBlank,B as isBoolean,y as isBrowser,R as isDefined,wn as isEmpty,D as isEmptyObject,tn as isEven,L as isFunction,P as isNull,x as isNumber,s as isObject,rn as isOdd,c as isString,W as isTouchDevice,H as isWindow,A as last,on as max,Y as memoize,un as min,an as noop,Z as once,F as partition,sn as randomChance,O as randomNumber,S as range,ln as round,z as scroll,mn as sleep,E as splitAt,vn as splitStrAt,cn as sum,q as tail,C as take,G as throttle,I as toArray,On as toCamel,jn as toKebab,kn as toNumber,Un as toOrdinal,Mn as truncate,d as uniq,pn as uuid};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsu",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "type": "module",
5
5
  "description": "TypeScript utilities",
6
6
  "license": "MIT",