tsu 2.9.0 → 2.9.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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var d=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var E=(e,n)=>{for(var t in n)d(e,t,{get:n[t],enumerable:!0})},M=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of N(n))!U.call(e,o)&&o!==t&&d(e,o,{get:()=>n[o],enumerable:!(r=C(n,o))||r.enumerable});return e};var S=e=>M(d({},"__esModule",{value:!0}),e);var Le={};E(Le,{capitalise:()=>ke,ceil:()=>F,chars:()=>Oe,clamp:()=>I,clone:()=>m,copyToClipboard:()=>de,debounce:()=>he,deepMerge:()=>O,drop:()=>te,floor:()=>L,groupsOf:()=>re,head:()=>oe,init:()=>ie,isArray:()=>l,isBlank:()=>Ae,isBoolean:()=>_,isBrowser:()=>p,isDefined:()=>$,isEmpty:()=>Ce,isEmptyArray:()=>z,isEmptyObject:()=>J,isEven:()=>q,isFunction:()=>K,isNull:()=>c,isNumber:()=>x,isObject:()=>a,isObjectLike:()=>f,isOdd:()=>R,isString:()=>b,isTouchDevice:()=>Y,isUndefined:()=>Z,isWindow:()=>G,last:()=>ue,max:()=>V,memoize:()=>we,min:()=>D,noop:()=>Q,once:()=>ve,partition:()=>le,product:()=>B,randomChance:()=>P,randomNumber:()=>s,range:()=>se,replaceChar:()=>Ne,round:()=>W,scroll:()=>xe,shuffle:()=>ce,sleep:()=>ee,splitAt:()=>ae,splitStrAt:()=>Ue,sum:()=>X,tail:()=>fe,take:()=>me,throttle:()=>je,toArray:()=>pe,toCamel:()=>Ee,toKebab:()=>Me,toNumber:()=>Se,toOrdinal:()=>Fe,toRomanNumerals:()=>H,truncate:()=>Ie,uniq:()=>T,uuid:()=>ne});module.exports=S(Le);function F(e,n=1){let t=e/n;return Math.ceil(t)*n}function I(e,n,t){return Math.min(t,Math.max(n,e))}function L(e,n=1){let t=e/n;return Math.floor(t)*n}function q(e){return e%2===0}function R(e){return e%2!==0}function V(...e){let n;return e.length===1&&Array.isArray(e[0])?n=e[0]:n=e,Math.max(...n)}function D(...e){let n;return e.length===1&&Array.isArray(e[0])?n=e[0]:n=e,Math.min(...n)}function B(e){let n=1;for(let t=0;t<e.length;t++)n*=e[t];return n}function P(e){return s(e)===0}function s(...e){let n,t;return e.length===1?(n=0,t=e[0]):(n=e[0],t=e[1]),Math.floor(Math.random()*(t-n))+n}function W(e,n=1){let t=e/n;return Math.round(t)*n}function X(e){let n=0;for(let t=0;t<e.length;t++)n+=e[t];return n}var j={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 H(e,n=!1){let t=e,r="",o=Object.keys(j).map(Number).sort((i,u)=>u-i);for(let i of o)for(;t>=i;)r+=j[i],t-=i;return n?r.toLowerCase():r}function l(e){return Array.isArray(e)}function _(e){return typeof e=="boolean"}function p(){return typeof window<"u"}function $(e){return typeof e<"u"}function z(e){return l(e)&&e.length===0}function J(e){if(!a(e))return!1;for(let n in e)return!1;return!0}function K(e){return typeof e=="function"}function c(e){return Object.prototype.toString.call(e)==="[object Null]"}function x(e){return typeof e=="number"}function a(e){return Object.prototype.toString.call(e)==="[object Object]"}function f(e){return typeof e=="object"}function b(e){return typeof e=="string"}function Y(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function Z(e){return typeof e>"u"}function G(e){return p()&&Object.prototype.toString.call(e)==="[object Window]"}function m(e){if(l(e)){let n=[];for(let t=0;t<e.length;t++)f(e[t])&&!c(e[t])?n[t]=m(e[t]):n[t]=e[t];return n}if(f(e)&&!c(e)){let n={};for(let t in e)f(e[t])&&!c(e[t])?n[t]=m(e[t]):n[t]=e[t];return n}return e}function Q(){}async function ee(e){return e<0&&console.warn("[tsu] warning: a sleep duration less than 0ms will be treated as 0ms."),new Promise(n=>{setTimeout(n,e)})}var k="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function ne(e=16){let n=k.length,t=e,r="";for(;t--;)r+=k[s(n)];return r}function te(e,n){return e<=0?[...n]:n.slice(e)}function re(e,n){if(e<=0)throw new Error("[tsu] Invalid group size. Is it greater than 0?");if(e>=n.length)return[[...n]];let t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function oe(e){return e[0]}function ie(e){return e.slice(0,e.length-1)}function ue(e){return e[e.length-1]}function le(e,n){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 se(...e){let n,t,r;e.length===1?(t=e[0],n=0,r=1):(n=e[0],t=e[1],r=e[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=n;for(;i<t;)o.push(i),i+=r||1;return o}function ce(e){let n=m(e),t,r,o;for(t=n.length;t;t-=1)r=s(t),o=n[t-1],n[t-1]=n[r],n[r]=o;return n}function ae(e,n){return e<=0?[[],[...n]]:e>n.length?[[...n],[]]:[n.slice(0,e),n.slice(e)]}function fe(e){return e.slice(1)}function me(e,n){return e<=0?[]:n.slice(0,e)}function pe(e){return e?Array.isArray(e)?e:[e]:[]}function T(e){return Array.from(new Set(e))}function be(e){let n=document.createElement("textarea");n.value=e??"",n.style.position="absolute",n.style.opacity="0",document.body.appendChild(n),n.select(),document.execCommand("copy"),n.remove()}function de(e){p()&&(window.navigator&&"clipboard"in window.navigator?navigator.clipboard.writeText(e):be(e))}function xe({to:e,offset:n=0,duration:t=1e3,container:r=null}){let o=b(e)?document.querySelector(e):e,i=b(r)?document.querySelector(r):r,u=i?.scrollTop||window?.pageYOffset||0,g=(x(o)?o:ye(o,u))+n,A=Date.now();function y(){let h=Date.now()-A,w=h<t,v=w?ge(u,g,h,t):g;w&&requestAnimationFrame(y),i?i.scrollTop=v:window.scrollTo(0,v)}y()}function Te(e){return e<.5?4*Math.pow(e,3):(e-1)*(2*e-2)*(2*e-2)+1}function ge(e,n,t,r){return e+(n-e)*Te(t/r)}function ye(e,n){return e.nodeName==="HTML"?-n:e.getBoundingClientRect().top+n}function he(e,n){n<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),e(...r)},n)}}function we(e){let n={};return function(...t){let r=JSON.stringify(t);if(r in n)return n[r];let o=e(...t);return n[r]=o,o}}function ve(e){let n=!1;return(...t)=>{n||(e(...t),n=!0)}}function je(e,n){n<0&&console.warn("[tsu] warning: a throttle limit less than 0ms will be treated as 0ms.");let t=!1;return function(...r){t||(e(...r),t=!0,setTimeout(()=>{t=!1},n))}}function O(...e){let n={};for(let t=0;t<e.length;t++){let r=e[t],o=Object.keys(r);for(let i=0;i<o.length;i++){let u=o[i];l(n[u])&&l(r[u])?n[u]=T(n[u].concat(r[u])):a(n[u])&&a(r[u])?n[u]=O(n[u],r[u]):n[u]=r[u]}}return n}function ke(e,n=!1,t=" "){return n?e.split(t).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(t):e.charAt(0).toUpperCase()+e.slice(1)}function Oe(e){return e.split("")}function Ae(e){return e.trim().length===0}function Ce(e){return e.length===0}function Ne(e,n,t){return n<0||n>e.length-1?e:e.slice(0,n)+t+e.slice(n+1)}function Ue(e,n){return n<=0?["",e]:n>e.length?[e,""]:[e.slice(0,n),e.slice(n)]}function Ee(e){let n=/-(\w)/g;return e.replace(n,(t,r)=>r?r.toUpperCase():"")}function Me(e){let n=/\B([A-Z])/g;return e.replace(n,"-$1").toLowerCase()}function Se(e){return e.length?Number(e.replace(/[#£€$,%]/g,"")):NaN}function Fe(e){let t=["st","nd","rd"][(e/10%10^1&&e%10)-1]||"th";return`${e}${t}`}function Ie(e,n,t="..."){return n<=0?t:e.slice(0,n)+t}0&&(module.exports={capitalise,ceil,chars,clamp,clone,copyToClipboard,debounce,deepMerge,drop,floor,groupsOf,head,init,isArray,isBlank,isBoolean,isBrowser,isDefined,isEmpty,isEmptyArray,isEmptyObject,isEven,isFunction,isNull,isNumber,isObject,isObjectLike,isOdd,isString,isTouchDevice,isUndefined,isWindow,last,max,memoize,min,noop,once,partition,product,randomChance,randomNumber,range,replaceChar,round,scroll,shuffle,sleep,splitAt,splitStrAt,sum,tail,take,throttle,toArray,toCamel,toKebab,toNumber,toOrdinal,toRomanNumerals,truncate,uniq,uuid});
|
package/dist/index.d.cts
CHANGED
|
@@ -186,7 +186,7 @@ declare function isBrowser(): boolean;
|
|
|
186
186
|
* @param val - The value.
|
|
187
187
|
* @returns If the value is defined.
|
|
188
188
|
*/
|
|
189
|
-
declare function isDefined<T>(val: T): val is T
|
|
189
|
+
declare function isDefined<T>(val: T): val is Exclude<T, null | undefined>;
|
|
190
190
|
/**
|
|
191
191
|
* Identifies if a value is an empty array.
|
|
192
192
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -186,7 +186,7 @@ declare function isBrowser(): boolean;
|
|
|
186
186
|
* @param val - The value.
|
|
187
187
|
* @returns If the value is defined.
|
|
188
188
|
*/
|
|
189
|
-
declare function isDefined<T>(val: T): val is T
|
|
189
|
+
declare function isDefined<T>(val: T): val is Exclude<T, null | undefined>;
|
|
190
190
|
/**
|
|
191
191
|
* Identifies if a value is an empty array.
|
|
192
192
|
*
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function E(e,n=1){let t=e/n;return Math.ceil(t)*n}function M(e,n,t){return Math.min(t,Math.max(n,e))}function S(e,n=1){let t=e/n;return Math.floor(t)*n}function F(e){return e%2===0}function I(e){return e%2!==0}function L(...e){let n;return e.length===1&&Array.isArray(e[0])?n=e[0]:n=e,Math.max(...n)}function q(...e){let n;return e.length===1&&Array.isArray(e[0])?n=e[0]:n=e,Math.min(...n)}function R(e){let n=1;for(let t=0;t<e.length;t++)n*=e[t];return n}function V(e){return s(e)===0}function s(...e){let n,t;return e.length===1?(n=0,t=e[0]):(n=e[0],t=e[1]),Math.floor(Math.random()*(t-n))+n}function D(e,n=1){let t=e/n;return Math.round(t)*n}function B(e){let n=0;for(let t=0;t<e.length;t++)n+=e[t];return n}var h={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 P(e,n=!1){let t=e,r="",o=Object.keys(h).map(Number).sort((i,u)=>u-i);for(let i of o)for(;t>=i;)r+=h[i],t-=i;return n?r.toLowerCase():r}function l(e){return Array.isArray(e)}function X(e){return typeof e=="boolean"}function p(){return typeof window<"u"}function H(e){return typeof e<"u"}function _(e){return l(e)&&e.length===0}function $(e){if(!a(e))return!1;for(let n in e)return!1;return!0}function z(e){return typeof e=="function"}function c(e){return Object.prototype.toString.call(e)==="[object Null]"}function w(e){return typeof e=="number"}function a(e){return Object.prototype.toString.call(e)==="[object Object]"}function f(e){return typeof e=="object"}function b(e){return typeof e=="string"}function J(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function K(e){return typeof e>"u"}function Y(e){return p()&&Object.prototype.toString.call(e)==="[object Window]"}function m(e){if(l(e)){let n=[];for(let t=0;t<e.length;t++)f(e[t])&&!c(e[t])?n[t]=m(e[t]):n[t]=e[t];return n}if(f(e)&&!c(e)){let n={};for(let t in e)f(e[t])&&!c(e[t])?n[t]=m(e[t]):n[t]=e[t];return n}return e}function ee(){}async function ne(e){return e<0&&console.warn("[tsu] warning: a sleep duration less than 0ms will be treated as 0ms."),new Promise(n=>{setTimeout(n,e)})}var v="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function te(e=16){let n=v.length,t=e,r="";for(;t--;)r+=v[s(n)];return r}function ue(e,n){return e<=0?[...n]:n.slice(e)}function le(e,n){if(e<=0)throw new Error("[tsu] Invalid group size. Is it greater than 0?");if(e>=n.length)return[[...n]];let t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t}function se(e){return e[0]}function ce(e){return e.slice(0,e.length-1)}function ae(e){return e[e.length-1]}function fe(e,n){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 me(...e){let n,t,r;e.length===1?(t=e[0],n=0,r=1):(n=e[0],t=e[1],r=e[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=n;for(;i<t;)o.push(i),i+=r||1;return o}function pe(e){let n=m(e),t,r,o;for(t=n.length;t;t-=1)r=s(t),o=n[t-1],n[t-1]=n[r],n[r]=o;return n}function be(e,n){return e<=0?[[],[...n]]:e>n.length?[[...n],[]]:[n.slice(0,e),n.slice(e)]}function de(e){return e.slice(1)}function xe(e,n){return e<=0?[]:n.slice(0,e)}function Te(e){return e?Array.isArray(e)?e:[e]:[]}function j(e){return Array.from(new Set(e))}function O(e){let n=document.createElement("textarea");n.value=e??"",n.style.position="absolute",n.style.opacity="0",document.body.appendChild(n),n.select(),document.execCommand("copy"),n.remove()}function he(e){p()&&(window.navigator&&"clipboard"in window.navigator?navigator.clipboard.writeText(e):O(e))}function we({to:e,offset:n=0,duration:t=1e3,container:r=null}){let o=b(e)?document.querySelector(e):e,i=b(r)?document.querySelector(r):r,u=i?.scrollTop||window?.pageYOffset||0,d=(w(o)?o:N(o,u))+n,k=Date.now();function x(){let T=Date.now()-k,g=T<t,y=g?C(u,d,T,t):d;g&&requestAnimationFrame(x),i?i.scrollTop=y:window.scrollTo(0,y)}x()}function A(e){return e<.5?4*Math.pow(e,3):(e-1)*(2*e-2)*(2*e-2)+1}function C(e,n,t,r){return e+(n-e)*A(t/r)}function N(e,n){return e.nodeName==="HTML"?-n:e.getBoundingClientRect().top+n}function je(e,n){n<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),e(...r)},n)}}function ke(e){let n={};return function(...t){let r=JSON.stringify(t);if(r in n)return n[r];let o=e(...t);return n[r]=o,o}}function Oe(e){let n=!1;return(...t)=>{n||(e(...t),n=!0)}}function Ae(e,n){n<0&&console.warn("[tsu] warning: a throttle limit less than 0ms will be treated as 0ms.");let t=!1;return function(...r){t||(e(...r),t=!0,setTimeout(()=>{t=!1},n))}}function U(...e){let n={};for(let t=0;t<e.length;t++){let r=e[t],o=Object.keys(r);for(let i=0;i<o.length;i++){let u=o[i];l(n[u])&&l(r[u])?n[u]=j(n[u].concat(r[u])):a(n[u])&&a(r[u])?n[u]=U(n[u],r[u]):n[u]=r[u]}}return n}function Me(e,n=!1,t=" "){return n?e.split(t).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(t):e.charAt(0).toUpperCase()+e.slice(1)}function Se(e){return e.split("")}function Fe(e){return e.trim().length===0}function Ie(e){return e.length===0}function Le(e,n,t){return n<0||n>e.length-1?e:e.slice(0,n)+t+e.slice(n+1)}function qe(e,n){return n<=0?["",e]:n>e.length?[e,""]:[e.slice(0,n),e.slice(n)]}function Re(e){let n=/-(\w)/g;return e.replace(n,(t,r)=>r?r.toUpperCase():"")}function Ve(e){let n=/\B([A-Z])/g;return e.replace(n,"-$1").toLowerCase()}function De(e){return e.length?Number(e.replace(/[#£€$,%]/g,"")):NaN}function Be(e){let t=["st","nd","rd"][(e/10%10^1&&e%10)-1]||"th";return`${e}${t}`}function Pe(e,n,t="..."){return n<=0?t:e.slice(0,n)+t}export{Me as capitalise,E as ceil,Se as chars,M as clamp,m as clone,he as copyToClipboard,je as debounce,U as deepMerge,ue as drop,S as floor,le as groupsOf,se as head,ce as init,l as isArray,Fe as isBlank,X as isBoolean,p as isBrowser,H as isDefined,Ie as isEmpty,_ as isEmptyArray,$ as isEmptyObject,F as isEven,z as isFunction,c as isNull,w as isNumber,a as isObject,f as isObjectLike,I as isOdd,b as isString,J as isTouchDevice,K as isUndefined,Y as isWindow,ae as last,L as max,ke as memoize,q as min,ee as noop,Oe as once,fe as partition,R as product,V as randomChance,s as randomNumber,me as range,Le as replaceChar,D as round,we as scroll,pe as shuffle,ne as sleep,be as splitAt,qe as splitStrAt,B as sum,de as tail,xe as take,Ae as throttle,Te as toArray,Re as toCamel,Ve as toKebab,De as toNumber,Be as toOrdinal,P as toRomanNumerals,Pe as truncate,j as uniq,te as uuid};
|