tsu 0.1.0 → 0.2.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 d=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var B=(e,r)=>{for(var n in r)d(e,n,{get:r[n],enumerable:!0})},D=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of R(r))!L.call(e,t)&&t!==n&&d(e,t,{get:()=>r[t],enumerable:!(o=U(r,t))||o.enumerable});return e};var q=e=>D(d({},"__esModule",{value:!0}),e);var _e={};B(_e,{average:()=>G,capitalise:()=>A,capitalize:()=>Le,ceil:()=>ee,chars:()=>Be,clamp:()=>c,clone:()=>a,copyToClipboard:()=>ve,debounce:()=>Oe,drop:()=>H,es:()=>ce,floor:()=>re,groups:()=>I,head:()=>P,init:()=>W,isArray:()=>m,isBlank:()=>De,isBoolean:()=>z,isBrowser:()=>l,isDefined:()=>_,isEmpty:()=>qe,isEmptyArray:()=>V,isEmptyObject:()=>J,isEven:()=>ne,isFunction:()=>g,isNull:()=>s,isNumber:()=>y,isObject:()=>T,isObjectLike:()=>p,isOdd:()=>oe,isString:()=>b,isTouchDevice:()=>Y,isUndefined:()=>Z,isWindow:()=>f,ks:()=>ae,last:()=>$,max:()=>te,memoise:()=>C,memoize:()=>Ae,min:()=>ie,noop:()=>Se,omit:()=>pe,once:()=>Ne,partition:()=>K,product:()=>ue,randomChance:()=>fe,randomNumber:()=>u,range:()=>X,remove:()=>Q,repeat:()=>Me,replaceChar:()=>He,round:()=>me,scroll:()=>Ce,shuffle:()=>be,sleep:()=>Ue,splitArray:()=>de,splitString:()=>Ie,sum:()=>h,tail:()=>Te,take:()=>ge,throttle:()=>Fe,toArray:()=>ye,toCamel:()=>Pe,toDp:()=>le,toKebab:()=>We,toNumber:()=>se,toOrdinal:()=>$e,toRomanNumerals:()=>Ke,truncate:()=>Xe,unchars:()=>ze,uniq:()=>he,uuid:()=>Re,vs:()=>xe});module.exports=q(_e);function H(e,r){return r<=0?[...e]:e.slice(r)}function I(e,r){if(r<=0)throw new Error("[tsu] Invalid group size. Is it greater than 0?");if(r>=e.length)return[[...e]];let n=[];for(let o=0;o<e.length;o+=r)n.push(e.slice(o,o+r));return n}function P(e){return e[0]}function W(e){return e.slice(0,e.length-1)}function $(e){return e[e.length-1]}function K(e,r){let n=[],o=[];for(let t=0;t<e.length;t++){let i=e[t];r(i,t,e)?n.push(i):o.push(i)}return[n,o]}function X(...e){let r,n,o;e.length===1?(n=e[0],r=0,o=1):(r=e[0],n=e[1],o=e[2]||1),o<=0&&(console.warn("[tsu] warning: a step less than or equal to 0 will be set to 1."),o=1);let t=[],i=r;for(;i<n;)t.push(i),i+=o||1;return t}function m(e){return Array.isArray(e)}function z(e){return typeof e=="boolean"}function l(){return typeof window<"u"}function _(e){return typeof e<"u"}function V(e){return m(e)&&e.length===0}function J(e){if(!T(e))return!1;for(let r in e)return!1;return!0}function g(e){return typeof e=="function"}function s(e){return Object.prototype.toString.call(e)==="[object Null]"}function y(e){return typeof e=="number"}function T(e){return Object.prototype.toString.call(e)==="[object Object]"}function p(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 f(e){return l()&&Object.prototype.toString.call(e)==="[object Window]"}function Q(e,r){let n=g(r)?r:t=>t===r,o=e.findIndex(n);return o!==-1?[...e.slice(0,o),...e.slice(o+1)]:e}function G(e){return e.length<1?0:h(e)/e.length}function ee(e,r=1){let n=e/r;return Math.ceil(n)*r}function c(e,r,n){return Math.min(n,Math.max(r,e))}function re(e,r=1){let n=e/r;return Math.floor(n)*r}function ne(e){return e%2===0}function oe(e){return e%2!==0}function te(...e){let r;return e.length===1&&Array.isArray(e[0])?r=e[0]:r=e,Math.max(...r)}function ie(...e){let r;return e.length===1&&Array.isArray(e[0])?r=e[0]:r=e,Math.min(...r)}function ue(e){if(e.length<1)return 0;let r=1;for(let n=0;n<e.length;n++)r*=e[n];return r}function u(...e){let r,n;return e.length===1?(r=0,n=e[0]):(r=e[0],n=e[1]),Math.floor(Math.random()*(n-r))+r}function fe(e){return u(e)===0}function me(e,r=1){let n=e/r;return Math.round(n)*r}function h(e){let r=0;for(let n=0;n<e.length;n++)r+=e[n];return r}function le(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 n=c(r,0,100);return Number(e.toFixed(n))}function se(e,r=[]){if(!e.length)return NaN;let n=["#","\xA3","\u20AC","$","%",",",...r],o=new RegExp(`[${n.join("")}]`,"g");return Number(e.replace(o,""))}function a(e){if(m(e)){let r=[];for(let n=0;n<e.length;n++)p(e[n])&&!s(e[n])?r[n]=a(e[n]):r[n]=e[n];return r}if(p(e)&&!s(e)){let r={};for(let n in e)p(e[n])&&!s(e[n])?r[n]=a(e[n]):r[n]=e[n];return r}return e}function pe(e,r){let n={...e};for(let o of r)delete n[o];return n}function ce(e){return Object.entries(e)}function ae(e){return Object.keys(e)}function xe(e){return Object.values(e)}function be(e){let r=a(e),n,o,t;for(n=r.length;n;n-=1)o=u(n),t=r[n-1],r[n-1]=r[o],r[o]=t;return r}function de(e,r){return r<=0?[[],[...e]]:r>e.length?[[...e],[]]:[e.slice(0,r),e.slice(r)]}function Te(e){return e.slice(1)}function ge(e,r){return r<=0?[]:e.slice(0,r)}function ye(e){return e?Array.isArray(e)?e:[e]:[]}function he(e){return Array.from(new Set(e))}function we(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 ve(e){l()&&(window.navigator&&"clipboard"in window.navigator?navigator.clipboard.writeText(e):we(e))}function je(e){return e<.5?4*Math.pow(e,3):(e-1)*(2*e-2)*(2*e-2)+1}function ke(e,r,n,o){return e+(r-e)*je(n/o)}function Ee(e,r,n){let o;return y(e)?o=e:f(n)?o=e.getBoundingClientRect().top+r:o=e.getBoundingClientRect().top+r-n.getBoundingClientRect().top,o}function Ce({to:e,offset:r=0,duration:n=1e3,container:o=null}){let t=b(e)?document.querySelector(e):e,i=b(o)?document.querySelector(o):o||window,x=f(i)?window.pageYOffset||document.documentElement.scrollTop:i.scrollTop||0,M=f(i)?document.documentElement.scrollHeight-window.innerHeight:i.scrollHeight-i.clientHeight,F=Ee(t,x,i)+r,w=c(F,0,M),S=Date.now();function v(){let j=Date.now()-S,k=j<n,E=k?ke(x,w,j,n):w;k&&requestAnimationFrame(v),f(i)?window.scrollTo(0,E):i instanceof HTMLElement&&(i.scrollTop=E)}v()}function Oe(e,r){r<0&&console.warn("[tsu] warning: debounce delays less than 0 will be set to 0.");let n;return function(...o){clearTimeout(n),n=setTimeout(()=>{clearTimeout(n),e(...o)},r)}}function C(e){let r={};return function(...n){let o=JSON.stringify(n);if(o in r)return r[o];let t=e(...n);return r[o]=t,t}}var Ae=C;function Ne(e){let r=!1;return(...n)=>{r||(e(...n),r=!0)}}function Me(e,r){if(!(r<=0))for(let n=0;n<r;n++)e(n)}function Fe(e,r){r<0&&console.warn("[tsu] warning: throttle limits less than 0 will be set to 0.");let n=!1;return function(...o){n||(e(...o),n=!0,setTimeout(()=>{n=!1},r))}}function Se(){}async function Ue(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 Re(e=16){let r=O.length,n=e,o="";for(;n--;)o+=O[u(r)];return o}function A(e,r=!1,n=" "){return r?e.split(n).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(n):e.charAt(0).toUpperCase()+e.slice(1)}var Le=A;function Be(e){return e.split("")}function De(e){return e.trim().length===0}function qe(e){return e.length===0}function He(e,r,n){return r<0||r>e.length-1?e:e.slice(0,r)+n+e.slice(r+1)}function Ie(e,r){return r<=0?["",e]:r>e.length?[e,""]:[e.slice(0,r),e.slice(r)]}function Pe(e){let r=/-(\w)/g;return e.replace(r,(n,o)=>o?o.toUpperCase():"")}function We(e){let r=/\B([A-Z])/g;return e.replace(r,"-$1").toLowerCase()}function $e(e){let n=["st","nd","rd"][(Math.abs(e)/10%10^1&&Math.abs(e)%10)-1]||"th";return`${e}${n}`}var N={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 Ke(e,r=!1){let n=e,o="",t=Object.keys(N).map(Number).sort((i,x)=>x-i);for(let i of t)for(;n>=i;)o+=N[i],n-=i;return r?o.toLowerCase():o}function Xe(e,r,n="..."){return r<=0?n:e.slice(0,r)+n}function ze(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,omit,once,partition,product,randomChance,randomNumber,range,remove,repeat,replaceChar,round,scroll,shuffle,sleep,splitArray,splitString,sum,tail,take,throttle,toArray,toCamel,toDp,toKebab,toNumber,toOrdinal,toRomanNumerals,truncate,unchars,uniq,uuid,vs});
1
+ "use strict";var d=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var B=(e,r)=>{for(var n in r)d(e,n,{get:r[n],enumerable:!0})},D=(e,r,n,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of R(r))!L.call(e,t)&&t!==n&&d(e,t,{get:()=>r[t],enumerable:!(o=U(r,t))||o.enumerable});return e};var q=e=>D(d({},"__esModule",{value:!0}),e);var _e={};B(_e,{average:()=>G,capitalise:()=>C,capitalize:()=>Le,ceil:()=>ee,chars:()=>Be,clamp:()=>c,clone:()=>a,copyToClipboard:()=>ve,debounce:()=>Ae,drop:()=>H,es:()=>ce,floor:()=>re,groups:()=>I,head:()=>P,init:()=>W,isArray:()=>l,isBlank:()=>De,isBoolean:()=>z,isBrowser:()=>m,isDefined:()=>_,isEmpty:()=>qe,isEmptyArray:()=>V,isEmptyObject:()=>J,isEven:()=>ne,isFunction:()=>g,isNull:()=>s,isNumber:()=>y,isObject:()=>T,isObjectLike:()=>p,isOdd:()=>oe,isString:()=>b,isTouchDevice:()=>Y,isUndefined:()=>Z,isWindow:()=>f,ks:()=>ae,last:()=>$,max:()=>te,memoise:()=>O,memoize:()=>Ce,min:()=>ie,noop:()=>Se,omit:()=>pe,once:()=>Me,partition:()=>K,product:()=>ue,random:()=>u,range:()=>X,remove:()=>Q,repeat:()=>Fe,replaceChar:()=>He,roll:()=>fe,round:()=>le,scroll:()=>Oe,shuffle:()=>be,sleep:()=>Ue,splitArray:()=>de,splitString:()=>Ie,sum:()=>h,tail:()=>Te,take:()=>ge,throttle:()=>Ne,toArray:()=>ye,toCamel:()=>Pe,toDp:()=>me,toKebab:()=>We,toNumber:()=>se,toOrdinal:()=>$e,toRomanNumerals:()=>Ke,truncate:()=>Xe,unchars:()=>ze,uniq:()=>he,uuid:()=>Re,vs:()=>xe});module.exports=q(_e);function H(e,r){return r<=0?[...e]:e.slice(r)}function I(e,r){if(r<=0)throw new Error("[tsu] Invalid group size. Is it greater than 0?");if(r>=e.length)return[[...e]];let n=[];for(let o=0;o<e.length;o+=r)n.push(e.slice(o,o+r));return n}function P(e){return e[0]}function W(e){return e.slice(0,e.length-1)}function $(e){return e[e.length-1]}function K(e,r){let n=[],o=[];for(let t=0;t<e.length;t++){let i=e[t];r(i,t,e)?n.push(i):o.push(i)}return[n,o]}function X(...e){let r,n,o;e.length===1?(n=e[0],r=0,o=1):(r=e[0],n=e[1],o=e[2]||1),o<=0&&(console.warn("[tsu] warning: a step less than or equal to 0 will be set to 1."),o=1);let t=[],i=r;for(;i<n;)t.push(i),i+=o||1;return t}function l(e){return Array.isArray(e)}function z(e){return typeof e=="boolean"}function m(){return typeof window<"u"}function _(e){return typeof e<"u"}function V(e){return l(e)&&e.length===0}function J(e){if(!T(e))return!1;for(let r in e)return!1;return!0}function g(e){return typeof e=="function"}function s(e){return Object.prototype.toString.call(e)==="[object Null]"}function y(e){return typeof e=="number"}function T(e){return Object.prototype.toString.call(e)==="[object Object]"}function p(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 f(e){return m()&&Object.prototype.toString.call(e)==="[object Window]"}function Q(e,r){let n=g(r)?r:t=>t===r,o=e.findIndex(n);return o!==-1?[...e.slice(0,o),...e.slice(o+1)]:e}function G(e){return e.length<1?0:h(e)/e.length}function ee(e,r=1){let n=e/r;return Math.ceil(n)*r}function c(e,r,n){return Math.min(n,Math.max(r,e))}function re(e,r=1){let n=e/r;return Math.floor(n)*r}function ne(e){return e%2===0}function oe(e){return e%2!==0}function te(...e){let r;return e.length===1&&Array.isArray(e[0])?r=e[0]:r=e,Math.max(...r)}function ie(...e){let r;return e.length===1&&Array.isArray(e[0])?r=e[0]:r=e,Math.min(...r)}function ue(e){if(e.length<1)return 0;let r=1;for(let n=0;n<e.length;n++)r*=e[n];return r}function u(...e){let r,n;return e.length===1?(r=0,n=e[0]):(r=e[0],n=e[1]),Math.floor(Math.random()*(n-r))+r}function fe(e){return u(e)===0}function le(e,r=1){let n=e/r;return Math.round(n)*r}function h(e){let r=0;for(let n=0;n<e.length;n++)r+=e[n];return r}function me(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 n=c(r,0,100);return Number(e.toFixed(n))}function se(e,r=[]){if(!e.length)return NaN;let n=["#","\xA3","\u20AC","$","%",",",...r],o=new RegExp(`[${n.join("")}]`,"g");return Number(e.replace(o,""))}function a(e){if(l(e)){let r=[];for(let n=0;n<e.length;n++)p(e[n])&&!s(e[n])?r[n]=a(e[n]):r[n]=e[n];return r}if(p(e)&&!s(e)){let r={};for(let n in e)p(e[n])&&!s(e[n])?r[n]=a(e[n]):r[n]=e[n];return r}return e}function pe(e,r){let n={...e};for(let o of r)delete n[o];return n}function ce(e){return Object.entries(e)}function ae(e){return Object.keys(e)}function xe(e){return Object.values(e)}function be(e){let r=a(e),n,o,t;for(n=r.length;n;n-=1)o=u(n),t=r[n-1],r[n-1]=r[o],r[o]=t;return r}function de(e,r){return r<=0?[[],[...e]]:r>e.length?[[...e],[]]:[e.slice(0,r),e.slice(r)]}function Te(e){return e.slice(1)}function ge(e,r){return r<=0?[]:e.slice(0,r)}function ye(e){return e?Array.isArray(e)?e:[e]:[]}function he(e){return Array.from(new Set(e))}function we(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 ve(e){m()&&(window.navigator&&"clipboard"in window.navigator?navigator.clipboard.writeText(e):we(e))}function je(e){return e<.5?4*Math.pow(e,3):(e-1)*(2*e-2)*(2*e-2)+1}function ke(e,r,n,o){return e+(r-e)*je(n/o)}function Ee(e,r,n){let o;return y(e)?o=e:f(n)?o=e.getBoundingClientRect().top+r:o=e.getBoundingClientRect().top+r-n.getBoundingClientRect().top,o}function Oe({to:e,offset:r=0,duration:n=1e3,container:o=null}){let t=b(e)?document.querySelector(e):e,i=b(o)?document.querySelector(o):o||window,x=f(i)?window.pageYOffset||document.documentElement.scrollTop:i.scrollTop||0,F=f(i)?document.documentElement.scrollHeight-window.innerHeight:i.scrollHeight-i.clientHeight,N=Ee(t,x,i)+r,w=c(N,0,F),S=Date.now();function v(){let j=Date.now()-S,k=j<n,E=k?ke(x,w,j,n):w;k&&requestAnimationFrame(v),f(i)?window.scrollTo(0,E):i instanceof HTMLElement&&(i.scrollTop=E)}v()}function Ae(e,r){r<0&&console.warn("[tsu] warning: debounce delays less than 0 will be set to 0.");let n;return function(...o){clearTimeout(n),n=setTimeout(()=>{clearTimeout(n),e(...o)},r)}}function O(e){let r={};return function(...n){let o=JSON.stringify(n);if(o in r)return r[o];let t=e(...n);return r[o]=t,t}}var Ce=O;function Me(e){let r=!1;return(...n)=>{r||(e(...n),r=!0)}}function Fe(e,r){if(!(r<=0))for(let n=0;n<r;n++)e(n)}function Ne(e,r){r<0&&console.warn("[tsu] warning: throttle limits less than 0 will be set to 0.");let n=!1;return function(...o){n||(e(...o),n=!0,setTimeout(()=>{n=!1},r))}}function Se(){}async function Ue(e){return e<0&&console.warn("[tsu] warning: sleep durations less than 0 are set to 0."),new Promise(r=>{setTimeout(r,e)})}var A="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function Re(e=16){let r=A.length,n=e,o="";for(;n--;)o+=A[u(r)];return o}function C(e,r=!1,n=" "){return r?e.split(n).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(n):e.charAt(0).toUpperCase()+e.slice(1)}var Le=C;function Be(e){return e.split("")}function De(e){return e.trim().length===0}function qe(e){return e.length===0}function He(e,r,n){return r<0||r>e.length-1?e:e.slice(0,r)+n+e.slice(r+1)}function Ie(e,r){return r<=0?["",e]:r>e.length?[e,""]:[e.slice(0,r),e.slice(r)]}function Pe(e){let r=/-(\w)/g;return e.replace(r,(n,o)=>o?o.toUpperCase():"")}function We(e){let r=/\B([A-Z])/g;return e.replace(r,"-$1").toLowerCase()}function $e(e){let n=["st","nd","rd"][(Math.abs(e)/10%10^1&&Math.abs(e)%10)-1]||"th";return`${e}${n}`}var M={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 Ke(e,r=!1){let n=e,o="",t=Object.keys(M).map(Number).sort((i,x)=>x-i);for(let i of t)for(;n>=i;)o+=M[i],n-=i;return r?o.toLowerCase():o}function Xe(e,r,n="..."){return r<=0?n:e.slice(0,r)+n}function ze(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,omit,once,partition,product,random,range,remove,repeat,replaceChar,roll,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
@@ -411,14 +411,6 @@ declare function min(...ns: number[] | [number[]]): number;
411
411
  */
412
412
  declare function product(ns: readonly number[]): number;
413
413
 
414
- /**
415
- * Rolls an n-sided die.
416
- *
417
- * @param n - The number of sides on the die.
418
- * @returns If the die roll was 0.
419
- */
420
- declare function randomChance(n: number): boolean;
421
-
422
414
  /**
423
415
  * Generates a random integer between bounds.
424
416
  *
@@ -426,8 +418,16 @@ declare function randomChance(n: number): boolean;
426
418
  * @param max - The exclusive maximum bound.
427
419
  * @returns The random integer.
428
420
  */
429
- declare function randomNumber(max: number): number;
430
- declare function randomNumber(min: number, max: number): number;
421
+ declare function random(max: number): number;
422
+ declare function random(min: number, max: number): number;
423
+
424
+ /**
425
+ * Rolls an n-sided die.
426
+ *
427
+ * @param n - The number of sides on the die.
428
+ * @returns If the die roll was 0.
429
+ */
430
+ declare function roll(n: number): boolean;
431
431
 
432
432
  /**
433
433
  * Rounds a number to the nearest multiple of the specified factor.
@@ -610,4 +610,4 @@ declare function truncate(str: string, length: number, suffix?: string): string;
610
610
  */
611
611
  declare function unchars(chars: string[]): string;
612
612
 
613
- 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, omit, once, partition, product, randomChance, randomNumber, range, remove, repeat, replaceChar, round, scroll, shuffle, sleep, splitArray, splitString, sum, tail, take, throttle, toArray, toCamel, toDp, toKebab, toNumber, toOrdinal, toRomanNumerals, truncate, unchars, uniq, uuid, vs };
613
+ 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, omit, once, partition, product, random, range, remove, repeat, replaceChar, roll, 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
@@ -411,14 +411,6 @@ declare function min(...ns: number[] | [number[]]): number;
411
411
  */
412
412
  declare function product(ns: readonly number[]): number;
413
413
 
414
- /**
415
- * Rolls an n-sided die.
416
- *
417
- * @param n - The number of sides on the die.
418
- * @returns If the die roll was 0.
419
- */
420
- declare function randomChance(n: number): boolean;
421
-
422
414
  /**
423
415
  * Generates a random integer between bounds.
424
416
  *
@@ -426,8 +418,16 @@ declare function randomChance(n: number): boolean;
426
418
  * @param max - The exclusive maximum bound.
427
419
  * @returns The random integer.
428
420
  */
429
- declare function randomNumber(max: number): number;
430
- declare function randomNumber(min: number, max: number): number;
421
+ declare function random(max: number): number;
422
+ declare function random(min: number, max: number): number;
423
+
424
+ /**
425
+ * Rolls an n-sided die.
426
+ *
427
+ * @param n - The number of sides on the die.
428
+ * @returns If the die roll was 0.
429
+ */
430
+ declare function roll(n: number): boolean;
431
431
 
432
432
  /**
433
433
  * Rounds a number to the nearest multiple of the specified factor.
@@ -610,4 +610,4 @@ declare function truncate(str: string, length: number, suffix?: string): string;
610
610
  */
611
611
  declare function unchars(chars: string[]): string;
612
612
 
613
- 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, omit, once, partition, product, randomChance, randomNumber, range, remove, repeat, replaceChar, round, scroll, shuffle, sleep, splitArray, splitString, sum, tail, take, throttle, toArray, toCamel, toDp, toKebab, toNumber, toOrdinal, toRomanNumerals, truncate, unchars, uniq, uuid, vs };
613
+ 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, omit, once, partition, product, random, range, remove, repeat, replaceChar, roll, 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 B(e,r){return r<=0?[...e]:e.slice(r)}function q(e,r){if(r<=0)throw new Error("[tsu] Invalid group size. Is it greater than 0?");if(r>=e.length)return[[...e]];let n=[];for(let o=0;o<e.length;o+=r)n.push(e.slice(o,o+r));return n}function I(e){return e[0]}function W(e){return e.slice(0,e.length-1)}function K(e){return e[e.length-1]}function z(e,r){let n=[],o=[];for(let i=0;i<e.length;i++){let t=e[i];r(t,i,e)?n.push(t):o.push(t)}return[n,o]}function V(...e){let r,n,o;e.length===1?(n=e[0],r=0,o=1):(r=e[0],n=e[1],o=e[2]||1),o<=0&&(console.warn("[tsu] warning: a step less than or equal to 0 will be set to 1."),o=1);let i=[],t=r;for(;t<n;)i.push(t),t+=o||1;return i}function l(e){return Array.isArray(e)}function Z(e){return typeof e=="boolean"}function s(){return typeof window<"u"}function ee(e){return typeof e<"u"}function oe(e){return l(e)&&e.length===0}function ue(e){if(!w(e))return!1;for(let r in e)return!1;return!0}function v(e){return typeof e=="function"}function p(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 c(e){return typeof e=="object"}function b(e){return typeof e=="string"}function xe(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function de(e){return typeof e>"u"}function f(e){return s()&&Object.prototype.toString.call(e)==="[object Window]"}function De(e,r){let n=v(r)?r:i=>i===r,o=e.findIndex(n);return o!==-1?[...e.slice(0,o),...e.slice(o+1)]:e}function Ie(e){return e.length<1?0:k(e)/e.length}function We(e,r=1){let n=e/r;return Math.ceil(n)*r}function a(e,r,n){return Math.min(n,Math.max(r,e))}function Xe(e,r=1){let n=e/r;return Math.floor(n)*r}function _e(e){return e%2===0}function Je(e){return e%2!==0}function Ze(...e){let r;return e.length===1&&Array.isArray(e[0])?r=e[0]:r=e,Math.max(...r)}function Ge(...e){let r;return e.length===1&&Array.isArray(e[0])?r=e[0]:r=e,Math.min(...r)}function rr(e){if(e.length<1)return 0;let r=1;for(let n=0;n<e.length;n++)r*=e[n];return r}function u(...e){let r,n;return e.length===1?(r=0,n=e[0]):(r=e[0],n=e[1]),Math.floor(Math.random()*(n-r))+r}function ir(e){return u(e)===0}function fr(e,r=1){let n=e/r;return Math.round(n)*r}function k(e){let r=0;for(let n=0;n<e.length;n++)r+=e[n];return r}function pr(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 n=a(r,0,100);return Number(e.toFixed(n))}function ar(e,r=[]){if(!e.length)return NaN;let n=["#","\xA3","\u20AC","$","%",",",...r],o=new RegExp(`[${n.join("")}]`,"g");return Number(e.replace(o,""))}function x(e){if(l(e)){let r=[];for(let n=0;n<e.length;n++)c(e[n])&&!p(e[n])?r[n]=x(e[n]):r[n]=e[n];return r}if(c(e)&&!p(e)){let r={};for(let n in e)c(e[n])&&!p(e[n])?r[n]=x(e[n]):r[n]=e[n];return r}return e}function Ur(e,r){let n={...e};for(let o of r)delete n[o];return n}function Lr(e){return Object.entries(e)}function Dr(e){return Object.keys(e)}function Hr(e){return Object.values(e)}function Jr(e){let r=x(e),n,o,i;for(n=r.length;n;n-=1)o=u(n),i=r[n-1],r[n-1]=r[o],r[o]=i;return r}function Zr(e,r){return r<=0?[[],[...e]]:r>e.length?[[...e],[]]:[e.slice(0,r),e.slice(r)]}function Gr(e){return e.slice(1)}function rn(e,r){return r<=0?[]:e.slice(0,r)}function on(e){return e?Array.isArray(e)?e:[e]:[]}function un(e){return Array.from(new Set(e))}function M(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 kn(e){s()&&(window.navigator&&"clipboard"in window.navigator?navigator.clipboard.writeText(e):M(e))}function F(e){return e<.5?4*Math.pow(e,3):(e-1)*(2*e-2)*(2*e-2)+1}function S(e,r,n,o){return e+(r-e)*F(n/o)}function U(e,r,n){let o;return j(e)?o=e:f(n)?o=e.getBoundingClientRect().top+r:o=e.getBoundingClientRect().top+r-n.getBoundingClientRect().top,o}function An({to:e,offset:r=0,duration:n=1e3,container:o=null}){let i=b(e)?document.querySelector(e):e,t=b(o)?document.querySelector(o):o||window,m=f(t)?window.pageYOffset||document.documentElement.scrollTop:t.scrollTop||0,O=f(t)?document.documentElement.scrollHeight-window.innerHeight:t.scrollHeight-t.clientHeight,A=U(i,m,t)+r,d=a(A,0,O),N=Date.now();function T(){let g=Date.now()-N,y=g<n,h=y?S(m,d,g,n):d;y&&requestAnimationFrame(T),f(t)?window.scrollTo(0,h):t instanceof HTMLElement&&(t.scrollTop=h)}T()}function Un(e,r){r<0&&console.warn("[tsu] warning: debounce delays less than 0 will be set to 0.");let n;return function(...o){clearTimeout(n),n=setTimeout(()=>{clearTimeout(n),e(...o)},r)}}function R(e){let r={};return function(...n){let o=JSON.stringify(n);if(o in r)return r[o];let i=e(...n);return r[o]=i,i}}var Ln=R;function Dn(e){let r=!1;return(...n)=>{r||(e(...n),r=!0)}}function Hn(e,r){if(!(r<=0))for(let n=0;n<r;n++)e(n)}function Pn(e,r){r<0&&console.warn("[tsu] warning: throttle limits less than 0 will be set to 0.");let n=!1;return function(...o){n||(e(...o),n=!0,setTimeout(()=>{n=!1},r))}}function Jn(){}async function Zn(e){return e<0&&console.warn("[tsu] warning: sleep durations less than 0 are set to 0."),new Promise(r=>{setTimeout(r,e)})}var E="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function eo(e=16){let r=E.length,n=e,o="";for(;n--;)o+=E[u(r)];return o}function L(e,r=!1,n=" "){return r?e.split(n).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(n):e.charAt(0).toUpperCase()+e.slice(1)}var uo=L;function mo(e){return e.split("")}function so(e){return e.trim().length===0}function co(e){return e.length===0}function xo(e,r,n){return r<0||r>e.length-1?e:e.slice(0,r)+n+e.slice(r+1)}function To(e,r){return r<=0?["",e]:r>e.length?[e,""]:[e.slice(0,r),e.slice(r)]}function yo(e){let r=/-(\w)/g;return e.replace(r,(n,o)=>o?o.toUpperCase():"")}function wo(e){let r=/\B([A-Z])/g;return e.replace(r,"-$1").toLowerCase()}function jo(e){let n=["st","nd","rd"][(Math.abs(e)/10%10^1&&Math.abs(e)%10)-1]||"th";return`${e}${n}`}var C={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 Eo(e,r=!1){let n=e,o="",i=Object.keys(C).map(Number).sort((t,m)=>m-t);for(let t of i)for(;n>=t;)o+=C[t],n-=t;return r?o.toLowerCase():o}function Oo(e,r,n="..."){return r<=0?n:e.slice(0,r)+n}function No(e){return e.join("")}export{Ie as average,L as capitalise,uo as capitalize,We as ceil,mo as chars,a as clamp,x as clone,kn as copyToClipboard,Un as debounce,B as drop,Lr as es,Xe as floor,q as groups,I as head,W as init,l as isArray,so as isBlank,Z as isBoolean,s as isBrowser,ee as isDefined,co as isEmpty,oe as isEmptyArray,ue as isEmptyObject,_e as isEven,v as isFunction,p as isNull,j as isNumber,w as isObject,c as isObjectLike,Je as isOdd,b as isString,xe as isTouchDevice,de as isUndefined,f as isWindow,Dr as ks,K as last,Ze as max,R as memoise,Ln as memoize,Ge as min,Jn as noop,Ur as omit,Dn as once,z as partition,rr as product,ir as randomChance,u as randomNumber,V as range,De as remove,Hn as repeat,xo as replaceChar,fr as round,An as scroll,Jr as shuffle,Zn as sleep,Zr as splitArray,To as splitString,k as sum,Gr as tail,rn as take,Pn as throttle,on as toArray,yo as toCamel,pr as toDp,wo as toKebab,ar as toNumber,jo as toOrdinal,Eo as toRomanNumerals,Oo as truncate,No as unchars,un as uniq,eo as uuid,Hr as vs};
1
+ function B(e,r){return r<=0?[...e]:e.slice(r)}function q(e,r){if(r<=0)throw new Error("[tsu] Invalid group size. Is it greater than 0?");if(r>=e.length)return[[...e]];let n=[];for(let o=0;o<e.length;o+=r)n.push(e.slice(o,o+r));return n}function I(e){return e[0]}function W(e){return e.slice(0,e.length-1)}function K(e){return e[e.length-1]}function z(e,r){let n=[],o=[];for(let i=0;i<e.length;i++){let t=e[i];r(t,i,e)?n.push(t):o.push(t)}return[n,o]}function V(...e){let r,n,o;e.length===1?(n=e[0],r=0,o=1):(r=e[0],n=e[1],o=e[2]||1),o<=0&&(console.warn("[tsu] warning: a step less than or equal to 0 will be set to 1."),o=1);let i=[],t=r;for(;t<n;)i.push(t),t+=o||1;return i}function m(e){return Array.isArray(e)}function Z(e){return typeof e=="boolean"}function s(){return typeof window<"u"}function ee(e){return typeof e<"u"}function oe(e){return m(e)&&e.length===0}function ue(e){if(!w(e))return!1;for(let r in e)return!1;return!0}function v(e){return typeof e=="function"}function p(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 c(e){return typeof e=="object"}function b(e){return typeof e=="string"}function xe(){return"ontouchstart"in window||navigator.maxTouchPoints>0}function de(e){return typeof e>"u"}function f(e){return s()&&Object.prototype.toString.call(e)==="[object Window]"}function De(e,r){let n=v(r)?r:i=>i===r,o=e.findIndex(n);return o!==-1?[...e.slice(0,o),...e.slice(o+1)]:e}function Ie(e){return e.length<1?0:k(e)/e.length}function We(e,r=1){let n=e/r;return Math.ceil(n)*r}function a(e,r,n){return Math.min(n,Math.max(r,e))}function Xe(e,r=1){let n=e/r;return Math.floor(n)*r}function _e(e){return e%2===0}function Je(e){return e%2!==0}function Ze(...e){let r;return e.length===1&&Array.isArray(e[0])?r=e[0]:r=e,Math.max(...r)}function Ge(...e){let r;return e.length===1&&Array.isArray(e[0])?r=e[0]:r=e,Math.min(...r)}function rr(e){if(e.length<1)return 0;let r=1;for(let n=0;n<e.length;n++)r*=e[n];return r}function u(...e){let r,n;return e.length===1?(r=0,n=e[0]):(r=e[0],n=e[1]),Math.floor(Math.random()*(n-r))+r}function ir(e){return u(e)===0}function fr(e,r=1){let n=e/r;return Math.round(n)*r}function k(e){let r=0;for(let n=0;n<e.length;n++)r+=e[n];return r}function pr(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 n=a(r,0,100);return Number(e.toFixed(n))}function ar(e,r=[]){if(!e.length)return NaN;let n=["#","\xA3","\u20AC","$","%",",",...r],o=new RegExp(`[${n.join("")}]`,"g");return Number(e.replace(o,""))}function x(e){if(m(e)){let r=[];for(let n=0;n<e.length;n++)c(e[n])&&!p(e[n])?r[n]=x(e[n]):r[n]=e[n];return r}if(c(e)&&!p(e)){let r={};for(let n in e)c(e[n])&&!p(e[n])?r[n]=x(e[n]):r[n]=e[n];return r}return e}function Ur(e,r){let n={...e};for(let o of r)delete n[o];return n}function Lr(e){return Object.entries(e)}function Dr(e){return Object.keys(e)}function Hr(e){return Object.values(e)}function Jr(e){let r=x(e),n,o,i;for(n=r.length;n;n-=1)o=u(n),i=r[n-1],r[n-1]=r[o],r[o]=i;return r}function Zr(e,r){return r<=0?[[],[...e]]:r>e.length?[[...e],[]]:[e.slice(0,r),e.slice(r)]}function Gr(e){return e.slice(1)}function rn(e,r){return r<=0?[]:e.slice(0,r)}function on(e){return e?Array.isArray(e)?e:[e]:[]}function un(e){return Array.from(new Set(e))}function F(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 kn(e){s()&&(window.navigator&&"clipboard"in window.navigator?navigator.clipboard.writeText(e):F(e))}function N(e){return e<.5?4*Math.pow(e,3):(e-1)*(2*e-2)*(2*e-2)+1}function S(e,r,n,o){return e+(r-e)*N(n/o)}function U(e,r,n){let o;return j(e)?o=e:f(n)?o=e.getBoundingClientRect().top+r:o=e.getBoundingClientRect().top+r-n.getBoundingClientRect().top,o}function Cn({to:e,offset:r=0,duration:n=1e3,container:o=null}){let i=b(e)?document.querySelector(e):e,t=b(o)?document.querySelector(o):o||window,l=f(t)?window.pageYOffset||document.documentElement.scrollTop:t.scrollTop||0,A=f(t)?document.documentElement.scrollHeight-window.innerHeight:t.scrollHeight-t.clientHeight,C=U(i,l,t)+r,d=a(C,0,A),M=Date.now();function T(){let g=Date.now()-M,y=g<n,h=y?S(l,d,g,n):d;y&&requestAnimationFrame(T),f(t)?window.scrollTo(0,h):t instanceof HTMLElement&&(t.scrollTop=h)}T()}function Un(e,r){r<0&&console.warn("[tsu] warning: debounce delays less than 0 will be set to 0.");let n;return function(...o){clearTimeout(n),n=setTimeout(()=>{clearTimeout(n),e(...o)},r)}}function R(e){let r={};return function(...n){let o=JSON.stringify(n);if(o in r)return r[o];let i=e(...n);return r[o]=i,i}}var Ln=R;function Dn(e){let r=!1;return(...n)=>{r||(e(...n),r=!0)}}function Hn(e,r){if(!(r<=0))for(let n=0;n<r;n++)e(n)}function Pn(e,r){r<0&&console.warn("[tsu] warning: throttle limits less than 0 will be set to 0.");let n=!1;return function(...o){n||(e(...o),n=!0,setTimeout(()=>{n=!1},r))}}function Jn(){}async function Zn(e){return e<0&&console.warn("[tsu] warning: sleep durations less than 0 are set to 0."),new Promise(r=>{setTimeout(r,e)})}var E="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function eo(e=16){let r=E.length,n=e,o="";for(;n--;)o+=E[u(r)];return o}function L(e,r=!1,n=" "){return r?e.split(n).map(o=>o.charAt(0).toUpperCase()+o.slice(1)).join(n):e.charAt(0).toUpperCase()+e.slice(1)}var uo=L;function lo(e){return e.split("")}function so(e){return e.trim().length===0}function co(e){return e.length===0}function xo(e,r,n){return r<0||r>e.length-1?e:e.slice(0,r)+n+e.slice(r+1)}function To(e,r){return r<=0?["",e]:r>e.length?[e,""]:[e.slice(0,r),e.slice(r)]}function yo(e){let r=/-(\w)/g;return e.replace(r,(n,o)=>o?o.toUpperCase():"")}function wo(e){let r=/\B([A-Z])/g;return e.replace(r,"-$1").toLowerCase()}function jo(e){let n=["st","nd","rd"][(Math.abs(e)/10%10^1&&Math.abs(e)%10)-1]||"th";return`${e}${n}`}var O={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 Eo(e,r=!1){let n=e,o="",i=Object.keys(O).map(Number).sort((t,l)=>l-t);for(let t of i)for(;n>=t;)o+=O[t],n-=t;return r?o.toLowerCase():o}function Ao(e,r,n="..."){return r<=0?n:e.slice(0,r)+n}function Mo(e){return e.join("")}export{Ie as average,L as capitalise,uo as capitalize,We as ceil,lo as chars,a as clamp,x as clone,kn as copyToClipboard,Un as debounce,B as drop,Lr as es,Xe as floor,q as groups,I as head,W as init,m as isArray,so as isBlank,Z as isBoolean,s as isBrowser,ee as isDefined,co as isEmpty,oe as isEmptyArray,ue as isEmptyObject,_e as isEven,v as isFunction,p as isNull,j as isNumber,w as isObject,c as isObjectLike,Je as isOdd,b as isString,xe as isTouchDevice,de as isUndefined,f as isWindow,Dr as ks,K as last,Ze as max,R as memoise,Ln as memoize,Ge as min,Jn as noop,Ur as omit,Dn as once,z as partition,rr as product,u as random,V as range,De as remove,Hn as repeat,xo as replaceChar,ir as roll,fr as round,Cn as scroll,Jr as shuffle,Zn as sleep,Zr as splitArray,To as splitString,k as sum,Gr as tail,rn as take,Pn as throttle,on as toArray,yo as toCamel,pr as toDp,wo as toKebab,ar as toNumber,jo as toOrdinal,Eo as toRomanNumerals,Ao as truncate,Mo as unchars,un as uniq,eo as uuid,Hr as vs};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tsu",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "TypeScript utilities",
6
6
  "license": "MIT",