ramda-extension
Version:
Helpful functions built on top of the mighty Ramda
2 lines (1 loc) • 10.1 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("ramda")):"function"==typeof define&&define.amd?define(["exports","ramda"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).R_={},e.R)}(this,(function(e,t){"use strict";var i=t.equals(0),o=[],a={},n=t.equals(""),s=t.complement(t.isNil),l=s,p=t.complement(t.isEmpty),r=p,u=t.complement(isNaN),c=u,y=t.allPass([t.o(c,parseFloat),isFinite]),d=t.complement(y),m=d,h=t.always(null),f=t.always(""),g=t.thunkify(t.clone),q=g(o),W=t.always(0),N=t.always(1),E=g(a),T=t.apply(t.compose),j=t.apply(t.pipe),P=t.curry((function(e,t,i){return i>=e&&t>=i})),A=t.is(Array),O=t.is(Function),b=t.is(Object),v=t.gt(0),w=t.anyPass([t.isNil,n]),L=t.allPass([l,b]),x=t.is(RegExp),S=t.complement(x),D=t.lt(0),F=t.allPass([b,t.o(O,t.prop("then"))]),I=t.is(String),C=Boolean,R=t.complement(C),k=t.is(Error),U=t.tap((function(e){return console.log(e)})),_=t.useWith(t.tap,[t.curryN(2,console.log),t.identity]),B=t.reduce(t.call),z=t.nthArg(0),K=t.converge(t.reduce,[t.converge(t.partialRight,[z,t.unapply(t.tail)]),t.nthArg(1),t.nthArg(2)]),Z=t.find(l),M=t.useWith(t.xprod,[t.of(Array),t.identity]),V=t.compose(t.map(t.juxt([T,t.last])),M),H=t.converge(t.call(t.cond),[V]),$=H(l),G=h,J=t.constructN(2,RegExp),Q=t.useWith(t.flip(J)("gi"),[t.concat("^")]),X=t.useWith(t.test,[Q,t.identity]),Y=t.useWith(t.startsWith,[t.toUpper,t.toUpper]),ee=t.useWith(t.flip(J)("gi"),[t.flip(t.concat)("$")]),te=t.useWith(t.test,[ee,t.identity]),ie=t.useWith(t.endsWith,[t.toUpper,t.toUpper]),oe=t.unapply(t.identity),ae=t.curry(t.compose(t.isEmpty,t.difference)),ne=t.curry(t.compose(t.not,t.isEmpty,t.intersection)),se=t.curry(t.compose(t.isEmpty,t.intersection)),le=t.split("."),pe=t.reduce(t.mergeDeepRight,{}),re=t.o(t.o(pe,t.values),t.mapObjIndexed(t.useWith(t.flip(t.call),[t.identity,t.compose(T,t.map(t.objOf),le)]))),ue=t.o(t.join(""),t.adjust(0,t.toUpper)),ce=t.unless(t.isEmpty,ue),ye=t.o(t.join(""),t.adjust(0,t.toLower)),de=J("[^a-zA-Z0-9]+","g"),me=t.o(t.reject(t.equals("")),t.split(de)),he=t.join(""),fe=t.o(he,t.o(t.map(ce),me)),ge=t.o(ye,fe),qe=t.join("_"),We=t.o(qe,t.o(t.map(t.toLower),me)),Ne=t.join("-"),Ee=t.o(Ne,t.o(t.map(t.toLower),me)),Te=t.join("."),je=t.o(Te,t.o(t.map(t.toLower),me)),Pe=t.o(qe,t.o(t.map(t.toUpper),me)),Ae=t.reject(t.isNil),Oe=t.useWith(t.reject,[t.equals,t.identity]),be=t.join(" "),ve=t.over(t.lensIndex(0)),we=t.curryN(2,t.compose(t.apply(t.dissocPath),ve(le),oe)),Le=t.useWith(t.path,[le,t.identity]),xe=t.curryN(2,t.compose(t.apply(t.assocPath),ve(le),oe)),Se=t.nthArg(-1),De=t.converge(Le,[z,Se]),Fe=t.converge(t.call,[t.nthArg(1),De,t.nthArg(2)]),Ie=t.converge(xe,[z,Fe,Se]),Ce=t.useWith(t.compose(t.fromPairs,t.map),[t.identity,t.toPairs]),Re=t.useWith(Ce,[ve,t.identity]),ke=t.ifElse(l,t.apply,h),Ue=t.useWith(t.__,[t.identity,t.length]),_e=Ue(t.equals),Be=t.useWith(t.equals,[t.toLower,t.toLower]),ze=Ue(t.gte),Ke=Ue(t.gt),Ze=Ue(t.lte),Me=Ue(t.lt),Ve=t.useWith(t.flip(t.o),[t.view,t.identity,t.identity]),He=t.useWith(Ve,[t.identity,t.equals,t.identity]),$e=t.compose(t.flatten,oe),Ge=t.cond([[A,function(e){return t.o(t.flatten,t.map(Ge))(e)}],[b,function(e){return t.o(Ge,t.values)(e)}],[t.T,t.of(Array)]]),Je=t.is(Number),Qe=t.filter(t.identity),Xe=t.filter(t.anyPass([b,I,Je])),Ye=t.mapObjIndexed((function(e,t){return e&&t})),et=t.compose(Qe,t.values,Ye),tt=t.into([],t.compose(t.map(t.when(b,et)),Xe,Qe)),it=t.compose(be,t.flatten,tt,$e),ot=t.complement(t.propEq),at=t.complement(t.pathEq),nt=t.flip(t.repeat),st=nt(2),lt=t.mapObjIndexed(t.nthArg(1)),pt=t.o(t.fromPairs,t.map(st)),rt=t.compose(t.juxt,t.flip(t.prepend)([t.last]),t.apply),ut=t.useWith(Ce,[rt,t.identity]),ct=Ce(t.juxt([t.o(ge,t.head),t.o((function(e){return dt(e)}),t.last)])),yt=t.map((function(e){return dt(e)})),dt=t.cond([[A,yt],[O,t.identity],[L,ct],[t.T,t.identity]]),mt=t.flip(t.includes),ht=mt,ft=t.complement(mt),gt=ft,qt=t.converge(t.curry,[t.pipe]),Wt=t.converge(t.curry,[t.compose]),Nt=t.useWith(t.until,[t.identity,t.concat,t.identity]),Et=t.useWith(Nt,[Ze,t.identity,t.identity]),Tt=t.useWith(t.until,[t.identity,t.flip(t.concat),t.identity]),jt=t.useWith(Tt,[Ze,t.identity,t.identity]),Pt=t.useWith(t.flip(t.xprod),[t.of(Array),t.identity]),At=t.memoizeWith(t.identity),Ot=t.converge(t.set,[z,Ve,E]),bt=t.reduce(t.mergeDeepLeft,{}),vt=t.useWith(t.reduce(t.__,{}),[t.mergeDeepWith,t.identity]),wt=t.useWith(t.reduce(t.__,{}),[t.mergeDeepWithKey,t.identity]),Lt=t.curryN(4,t.pipe),xt=t.curryN(2,t.pipe),St=t.curryN(3,t.call),Dt=t.o(t.map,t.when(_e(1))),Ft=t.o(Dt(t.prepend(void 0)),t.transpose),It=t.o(Dt(t.append(void 0)),t.transpose),Ct=t.map(t.length),Rt=t.o(t.apply(t.equals),Ct),kt=t.o(t.apply(t.lt),Ct),Ut=t.o(t.apply(t.gt),Ct),_t=t.cond([[Rt,t.transpose],[kt,Ft],[Ut,It]]),Bt=t.o(t.apply(t.call),ve(t.defaultTo)),zt=Lt(oe,_t,t.map(Bt)),Kt=t.o(St,t.o(zt,t.apply)),Zt=xt(oe),Mt=t.pipe(t.call,Zt),Vt=t.useWith(t.flip(Mt),[t.identity,Kt]),Ht=t.defaultTo(o),$t=t.defaultTo(a),Gt=t.defaultTo(""),Jt=t.defaultTo(!1),Qt=t.defaultTo(1),Xt=t.defaultTo(!0),Yt=t.defaultTo(0),ei=t.equals(o),ti=t.equals(a),ii=t.equals(!1),oi=t.equals(1),ai=t.equals(null),ni=t.equals(!0),si=t.complement(t.equals),li=t.complement(ei),pi=t.complement(ti),ri=t.complement(n),ui=t.complement(ii),ci=t.complement(ai),yi=t.complement(oi),di=t.complement(ni),mi=t.complement(i),hi=t.useWith(oe,[t.equals,t.always]),fi=t.compose(t.cond,t.juxt([hi,t.flip(hi),t.always([t.T,t.identity])])),gi=t.useWith(t.pathEq,[t.identity,le,t.identity]),qi=t.complement(gi),Wi=t.useWith(t.pathOr,[t.identity,le,t.identity]),Ni=t.useWith(t.pathSatisfies,[t.identity,le,t.identity]),Ei=t.complement(Ni),Ti=t.complement(t.propSatisfies),ji=t.complement(t.pathSatisfies),Pi=t.addIndex(t.map),Ai=t.anyPass([t.isNil,t.isEmpty]),Oi=t.allPass([t.o(t.equals("Object"),t.type),s,t.either(t.o(t.equals(Object.prototype),Object.getPrototypeOf),t.o(t.isNil,Object.getPrototypeOf))]),bi=t.ifElse(O,t.apply,z),vi=t.ifElse(O,t.call,z),wi=t.is(Boolean),Li=t.unless(A,t.of(Array)),xi=t.o(t.map(t.apply(t.objOf)),t.toPairs),Si=t.flip(t.path),Di=Wt(t.uniq,t.map),Fi=Wt(t.uniq,t.filter),Ii=Wt(t.length,t.uniq),Ci=Wt(t.uniq,t.take),Ri=Wt(t.uniq,t.takeLast),ki=Wt(t.uniq,t.takeWhile),Ui=Wt(t.uniq,t.drop),_i=Wt(t.uniq,t.takeLastWhile),Bi=Wt(t.uniq,t.dropLast),zi=Wt(t.uniq,t.dropWhile),Ki=Wt(t.uniq,t.dropLastWhile),Zi=Wt(t.uniq,t.append),Mi=Wt(t.uniq,t.prepend),Vi=t.useWith(t.groupBy,[t.path,t.identity]),Hi=t.useWith(t.groupBy,[t.prop,t.identity]),$i=t.unless(t.isNil,t.replace(/^./,t.toUpper)),Gi=t.unless(t.isNil,t.replace(/^./,t.toLower)),Ji=t.unless(t.isNil,t.replace(/(\b\w(?!\s))/g,t.toUpper)),Qi=t.unless(t.isNil,t.replace(/(\b\w(?!\s))/g,t.toLower)),Xi=t.uncurryN(3,t.compose(t.map,t.binary(t.over))),Yi=t.useWith(Xi,[t.lensProp,t.identity,t.identity]),eo=t.useWith(Xi,[t.lensPath,t.identity,t.identity]);e.alwaysEmptyArray=q,e.alwaysEmptyObject=E,e.alwaysEmptyString=f,e.alwaysNull=h,e.alwaysOne=N,e.alwaysZero=W,e.applyCompose=T,e.applyIfFunction=bi,e.applyIfNotNil=ke,e.applyPipe=j,e.argumentsToList=oe,e.assocDotPath=xe,e.between=P,e.callIfFunction=vi,e.camelizeKeys=dt,e.capitalizeAll=Ji,e.capitalizeFirst=$i,e.composeC=Wt,e.constructRegExp=J,e.containsAll=ae,e.containsAny=ne,e.containsNone=se,e.cx=it,e.decapitalizeAll=Qi,e.decapitalizeFirst=Gi,e.defaultArgs=Vt,e.defaultToEmptyArray=Ht,e.defaultToEmptyObject=$t,e.defaultToEmptyString=Gt,e.defaultToFalse=Jt,e.defaultToOne=Qt,e.defaultToTrue=Xt,e.defaultToZero=Yt,e.dispatch=$,e.dispatchWith=H,e.dissocDotPath=we,e.dotPath=Le,e.dotPathEq=gi,e.dotPathNotEq=qi,e.dotPathNotSatisfies=Ei,e.dotPathOr=Wi,e.dotPathSatisfies=Ni,e.duplicate=st,e.endsWithSuffix=te,e.endsWithSuffixIgnoreCase=ie,e.ensureArray=Li,e.equalsEmptyString=n,e.equalsLength=_e,e.equalsStringIgnoreCase=Be,e.equalsToEmptyArray=ei,e.equalsToEmptyObject=ti,e.equalsToEmptyString=n,e.equalsToFalse=ii,e.equalsToNull=ai,e.equalsToOne=oi,e.equalsToTrue=ni,e.equalsToZero=i,e.equalsZero=i,e.findNotNil=Z,e.flattenArgs=$e,e.flattenValues=Ge,e.flipIncludes=mt,e.get=Si,e.groupByPath=Vi,e.groupByProp=Hi,e.gtThanLength=Ke,e.gteThanLength=ze,e.headArg=z,e.includes=ht,e.isArray=A,e.isBoolean=wi,e.isError=k,e.isFalsy=R,e.isFunction=O,e.isNegative=v,e.isNilOrEmpty=Ai,e.isNilOrEmptyString=w,e.isNotEmpty=p,e.isNotNaN=u,e.isNotNil=s,e.isNotNilObject=L,e.isNotNumeric=d,e.isNotRegExp=S,e.isNumber=Je,e.isNumeric=y,e.isObject=b,e.isPlainObject=Oi,e.isPositive=D,e.isPromise=F,e.isRegExp=x,e.isString=I,e.isTruthy=C,e.joinWithDash=Ne,e.joinWithDot=Te,e.joinWithSpace=be,e.joinWithUnderscore=qe,e.keyMirror=lt,e.lastArg=Se,e.listToString=he,e.log=U,e.ltThanLength=Me,e.lteThanLength=Ze,e.mapIndexed=Pi,e.mapKeys=Re,e.mapKeysAndValues=Ce,e.mapKeysWithValue=ut,e.mapOver=Xi,e.mapOverPath=eo,e.mapOverProp=Yi,e.memoizeWithIdentity=At,e.mergeDeepAllWith=vt,e.mergeDeepAllWithKey=wt,e.mergeDeepLeftAll=bt,e.mergeDeepRightAll=pe,e.mergeWithDotPath=Ie,e.noop=G,e.notEmpty=r,e.notEqual=si,e.notEqualToEmptyArray=li,e.notEqualToEmptyObject=pi,e.notEqualToEmptyString=ri,e.notEqualToFalse=ui,e.notEqualToNull=ci,e.notEqualToOne=yi,e.notEqualToTrue=di,e.notEqualToZero=mi,e.notFlipInclude=ft,e.notInclude=gt,e.notNaN=c,e.notNil=l,e.notNumeric=m,e.objOfOver=Ot,e.overHead=ve,e.padLeft=Et,e.padLeftUntil=Nt,e.padRight=jt,e.padRightUntil=Tt,e.pathNotEq=at,e.pathNotSatisfies=ji,e.pipeC=qt,e.propNotEq=ot,e.propNotSatisfies=Ti,e.reduceCallable=B,e.reduceSource=K,e.rejectEq=Oe,e.rejectNil=Ae,e.replicate=nt,e.splitByDot=le,e.splitByNonAlphaNumeric=me,e.startsWithPrefix=X,e.startsWithPrefixIgnoreCase=Y,e.toCamelCase=ge,e.toDotCase=je,e.toEntries=xi,e.toKebabCase=Ee,e.toLowerFirst=ye,e.toPascalCase=fe,e.toScreamingSnakeCase=Pe,e.toSnakeCase=We,e.toUpperFirst=ce,e.toggle=fi,e.trace=_,e.unfoldObjectDots=re,e.uniqAppend=Zi,e.uniqDrop=Ui,e.uniqDropLast=Bi,e.uniqDropLastWhile=Ki,e.uniqDropWhile=zi,e.uniqFilter=Fi,e.uniqLength=Ii,e.uniqMap=Di,e.uniqPrepend=Mi,e.uniqTake=Ci,e.uniqTakeLast=Ri,e.uniqTakeLastWhile=_i,e.uniqTakeWhile=ki,e.valueMirror=pt,e.viewEq=He,e.viewWith=Ve,e.xPairs=M,e.xPairsRight=Pt,Object.defineProperty(e,"__esModule",{value:!0})}));