diff --git a/cdn/radash.esm.js b/cdn/radash.esm.js index d81bc385..726c4f3f 100644 --- a/cdn/radash.esm.js +++ b/cdn/radash.esm.js @@ -801,4 +801,4 @@ const trim = (str, charsToTrim = " ") => { return str.replace(regex, ""); }; -export { alphabetical, assign, boil, callable, camel as camal, camel, capitalize, chain, clone, cluster, compose, counting, dash, debounce, defer, diff, draw, first, flat, fork, get, group, intersects, invert, isArray, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isNumber, isObject, isPrimitive, isString, isSymbol, iterate, last, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, min, objectify, omit, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, select, series, shake, shift, shuffle, sift, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, trim, tryit as try, tryit, uid, unique, upperize, zip, zipToObject }; +export { alphabetical, assign, boil, callable, camel, capitalize, chain, clone, cluster, compose, counting, dash, debounce, defer, diff, draw, first, flat, fork, get, group, intersects, invert, isArray, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isNumber, isObject, isPrimitive, isString, isSymbol, iterate, last, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, min, objectify, omit, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, select, series, shake, shift, shuffle, sift, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, trim, tryit as try, tryit, uid, unique, upperize, zip, zipToObject }; diff --git a/cdn/radash.js b/cdn/radash.js index 415e3d36..175efa60 100644 --- a/cdn/radash.js +++ b/cdn/radash.js @@ -808,7 +808,6 @@ var radash = (function (exports) { exports.assign = assign; exports.boil = boil; exports.callable = callable; - exports.camal = camel; exports.camel = camel; exports.capitalize = capitalize; exports.chain = chain; diff --git a/cdn/radash.min.js b/cdn/radash.min.js index d053c364..4d6d5556 100644 --- a/cdn/radash.min.js +++ b/cdn/radash.min.js @@ -1 +1 @@ -var radash=function(i){"use strict";const O=t=>!!t&&t.constructor===Symbol,C=t=>!!t&&t.constructor===Array,E=t=>!!t&&t.constructor===Object,N=t=>t==null||typeof t!="object"&&typeof t!="function",m=t=>!!(t&&t.constructor&&t.call&&t.apply),L=t=>typeof t=="string"||t instanceof String,D=t=>a(t)&&t%1===0,F=t=>a(t)&&t%1!==0,a=t=>{try{return Number(t)===t}catch{return!1}},_=t=>Object.prototype.toString.call(t)==="[object Date]",R=t=>{if(t===!0||t===!1||t==null)return!0;if(a(t))return t===0;if(_(t))return isNaN(t.getTime());if(m(t)||O(t))return!1;const e=t.length;if(a(e))return e===0;const n=t.size;return a(n)?n===0:Object.keys(t).length===0},$=(t,e)=>{if(Object.is(t,e))return!0;if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.toString()===e.toString();if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;const n=Reflect.ownKeys(t),r=Reflect.ownKeys(e);if(n.length!==r.length)return!1;for(let c=0;ct.reduce((n,r)=>{const c=e(r);return n[c]||(n[c]=[]),n[c].push(r),n},{});function q(...t){return!t||!t.length?[]:new Array(Math.max(...t.map(({length:e})=>e))).fill([]).map((e,n)=>t.map(r=>r[n]))}function I(t,e){if(!t||!t.length)return{};const n=m(e)?e:C(e)?(r,c)=>e[c]:(r,c)=>e;return t.reduce((r,c,s)=>({...r,[c]:n(c,s)}),{})}const w=(t,e)=>!t||(t.length??0)===0?null:t.reduce(e),M=(t,e)=>(t||[]).reduce((n,r)=>n+(e?e(r):r),0),U=(t,e=void 0)=>t?.length>0?t[0]:e,V=(t,e=void 0)=>t?.length>0?t[t.length-1]:e,z=(t,e,n=!1)=>{if(!t)return[];const r=(s,u)=>e(s)-e(u),c=(s,u)=>e(u)-e(s);return t.slice().sort(n===!0?c:r)},K=(t,e,n="asc")=>{if(!t)return[];const r=(s,u)=>`${e(s)}`.localeCompare(e(u)),c=(s,u)=>`${e(u)}`.localeCompare(e(s));return t.slice().sort(n==="desc"?c:r)},J=(t,e)=>t.reduce((n,r)=>{const c=e(r);return{...n,[c]:(n[c]??0)+1}},{}),W=(t,e,n)=>{if(!t)return[];if(!e)return[...t];for(let r=0;rr)=>t.reduce((r,c)=>({...r,[e(c)]:n(c)}),{}),Y=(t,e,n)=>t.reduce((r,c)=>n(c)?[...r,e(c)]:r,[]),G=(t,e)=>{const n=e||(r=>r);return w(t,(r,c)=>n(r)>n(c)?r:c)},H=(t,e)=>{const n=e||(r=>r);return w(t,(r,c)=>n(r){const n=Math.ceil(t.length/e);return new Array(n).fill(null).map((r,c)=>t.slice(c*e,c*e+e))},v=(t,e)=>{const n=t.reduce((r,c)=>{const s=e?e(c):c;return r[s]?r:{...r,[s]:c}},{});return Object.values(n)};function*y(t,e,n=c=>c,r=1){const c=m(n)?n:()=>n,s=e?t:0,u=e??t;for(let o=s;o<=u&&(yield c(o),!(o+r>u));o+=r);}const P=(t,e,n,r)=>Array.from(y(t,e,n,r)),x=t=>t.reduce((e,n)=>[...e,...n],[]),tt=(t,e,n)=>{if(!t||!e)return!1;const r=n??(s=>s),c=e.reduce((s,u)=>({...s,[r(u)]:!0}),{});return t.some(s=>c[r(s)])},S=(t,e)=>t?t.reduce((n,r)=>{const[c,s]=n;return e(r)?[[...c,r],s]:[c,[...s,r]]},[[],[]]):[[],[]],et=(t,e,n)=>!e&&!t?[]:e?t?n?t.reduce((r,c)=>{const s=e.find(u=>n(c)===n(u));return s?[...r,s]:[...r,c]},[]):t:[]:t,nt=(t,e,n)=>{if(!t&&!e)return[];if(!e)return[...t];if(!t)return[e];for(let r=0;r{if(!t&&!e)return[];if(!t)return[e];if(!e)return[...t];const c=n?(o,l)=>n(o,l)===n(e,l):o=>o===e;return t.find(c)?t.filter((o,l)=>!c(o,l)):(r?.strategy??"append")==="append"?[...t,e]:[e,...t]},ct=t=>t?.filter(e=>!!e)??[],T=(t,e,n)=>{let r=n;for(let c=1;c<=t;c++)r=e(r,c);return r},it=(t,e,n=r=>r)=>{if(!t?.length&&!e?.length)return[];if(t?.length===void 0)return[...e];if(!e?.length)return[...t];const r=e.reduce((c,s)=>({...c,[n(s)]:!0}),{});return t.filter(c=>!r[n(c)])};function st(t,e){if(t.length===0)return t;const n=e%t.length;return n===0?t:[...t.slice(-n,t.length),...t.slice(0,-n)]}const ut=async(t,e,n)=>{const r=n!==void 0;if(!r&&t?.length<1)throw new Error("Cannot reduce empty array with no init value");const c=r?t:t.slice(1);let s=r?n:t[0];for(const u of c)s=await e(s,u);return s},ot=async(t,e)=>{if(!t)return[];let n=[],r=0;for(const c of t){const s=await e(c,r++);n.push(s)}return n},lt=async t=>{const e=[],n=(s,u)=>e.push({fn:s,rethrow:u?.rethrow??!1}),[r,c]=await d(t)(n);for(const{fn:s,rethrow:u}of e){const[o]=await d(s)(r);if(u)throw o}if(r)throw r;return c};class ft extends Error{constructor(e=[]){super();const n=e.find(r=>r.name)?.name??"";this.name=`AggregateError(${n}...)`,this.message=`AggregateError with ${e.length} errors`,this.stack=e.find(r=>r.stack)?.stack??this.stack,this.errors=e}}const at=async(t,e,n)=>{const r=e.map((f,h)=>({index:h,item:f})),c=async f=>{const h=[];for(;;){const A=r.pop();if(!A)return f(h);const[Wt,Xt]=await d(n)(A.item);h.push({error:Wt,result:Xt,index:A.index})}},s=P(1,t).map(()=>new Promise(c)),u=await Promise.all(s),[o,l]=S(z(u.flat(),f=>f.index),f=>!!f.error);if(o.length>0)throw new ft(o.map(f=>f.error));return l.map(f=>f.result)},dt=async(t,e)=>{const n=t?.times??3,r=t?.delay,c=t?.backoff??null;for(const s of y(1,n)){const[u,o]=await d(e)(l=>{throw{_exited:l}});if(!u)return o;if(u._exited)throw u._exited;if(s===n)throw u;r&&await p(r),c&&await p(c(s))}},p=t=>new Promise(e=>setTimeout(e,t)),d=t=>async(...e)=>{try{return[null,await t(...e)]}catch(n){return[n,null]}},gt=(...t)=>(...e)=>t.slice(1).reduce((n,r)=>r(n),t[0](...e)),mt=(...t)=>t.reverse().reduce((e,n)=>n(e)),ht=(t,...e)=>(...n)=>t(...e,...n),wt=(t,e)=>n=>t({...e,...n}),yt=t=>new Proxy({},{get:(e,n)=>t(n)}),pt=(t,e,n,r)=>function(...s){const u=n?n(...s):JSON.stringify({args:s}),o=t[u];if(o!==void 0&&o.exp>new Date().getTime())return o.value;const l=e(...s);return t[u]={exp:new Date().getTime()+r,value:l},l},bt=(t,{key:e=null,ttl:n=300}={})=>pt({},t,e,n),kt=({delay:t},e)=>{let n=null;return(...c)=>{clearTimeout(n),n=setTimeout(()=>e(...c),t)}},At=({interval:t},e)=>{let n=!0;return(...c)=>{!n||(e(...c),n=!1,setTimeout(()=>{n=!0},t))}},Ot=(t,e)=>{const n=()=>{};return new Proxy(Object.assign(n,t),{get:(r,c)=>r[c],set:(r,c,s)=>(r[c]=s,!0),apply:(r,c,s)=>e(Object.assign({},r))(...s)})},Ct=(t,e)=>{const n=e===void 0?0:e;if(t==null)return n;const r=parseFloat(t);return isNaN(r)?n:r},Et=(t,e)=>{const n=e===void 0?0:e;if(t==null)return n;const r=parseInt(t);return isNaN(r)?n:r},Nt=(t,e=n=>n===void 0)=>t?Object.keys(t).reduce((r,c)=>e(t[c])?r:{...r,[c]:t[c]},{}):{},b=(t,e)=>Object.keys(t).reduce((r,c)=>({...r,[e(c,t[c])]:t[c]}),{}),_t=(t,e)=>Object.keys(t).reduce((r,c)=>({...r,[c]:e(t[c],c)}),{}),$t=(t,e)=>t?Object.entries(t).reduce((n,[r,c])=>{const[s,u]=e(r,c);return{...n,[s]:u}},{}):{},zt=t=>t?Object.keys(t).reduce((n,r)=>({...n,[t[r]]:r}),{}):{},Pt=t=>b(t,e=>e.toLowerCase()),St=t=>b(t,e=>e.toUpperCase()),Tt=t=>{if(N(t))return t;if(typeof t=="function")return t.bind({});const e=new t.constructor;return Object.getOwnPropertyNames(t).forEach(n=>{e[n]=t[n]}),e},jt=(t,e)=>{if(!t)return[];const n=Object.entries(t);return n.length===0?[]:n.reduce((r,c)=>[...r,e(c[0],c[1])],[])},Bt=(t,e)=>t?e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{}):{},Lt=(t,e)=>t?!e||e.length===0?t:e.reduce((n,r)=>(delete n[r],n),{...t}):{},Dt=(t,e,n=null)=>{const r=e.split(/[\.\[\]]/g);let c=t;for(const s of r){if(c===null||c===void 0)return n;s.trim()!==""&&(c=c[s])}return c===void 0?n:c},j=(t,e)=>!t&&!e?{}:t?e?Object.entries(t).reduce((n,[r,c])=>({...n,[r]:(()=>E(c)?j(c,e[r]):e[r])()}),{}):t:e,k=(t,e)=>Math.floor(Math.random()*(e-t+1)+t),Ft=t=>{const e=t.length;if(e===0)return null;const n=k(0,e-1);return t[n]},Rt=t=>t.map(e=>({rand:Math.random(),value:e})).sort((e,n)=>e.rand-n.rand).map(e=>e.value),Zt=(t,e="")=>{const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"+e;return T(t,r=>r+n.charAt(k(0,n.length-1)),"")},qt=(...t)=>{const{itemsByValue:e,itemsByIndex:n}=t.reduce((r,c,s)=>({itemsByValue:{...r.itemsByValue,[c]:s},itemsByIndex:{...r.itemsByIndex,[s]:c}}),{itemsByValue:{},itemsByIndex:{}});return{min:(r,c)=>e[r]e[r]>e[c]?r:c,first:()=>n[0],last:()=>n[t.length-1],next:(r,c)=>n[e[r]+1]??c,previous:(r,c)=>n[e[r]-1]??c}},g=t=>{if(!t||t.length===0)return"";const e=t.toLowerCase();return e.substring(0,1).toUpperCase()+e.substring(1,e.length)},B=t=>{const e=t?.replace(/([A-Z])+/g,g)?.split(/(?=[A-Z])|[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((n,r)=>`${n}${r.charAt(0).toUpperCase()}${r.slice(1)}`)},It=t=>{const e=t?.replace(/([A-Z])+/g,g).split(/(?=[A-Z])|[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((n,r)=>`${n}_${r.toLowerCase()}`)},Mt=t=>{const e=t?.replace(/([A-Z])+/g,g)?.split(/(?=[A-Z])|[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((n,r)=>`${n}-${r.toLowerCase()}`)},Ut=t=>{const e=t?.split(/[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")},Vt=t=>t?t.split(/(?=[A-Z])|[\.\-\s_]/).map(e=>e.trim()).filter(e=>!!e).map(e=>g(e.toLowerCase())).join(" "):"",Kt=(t,e,n=/\{\{(.+?)\}\}/g)=>Array.from(t.matchAll(n)).reduce((r,c)=>r.replace(c[0],e[c[1]]),t),Jt=(t,e=" ")=>{if(!t)return"";const n=new RegExp(`^[${e}]+|[${e}]+$`,"g");return t.replace(n,"")};return i.alphabetical=K,i.assign=j,i.boil=w,i.callable=Ot,i.camal=B,i.camel=B,i.capitalize=g,i.chain=gt,i.clone=Tt,i.cluster=Q,i.compose=mt,i.counting=J,i.dash=Mt,i.debounce=kt,i.defer=lt,i.diff=it,i.draw=Ft,i.first=U,i.flat=x,i.fork=S,i.get=Dt,i.group=Z,i.intersects=tt,i.invert=zt,i.isArray=C,i.isDate=_,i.isEmpty=R,i.isEqual=$,i.isFloat=F,i.isFunction=m,i.isInt=D,i.isNumber=a,i.isObject=E,i.isPrimitive=N,i.isString=L,i.isSymbol=O,i.iterate=T,i.last=V,i.list=P,i.listify=jt,i.lowerize=Pt,i.map=ot,i.mapEntries=$t,i.mapKeys=b,i.mapValues=_t,i.max=G,i.memo=bt,i.merge=et,i.min=H,i.objectify=X,i.omit=Lt,i.parallel=at,i.partial=ht,i.partob=wt,i.pascal=Ut,i.pick=Bt,i.proxied=yt,i.random=k,i.range=y,i.reduce=ut,i.replace=W,i.replaceOrAppend=nt,i.retry=dt,i.select=Y,i.series=qt,i.shake=Nt,i.shift=st,i.shuffle=Rt,i.sift=ct,i.sleep=p,i.snake=It,i.sort=z,i.sum=M,i.template=Kt,i.throttle=At,i.title=Vt,i.toFloat=Ct,i.toInt=Et,i.toggle=rt,i.trim=Jt,i.try=d,i.tryit=d,i.uid=Zt,i.unique=v,i.upperize=St,i.zip=q,i.zipToObject=I,i}({}); +var radash=function(i){"use strict";const O=t=>!!t&&t.constructor===Symbol,C=t=>!!t&&t.constructor===Array,E=t=>!!t&&t.constructor===Object,N=t=>t==null||typeof t!="object"&&typeof t!="function",m=t=>!!(t&&t.constructor&&t.call&&t.apply),B=t=>typeof t=="string"||t instanceof String,L=t=>a(t)&&t%1===0,D=t=>a(t)&&t%1!==0,a=t=>{try{return Number(t)===t}catch{return!1}},_=t=>Object.prototype.toString.call(t)==="[object Date]",F=t=>{if(t===!0||t===!1||t==null)return!0;if(a(t))return t===0;if(_(t))return isNaN(t.getTime());if(m(t)||O(t))return!1;const e=t.length;if(a(e))return e===0;const n=t.size;return a(n)?n===0:Object.keys(t).length===0},$=(t,e)=>{if(Object.is(t,e))return!0;if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.toString()===e.toString();if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;const n=Reflect.ownKeys(t),r=Reflect.ownKeys(e);if(n.length!==r.length)return!1;for(let c=0;ct.reduce((n,r)=>{const c=e(r);return n[c]||(n[c]=[]),n[c].push(r),n},{});function Z(...t){return!t||!t.length?[]:new Array(Math.max(...t.map(({length:e})=>e))).fill([]).map((e,n)=>t.map(r=>r[n]))}function q(t,e){if(!t||!t.length)return{};const n=m(e)?e:C(e)?(r,c)=>e[c]:(r,c)=>e;return t.reduce((r,c,s)=>({...r,[c]:n(c,s)}),{})}const w=(t,e)=>!t||(t.length??0)===0?null:t.reduce(e),I=(t,e)=>(t||[]).reduce((n,r)=>n+(e?e(r):r),0),M=(t,e=void 0)=>t?.length>0?t[0]:e,U=(t,e=void 0)=>t?.length>0?t[t.length-1]:e,z=(t,e,n=!1)=>{if(!t)return[];const r=(s,u)=>e(s)-e(u),c=(s,u)=>e(u)-e(s);return t.slice().sort(n===!0?c:r)},V=(t,e,n="asc")=>{if(!t)return[];const r=(s,u)=>`${e(s)}`.localeCompare(e(u)),c=(s,u)=>`${e(u)}`.localeCompare(e(s));return t.slice().sort(n==="desc"?c:r)},K=(t,e)=>t.reduce((n,r)=>{const c=e(r);return{...n,[c]:(n[c]??0)+1}},{}),J=(t,e,n)=>{if(!t)return[];if(!e)return[...t];for(let r=0;rr)=>t.reduce((r,c)=>({...r,[e(c)]:n(c)}),{}),X=(t,e,n)=>t.reduce((r,c)=>n(c)?[...r,e(c)]:r,[]),Y=(t,e)=>{const n=e||(r=>r);return w(t,(r,c)=>n(r)>n(c)?r:c)},G=(t,e)=>{const n=e||(r=>r);return w(t,(r,c)=>n(r){const n=Math.ceil(t.length/e);return new Array(n).fill(null).map((r,c)=>t.slice(c*e,c*e+e))},Q=(t,e)=>{const n=t.reduce((r,c)=>{const s=e?e(c):c;return r[s]?r:{...r,[s]:c}},{});return Object.values(n)};function*y(t,e,n=c=>c,r=1){const c=m(n)?n:()=>n,s=e?t:0,u=e??t;for(let o=s;o<=u&&(yield c(o),!(o+r>u));o+=r);}const P=(t,e,n,r)=>Array.from(y(t,e,n,r)),v=t=>t.reduce((e,n)=>[...e,...n],[]),x=(t,e,n)=>{if(!t||!e)return!1;const r=n??(s=>s),c=e.reduce((s,u)=>({...s,[r(u)]:!0}),{});return t.some(s=>c[r(s)])},S=(t,e)=>t?t.reduce((n,r)=>{const[c,s]=n;return e(r)?[[...c,r],s]:[c,[...s,r]]},[[],[]]):[[],[]],tt=(t,e,n)=>!e&&!t?[]:e?t?n?t.reduce((r,c)=>{const s=e.find(u=>n(c)===n(u));return s?[...r,s]:[...r,c]},[]):t:[]:t,et=(t,e,n)=>{if(!t&&!e)return[];if(!e)return[...t];if(!t)return[e];for(let r=0;r{if(!t&&!e)return[];if(!t)return[e];if(!e)return[...t];const c=n?(o,l)=>n(o,l)===n(e,l):o=>o===e;return t.find(c)?t.filter((o,l)=>!c(o,l)):(r?.strategy??"append")==="append"?[...t,e]:[e,...t]},rt=t=>t?.filter(e=>!!e)??[],T=(t,e,n)=>{let r=n;for(let c=1;c<=t;c++)r=e(r,c);return r},ct=(t,e,n=r=>r)=>{if(!t?.length&&!e?.length)return[];if(t?.length===void 0)return[...e];if(!e?.length)return[...t];const r=e.reduce((c,s)=>({...c,[n(s)]:!0}),{});return t.filter(c=>!r[n(c)])};function it(t,e){if(t.length===0)return t;const n=e%t.length;return n===0?t:[...t.slice(-n,t.length),...t.slice(0,-n)]}const st=async(t,e,n)=>{const r=n!==void 0;if(!r&&t?.length<1)throw new Error("Cannot reduce empty array with no init value");const c=r?t:t.slice(1);let s=r?n:t[0];for(const u of c)s=await e(s,u);return s},ut=async(t,e)=>{if(!t)return[];let n=[],r=0;for(const c of t){const s=await e(c,r++);n.push(s)}return n},ot=async t=>{const e=[],n=(s,u)=>e.push({fn:s,rethrow:u?.rethrow??!1}),[r,c]=await d(t)(n);for(const{fn:s,rethrow:u}of e){const[o]=await d(s)(r);if(u)throw o}if(r)throw r;return c};class lt extends Error{constructor(e=[]){super();const n=e.find(r=>r.name)?.name??"";this.name=`AggregateError(${n}...)`,this.message=`AggregateError with ${e.length} errors`,this.stack=e.find(r=>r.stack)?.stack??this.stack,this.errors=e}}const ft=async(t,e,n)=>{const r=e.map((f,h)=>({index:h,item:f})),c=async f=>{const h=[];for(;;){const A=r.pop();if(!A)return f(h);const[Wt,Xt]=await d(n)(A.item);h.push({error:Wt,result:Xt,index:A.index})}},s=P(1,t).map(()=>new Promise(c)),u=await Promise.all(s),[o,l]=S(z(u.flat(),f=>f.index),f=>!!f.error);if(o.length>0)throw new lt(o.map(f=>f.error));return l.map(f=>f.result)},at=async(t,e)=>{const n=t?.times??3,r=t?.delay,c=t?.backoff??null;for(const s of y(1,n)){const[u,o]=await d(e)(l=>{throw{_exited:l}});if(!u)return o;if(u._exited)throw u._exited;if(s===n)throw u;r&&await p(r),c&&await p(c(s))}},p=t=>new Promise(e=>setTimeout(e,t)),d=t=>async(...e)=>{try{return[null,await t(...e)]}catch(n){return[n,null]}},dt=(...t)=>(...e)=>t.slice(1).reduce((n,r)=>r(n),t[0](...e)),gt=(...t)=>t.reverse().reduce((e,n)=>n(e)),mt=(t,...e)=>(...n)=>t(...e,...n),ht=(t,e)=>n=>t({...e,...n}),wt=t=>new Proxy({},{get:(e,n)=>t(n)}),yt=(t,e,n,r)=>function(...s){const u=n?n(...s):JSON.stringify({args:s}),o=t[u];if(o!==void 0&&o.exp>new Date().getTime())return o.value;const l=e(...s);return t[u]={exp:new Date().getTime()+r,value:l},l},pt=(t,{key:e=null,ttl:n=300}={})=>yt({},t,e,n),bt=({delay:t},e)=>{let n=null;return(...c)=>{clearTimeout(n),n=setTimeout(()=>e(...c),t)}},kt=({interval:t},e)=>{let n=!0;return(...c)=>{!n||(e(...c),n=!1,setTimeout(()=>{n=!0},t))}},At=(t,e)=>{const n=()=>{};return new Proxy(Object.assign(n,t),{get:(r,c)=>r[c],set:(r,c,s)=>(r[c]=s,!0),apply:(r,c,s)=>e(Object.assign({},r))(...s)})},Ot=(t,e)=>{const n=e===void 0?0:e;if(t==null)return n;const r=parseFloat(t);return isNaN(r)?n:r},Ct=(t,e)=>{const n=e===void 0?0:e;if(t==null)return n;const r=parseInt(t);return isNaN(r)?n:r},Et=(t,e=n=>n===void 0)=>t?Object.keys(t).reduce((r,c)=>e(t[c])?r:{...r,[c]:t[c]},{}):{},b=(t,e)=>Object.keys(t).reduce((r,c)=>({...r,[e(c,t[c])]:t[c]}),{}),Nt=(t,e)=>Object.keys(t).reduce((r,c)=>({...r,[c]:e(t[c],c)}),{}),_t=(t,e)=>t?Object.entries(t).reduce((n,[r,c])=>{const[s,u]=e(r,c);return{...n,[s]:u}},{}):{},$t=t=>t?Object.keys(t).reduce((n,r)=>({...n,[t[r]]:r}),{}):{},zt=t=>b(t,e=>e.toLowerCase()),Pt=t=>b(t,e=>e.toUpperCase()),St=t=>{if(N(t))return t;if(typeof t=="function")return t.bind({});const e=new t.constructor;return Object.getOwnPropertyNames(t).forEach(n=>{e[n]=t[n]}),e},Tt=(t,e)=>{if(!t)return[];const n=Object.entries(t);return n.length===0?[]:n.reduce((r,c)=>[...r,e(c[0],c[1])],[])},jt=(t,e)=>t?e.reduce((n,r)=>(t.hasOwnProperty(r)&&(n[r]=t[r]),n),{}):{},Bt=(t,e)=>t?!e||e.length===0?t:e.reduce((n,r)=>(delete n[r],n),{...t}):{},Lt=(t,e,n=null)=>{const r=e.split(/[\.\[\]]/g);let c=t;for(const s of r){if(c===null||c===void 0)return n;s.trim()!==""&&(c=c[s])}return c===void 0?n:c},j=(t,e)=>!t&&!e?{}:t?e?Object.entries(t).reduce((n,[r,c])=>({...n,[r]:(()=>E(c)?j(c,e[r]):e[r])()}),{}):t:e,k=(t,e)=>Math.floor(Math.random()*(e-t+1)+t),Dt=t=>{const e=t.length;if(e===0)return null;const n=k(0,e-1);return t[n]},Ft=t=>t.map(e=>({rand:Math.random(),value:e})).sort((e,n)=>e.rand-n.rand).map(e=>e.value),Rt=(t,e="")=>{const n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"+e;return T(t,r=>r+n.charAt(k(0,n.length-1)),"")},Zt=(...t)=>{const{itemsByValue:e,itemsByIndex:n}=t.reduce((r,c,s)=>({itemsByValue:{...r.itemsByValue,[c]:s},itemsByIndex:{...r.itemsByIndex,[s]:c}}),{itemsByValue:{},itemsByIndex:{}});return{min:(r,c)=>e[r]e[r]>e[c]?r:c,first:()=>n[0],last:()=>n[t.length-1],next:(r,c)=>n[e[r]+1]??c,previous:(r,c)=>n[e[r]-1]??c}},g=t=>{if(!t||t.length===0)return"";const e=t.toLowerCase();return e.substring(0,1).toUpperCase()+e.substring(1,e.length)},qt=t=>{const e=t?.replace(/([A-Z])+/g,g)?.split(/(?=[A-Z])|[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((n,r)=>`${n}${r.charAt(0).toUpperCase()}${r.slice(1)}`)},It=t=>{const e=t?.replace(/([A-Z])+/g,g).split(/(?=[A-Z])|[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((n,r)=>`${n}_${r.toLowerCase()}`)},Mt=t=>{const e=t?.replace(/([A-Z])+/g,g)?.split(/(?=[A-Z])|[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.length===1?e[0]:e.reduce((n,r)=>`${n}-${r.toLowerCase()}`)},Ut=t=>{const e=t?.split(/[\.\-\s_]/).map(n=>n.toLowerCase())??[];return e.length===0?"":e.map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")},Vt=t=>t?t.split(/(?=[A-Z])|[\.\-\s_]/).map(e=>e.trim()).filter(e=>!!e).map(e=>g(e.toLowerCase())).join(" "):"",Kt=(t,e,n=/\{\{(.+?)\}\}/g)=>Array.from(t.matchAll(n)).reduce((r,c)=>r.replace(c[0],e[c[1]]),t),Jt=(t,e=" ")=>{if(!t)return"";const n=new RegExp(`^[${e}]+|[${e}]+$`,"g");return t.replace(n,"")};return i.alphabetical=V,i.assign=j,i.boil=w,i.callable=At,i.camel=qt,i.capitalize=g,i.chain=dt,i.clone=St,i.cluster=H,i.compose=gt,i.counting=K,i.dash=Mt,i.debounce=bt,i.defer=ot,i.diff=ct,i.draw=Dt,i.first=M,i.flat=v,i.fork=S,i.get=Lt,i.group=R,i.intersects=x,i.invert=$t,i.isArray=C,i.isDate=_,i.isEmpty=F,i.isEqual=$,i.isFloat=D,i.isFunction=m,i.isInt=L,i.isNumber=a,i.isObject=E,i.isPrimitive=N,i.isString=B,i.isSymbol=O,i.iterate=T,i.last=U,i.list=P,i.listify=Tt,i.lowerize=zt,i.map=ut,i.mapEntries=_t,i.mapKeys=b,i.mapValues=Nt,i.max=Y,i.memo=pt,i.merge=tt,i.min=G,i.objectify=W,i.omit=Bt,i.parallel=ft,i.partial=mt,i.partob=ht,i.pascal=Ut,i.pick=jt,i.proxied=wt,i.random=k,i.range=y,i.reduce=st,i.replace=J,i.replaceOrAppend=et,i.retry=at,i.select=X,i.series=Zt,i.shake=Et,i.shift=it,i.shuffle=Ft,i.sift=rt,i.sleep=p,i.snake=It,i.sort=z,i.sum=I,i.template=Kt,i.throttle=kt,i.title=Vt,i.toFloat=Ot,i.toInt=Ct,i.toggle=nt,i.trim=Jt,i.try=d,i.tryit=d,i.uid=Rt,i.unique=Q,i.upperize=Pt,i.zip=Z,i.zipToObject=q,i}({}); diff --git a/src/index.ts b/src/index.ts index adc5eaf1..215e35f6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -70,13 +70,6 @@ export { export { draw, random, shuffle, uid } from './random' export { series } from './series' export { - /** - * Warning: This is exported for compatability - * but is @deprecated and will be removed in - * the next major version. Someone spelled - * camel wrong when it was implemented... - */ - camel as camal, camel, capitalize, dash, diff --git a/src/tests/string.test.ts b/src/tests/string.test.ts index 1e7f0e7b..52caa59e 100644 --- a/src/tests/string.test.ts +++ b/src/tests/string.test.ts @@ -3,10 +3,6 @@ import * as _ from '..' describe('string module', () => { describe('camel function', () => { - test('camal alias is available', () => { - // NOTE: Remove in next major version - assert.isFunction(_.camal) - }) test('returns correctly cased string', () => { const result = _.camel('hello world') assert.equal(result, 'helloWorld')