UNPKG

@cmtlyt/base

Version:
2 lines (1 loc) 6.66 kB
"use strict";const array=require("./base.BHKgYhd5.cjs");require("ms");function _generateRunFunc(e,r){return e.length===0?n=>n:e.length===1?e[0]:(...n)=>r(e,...n)[0]}const compose=function(...e){const r=_generateRunFunc(e,(c,...s)=>c.reduceRight((a,_)=>[_(...array.getArray(a))],s)),n=e[e.length-1];return r.clength=n?.clength||n?.length,r},pipe=function(...e){const r=_generateRunFunc(e,(c,...s)=>c.reduce((a,_)=>[_(...array.getArray(a))],s)),n=e[0];return r.clength=n?.clength||n?.length,r};function both_(...e){const r=e.pop();return e.every(n=>n(r))}function both(...e){return r=>both_(...e,r)}function eq_(e,r){return e===r}const eq=array.curry(eq_);function gt_(e,r){return e>r}const gt=array.curry(gt_);function lt_(e,r){return e<r}const lt=array.curry(lt_),trace=array.curry((e,r)=>{try{e(r)}catch{}return r});function when_(e,r,n){return e(n)?r(n):n}const when=array.curry(when_);function applySpec_(e,r){if(typeof e!="object")throw new TypeError("Spec must be an object");return Object.keys(e).reduce((n,c)=>{const s=e[c];return typeof s=="function"?n[c]=e[c](...r):n[c]=applySpec_(s,r),n},{})}const applySpec=array.curry(applySpec_);function assoc_(e,r,n,c="."){let s=e;array.isArray(s)||(array.isString(s)?s=s.split(c):s=array.getArray(s));const a=array.getType(n);if(a!=="array"&&a!=="object")throw new TypeError("source must be array or object");const _=a==="array"?[...n]:{...n},l=s.slice(0,-1).reduce((i,u)=>a==="array"?i[u]=[]:i[u]||={},_);return l[s.pop()]=r,_}const{__:t}=array.placeholderFunc,assoc=array.curry(array.placeholderFunc(assoc_)(t,t,t,"."));function deepExec_(e,r){const n={};for(const c in r){const s=r[c];array.getType(s)==="object"?n[c]=deepExec_(e,s):n[c]=e(s,c)}return n}const deepExec=array.curry(deepExec_);function deepExecWith_(e,r,n){const c={};for(const s in n){const a=n[s];array.getType(a)==="object"?c[s]=deepExecWith_(e,r,a):r(a,s)?c[s]=e(a,s):c[s]=a}return c}const deepExecWith=array.curry(deepExecWith_);function deepProp_(e,r,n="."){return!n&&typeof e=="string"?r[e]:(array.isArray(e)?e:String(e).split(n)).reduce((c,s)=>array.isNull(c)?c:c[s],r)}const p=array.placeholderFunc.__,deepProp=array.curry(array.placeholderFunc(deepProp_)(p,p,"."));function deleteProp_(e,r){const n={...r};return delete n[e],n}const deleteProp=array.curry(deleteProp_);function omit_(e,r){const n={},c=array.getArray(e);return Object.keys(r).forEach(s=>{c.includes(s)||(n[s]=r[s])}),n}const omit=array.curry(omit_);function pick_(e,r){const n={};return array.getArray(e).forEach(c=>n[c]=r[c]),n}const pick=array.curry(pick_);function prop_(e,r){return r[e]}const prop=array.curry(prop_);function props_(e,r,n="."){return array.reduce((c,s)=>assoc_(s,deepProp_(s,r,n),c,n),{},e)}const{__:o}=array.placeholderFunc,props=array.curry(array.placeholderFunc(props_)(o,o,"."));function rename_(e,r){const n={...r};for(const c in e){const s=prop_(c,r);delete n[c],n[e[c]]=s}return n}const rename=array.curry(rename_);function addThen_(e,r){return r.then(e)}const addThen=array.curry(addThen_),always_=(e,r)=>e,always=array.curry(always_),defaultValue_=(e,r)=>r??e,defaultValue=array.curry(defaultValue_),id=e=>e,id_=id,identity=id,identity_=identity,toCamelCase=e=>e.replace(/(^|[-\s])+(\w)/g,(r,n,c)=>c.toLocaleUpperCase()),toCamelCase_=toCamelCase,toKebabCase=e=>e.replace(/([A-Z])/g,(r,n)=>`-${n.toLocaleLowerCase()}`).replace(/[_\s-]+/g,"-").replace(/^-+/,""),toKebabCase_=toKebabCase,toLowerCase=e=>e.toLocaleLowerCase(),toLowerCase_=toLowerCase,toUnderlineCase=e=>e.replace(/([A-Z])/g,(r,n)=>`_${n.toLocaleLowerCase()}`).replace(/[-_\s]+/g,"_").replace(/^_+/,""),toUnderlineCase_=toUnderlineCase,toUpperCase=e=>e.toLocaleUpperCase(),toUpperCase_=toUpperCase,index={__proto__:null,__:array.__,addThen,addThen_,adjust:array.adjust,adjust_:array.adjust_,always,always_,aperture:array.aperture,aperture_:array.aperture_,append:array.append,append_:array.append_,apply:array.apply,applySpec,applySpec_,applyTo:array.applyTo,applyTo_:array.applyTo_,apply_:array.apply_,argNumLimit:array.argNumLimit,argNumLimit_:array.argNumLimit_,assoc,assoc_,both,both_,collectBy:array.collectBy,collectBy_:array.collectBy_,compose,curry:array.curry,deepExec,deepExecWith,deepExecWith_,deepExec_,deepProp,deepProp_,defaultValue,defaultValue_,deleteProp,deleteProp_,eq,eq_,every:array.every,every_:array.every_,filter:array.filter,filter_:array.filter_,find:array.find,findIndex:array.findIndex,findIndex_:array.findIndex_,find_:array.find_,groupBy:array.groupBy,groupBy_:array.groupBy_,groupWith:array.groupWith,groupWith_:array.groupWith_,gt,gt_,id,id_,identity,identity_,includes:array.includes,includes_:array.includes_,join:array.join,join_:array.join_,lt,lt_,makeBy:array.makeBy,makeBy_:array.makeBy_,map:array.map,map_:array.map_,nth:array.nth,nth_:array.nth_,omit,omit_,partition:array.partition,partition_:array.partition_,pick,pick_,pipe,placeholderFunc:array.placeholderFunc,prop,prop_,props,props_,reduce:array.reduce,reduce_:array.reduce_,rename,rename_,replicate:array.replicate,replicate_:array.replicate_,some:array.some,some_:array.some_,take:array.take,take_:array.take_,toCamelCase,toCamelCase_,toKebabCase,toKebabCase_,toLowerCase,toLowerCase_,toUnderlineCase,toUnderlineCase_,toUpperCase,toUpperCase_,trace,when,when_,zip:array.zip,zip_:array.zip_};exports.addThen=addThen,exports.addThen_=addThen_,exports.always=always,exports.always_=always_,exports.applySpec=applySpec,exports.applySpec_=applySpec_,exports.assoc=assoc,exports.assoc_=assoc_,exports.both=both,exports.both_=both_,exports.compose=compose,exports.deepExec=deepExec,exports.deepExecWith=deepExecWith,exports.deepExecWith_=deepExecWith_,exports.deepExec_=deepExec_,exports.deepProp=deepProp,exports.deepProp_=deepProp_,exports.defaultValue=defaultValue,exports.defaultValue_=defaultValue_,exports.deleteProp=deleteProp,exports.deleteProp_=deleteProp_,exports.eq=eq,exports.eq_=eq_,exports.gt=gt,exports.gt_=gt_,exports.id=id,exports.id_=id_,exports.identity=identity,exports.identity_=identity_,exports.index=index,exports.lt=lt,exports.lt_=lt_,exports.omit=omit,exports.omit_=omit_,exports.pick=pick,exports.pick_=pick_,exports.pipe=pipe,exports.prop=prop,exports.prop_=prop_,exports.props=props,exports.props_=props_,exports.rename=rename,exports.rename_=rename_,exports.toCamelCase=toCamelCase,exports.toCamelCase_=toCamelCase_,exports.toKebabCase=toKebabCase,exports.toKebabCase_=toKebabCase_,exports.toLowerCase=toLowerCase,exports.toLowerCase_=toLowerCase_,exports.toUnderlineCase=toUnderlineCase,exports.toUnderlineCase_=toUnderlineCase_,exports.toUpperCase=toUpperCase,exports.toUpperCase_=toUpperCase_,exports.trace=trace,exports.when=when,exports.when_=when_;