Comparing version 0.5.6 to 0.5.7
@@ -1,1 +0,1 @@ | ||
function add(a,b){if(b===void 0){return c=>add(a,c);}return a+b;}function adjust(d,e,f){if(e===void 0){return(g,h)=>adjust(d,g,h);}else if(f===void 0){return j=>adjust(d,e,j);}return f.map((k,l)=>{if(l===e){return d(f[e]);}return k;});}function any(m,n){if(n===void 0){return o=>any(m,o);}let p=0;while(p<n.length){if(m(n[p])){return!0;}p++;}return!1;}function append(q,r){if(r===void 0){return s=>append(q,s);}const t=r;t.push(q);return t;}function isFunction(u){return typeof u==="function";}function compose(){const v=arguments;let w=v.length;while(w--){if(!isFunction(v[w])){throw new TypeError();}}return function(){let x=arguments,y=v.length;while(y--){x=[v[y].apply(this,x)];}return x[0];};}function contains(z,A){if(A===void 0){return B=>contains(z,B);}let C=-1,D=!1;while(++C<A.length&&!D){if(equals(A[C],z)){D=!0;}}return D;}function filter(E,F){if(F===void 0){return G=>filter(E,G);}let H=-1,I=0;const J=F.length,K=[];while(++H<J){const L=F[H];if(E(L)){K[I++]=L;}}return K;}function find(M,N){if(N===void 0){return O=>find(M,O);}return N.find(M);}function findIndex(P,Q){if(Q===void 0){return R=>findIndex(P,R);}const S=Q.length;let T=-1;while(++T<S){if(P(Q[T])){return T;}}return-1;}function flatten(U,V){V=V===void 0?[]:V;for(let i=0;i<U.length;i++){if(Array.isArray(U[i])){flatten(U[i],V);}else{V.push(U[i]);}}return V;}function drop(W,a){if(a===void 0){return X=>drop(W,X);}return a.slice(W);}function dropLast(Y,a){if(a===void 0){return Z=>dropLast(Y,Z);}return a.slice(0,-Y);}function equals(a,b){if(b===void 0){return a1=>equals(a,a1);}else if(a===b){return a!==0||1/a===1/b;}const b1=type(a);if(b1!==type(b)){return!1;}if(b1==="Array"){const c1=a,d1=b;return c1.sort().toString()===d1.sort().toString();}if(b1==="Object"){const e1=Object.keys(a);if(e1.length===Object.keys(b).length){if(e1.length===0){return!0;}let f1=!0;e1.map(g1=>{if(f1){const h1=type(a[g1]),i1=type(b[g1]);if(h1===i1){if(h1==="Object"){if(Object.keys(a[g1]).length===Object.keys(b[g1]).length){if(Object.keys(a[g1]).length!==0){if(!equals(a[g1],b[g1])){f1=!1;}}}else{f1=!1;}}else if(!equals(a[g1],b[g1])){f1=!1;}}else{f1=!1;}}});return f1;}}return!1;}function head(a){if(typeof a==="string"){return a[0]||"";}return a[0];}function indexOf(j1,k1){if(k1===void 0){return l1=>indexOf(j1,l1);}let m1=-1;const n1=k1.length;while(++m1<n1){if(k1[m1]===j1){return m1;}}return-1;}function baseSlice(o1,p1,q1){let r1=-1,s1=o1.length;q1=q1>s1?s1:q1;if(q1<0){q1+=s1;}s1=p1>q1?0:q1-p1>>>0;p1>>>=0;const t1=Array(s1);while(++r1<s1){t1[r1]=o1[r1+p1];}return t1;}function init(a){if(typeof a==="string"){return a.slice(0,-1);}return a.length?baseSlice(a,0,-1):[];}function join(u1,v1){if(v1===void 0){return w1=>join(u1,w1);}return v1.join(u1);}function map(fn,y1){if(y1===void 0){return z1=>map(fn,z1);}let A1=-1;const B1=y1.length,C1=Array(B1);while(++A1<B1){C1[A1]=fn(y1[A1]);}return C1;}function last(a){if(typeof a==="string"){return a[a.length-1]||"";}return a[a.length-1];}function length(D1){return D1.length;}function match(E1,F1){if(F1===void 0){return G1=>match(E1,G1);}const H1=F1.match(E1);return H1===null?[]:H1;}function merge(I1,J1){if(J1===void 0){return K1=>merge(I1,K1);}return Object.assign({},I1,J1);}function omit(L1,M1){if(M1===void 0){return N1=>omit(L1,N1);}const O1={};for(key in M1){if(!L1.includes(key)){O1[key]=M1[key];}}return O1;}function path(P1,Q1){if(Q1===void 0){return R1=>path(P1,R1);}let S1=Q1,T1=0;while(T1<P1.length){if(S1===null){return void 0;}S1=S1[P1[T1]];T1++;}return S1;}function pick(U1,V1){if(V1===void 0){return W1=>pick(U1,W1);}const X1={};let Y1=0;while(Y1<U1.length){if(U1[Y1]in V1){X1[U1[Y1]]=V1[U1[Y1]];}Y1++;}return X1;}function prepend(Z1,a2){if(a2===void 0){return b2=>prepend(Z1,b2);}const c2=a2;c2.unshift(Z1);return c2;}function prop(d2,e2){if(e2===void 0){return f2=>prop(d2,f2);}return e2[d2];}function propEq(g2,h2,i2){if(h2===void 0){return(j2,k2)=>propEq(g2,j2,k2);}else if(i2===void 0){return l2=>propEq(g2,h2,l2);}return i2[g2]===h2;}function range(m2,n2){const o2=[];for(let i=m2;i<n2;i++){o2.push(i);}return o2;}function repeat(a,p2){if(p2===void 0){return q2=>repeat(a,q2);}const r2=Array(p2);return r2.fill(a);}function replace(s2,t2,u2){if(t2===void 0){return(v2,w2)=>replace(s2,v2,w2);}else if(u2===void 0){return x2=>replace(s2,t2,x2);}return u2.replace(s2,t2);}function subtract(a,b){if(b===void 0){return y2=>subtract(a,y2);}return a-b;}function sort(fn,A2){if(A2===void 0){return B2=>sort(fn,B2);}const C2=Array.from(A2);return C2.sort(fn);}function sortBy(fn,E2){if(E2===void 0){return F2=>sortBy(fn,F2);}const G2=Array.from(E2);return G2.sort((a,b)=>{const H2=fn(a),I2=fn(b);return H2<I2?-1:H2>I2?1:0;});}function split(J2,K2){if(K2===void 0){return L2=>split(J2,L2);}return K2.split(J2);}function splitEvery(M2,a){if(a===void 0){return N2=>splitEvery(M2,N2);}M2=M2>1?M2:1;const O2=[];let P2=0;while(P2<a.length){O2.push(a.slice(P2,P2+=M2));}return O2;}function tail(Q2){return drop(1,Q2);}function take(R2,a){if(a===void 0){return S2=>take(R2,S2);}else if(typeof a==="string"){return a.slice(0,R2);}return baseSlice(a,0,R2);}function takeLast(T2,a){if(a===void 0){return U2=>takeLast(T2,U2);}const V2=a.length;T2=T2>V2?V2:T2;if(typeof a==="string"){return a.slice(V2-T2);}T2=V2-T2;return baseSlice(a,T2,V2);}function toLower(W2){return W2.toLowerCase();}function toUpper(X2){return X2.toUpperCase();}function test(Y2,Z2){if(Z2===void 0){return a3=>test(Y2,a3);}return Z2.search(Y2)===-1?!1:!0;}function trim(b3){return b3.trim();}function type(a){if(a===null){return"Null";}else if(Array.isArray(a)){return"Array";}else if(typeof a==="boolean"){return"Boolean";}else if(typeof a==="number"){return"Number";}else if(typeof a==="string"){return"String";}else if(a===void 0){return"Undefined";}else if(a instanceof RegExp){return"RegExp";}const c3=a.toString();if(c3.startsWith("async")){return"Async";}else if(c3.includes("function")||c3.includes("=>")){return"Function";}return"Object";}function values(d3){const e3=[];for(key in d3){e3.push(d3[key]);}return e3;}function uniq(f3){let g3=-1;const h3=[];while(++g3<f3.length){const i3=f3[g3];if(!contains(i3,h3)){h3.push(i3);}}return h3;}function update(j3,k3,l3){if(k3===void 0){return(m3,n3)=>update(j3,m3,n3);}else if(l3===void 0){return o3=>update(j3,k3,o3);}const p3=Array.from(l3);return p3.fill(k3,j3,j3+1);}module.exports.add=add;module.exports.adjust=adjust;module.exports.any=any;module.exports.append=append;module.exports.compose=compose;module.exports.contains=contains;module.exports.drop=drop;module.exports.dropLast=dropLast;module.exports.equals=equals;module.exports.filter=filter;module.exports.find=find;module.exports.findIndex=findIndex;module.exports.flatten=flatten;module.exports.head=head;module.exports.indexOf=indexOf;module.exports.init=init;module.exports.join=join;module.exports.last=last;module.exports.length=length;module.exports.map=map;module.exports.match=match;module.exports.merge=merge;module.exports.omit=omit;module.exports.path=path;module.exports.pick=pick;module.exports.prepend=prepend;module.exports.prop=prop;module.exports.propEq=propEq;module.exports.range=range;module.exports.repeat=repeat;module.exports.replace=replace;module.exports.sort=sort;module.exports.sortBy=sortBy;module.exports.split=split;module.exports.splitEvery=splitEvery;module.exports.subtract=subtract;module.exports.tail=tail;module.exports.take=take;module.exports.takeLast=takeLast;module.exports.test=test;module.exports.toLower=toLower;module.exports.toUpper=toUpper;module.exports.trim=trim;module.exports.type=type;module.exports.uniq=uniq;module.exports.update=update;module.exports.values=values; | ||
function add(a,b){if(b===void 0){return c=>add(a,c);}return a+b;}function adjust(d,e,f){if(e===void 0){return(g,h)=>adjust(d,g,h);}else if(f===void 0){return j=>adjust(d,e,j);}return f.map((k,l)=>{if(l===e){return d(f[e]);}return k;});}function any(m,n){if(n===void 0){return o=>any(m,o);}let p=0;while(p<n.length){if(m(n[p])){return!0;}p++;}return!1;}function append(q,r){if(r===void 0){return s=>append(q,s);}const t=r;t.push(q);return t;}function isFunction(u){return typeof u==="function";}function compose(){const v=arguments;let w=v.length;while(w--){if(!isFunction(v[w])){throw new TypeError();}}return function(){let x=arguments,y=v.length;while(y--){x=[v[y].apply(this,x)];}return x[0];};}function contains(z,A){if(A===void 0){return B=>contains(z,B);}let C=-1,D=!1;while(++C<A.length&&!D){if(equals(A[C],z)){D=!0;}}return D;}function filter(E,F){if(F===void 0){return G=>filter(E,G);}let H=-1,I=0;const J=F.length,K=[];while(++H<J){const L=F[H];if(E(L)){K[I++]=L;}}return K;}function find(M,N){if(N===void 0){return O=>find(M,O);}return N.find(M);}function findIndex(P,Q){if(Q===void 0){return R=>findIndex(P,R);}const S=Q.length;let T=-1;while(++T<S){if(P(Q[T])){return T;}}return-1;}function flatten(U,V){V=V===void 0?[]:V;for(let i=0;i<U.length;i++){if(Array.isArray(U[i])){flatten(U[i],V);}else{V.push(U[i]);}}return V;}function drop(W,a){if(a===void 0){return X=>drop(W,X);}return a.slice(W);}function dropLast(Y,a){if(a===void 0){return Z=>dropLast(Y,Z);}return a.slice(0,-Y);}function equals(a,b){if(b===void 0){return a1=>equals(a,a1);}else if(a===b){return a!==0||1/a===1/b;}const b1=type(a);if(b1!==type(b)){return!1;}if(b1==="Array"){const c1=a,d1=b;return c1.sort().toString()===d1.sort().toString();}if(b1==="Object"){const e1=Object.keys(a);if(e1.length===Object.keys(b).length){if(e1.length===0){return!0;}let f1=!0;e1.map(g1=>{if(f1){const h1=type(a[g1]),i1=type(b[g1]);if(h1===i1){if(h1==="Object"){if(Object.keys(a[g1]).length===Object.keys(b[g1]).length){if(Object.keys(a[g1]).length!==0){if(!equals(a[g1],b[g1])){f1=!1;}}}else{f1=!1;}}else if(!equals(a[g1],b[g1])){f1=!1;}}else{f1=!1;}}});return f1;}}return!1;}function head(a){if(typeof a==="string"){return a[0]||"";}return a[0];}function indexOf(j1,k1){if(k1===void 0){return l1=>indexOf(j1,l1);}let m1=-1;const n1=k1.length;while(++m1<n1){if(k1[m1]===j1){return m1;}}return-1;}function baseSlice(o1,p1,q1){let r1=-1,s1=o1.length;q1=q1>s1?s1:q1;if(q1<0){q1+=s1;}s1=p1>q1?0:q1-p1>>>0;p1>>>=0;const t1=Array(s1);while(++r1<s1){t1[r1]=o1[r1+p1];}return t1;}function init(a){if(typeof a==="string"){return a.slice(0,-1);}return a.length?baseSlice(a,0,-1):[];}function join(u1,v1){if(v1===void 0){return w1=>join(u1,w1);}return v1.join(u1);}function map(fn,y1){if(y1===void 0){return z1=>map(fn,z1);}let A1=-1;const B1=y1.length,C1=Array(B1);while(++A1<B1){C1[A1]=fn(y1[A1]);}return C1;}function last(a){if(typeof a==="string"){return a[a.length-1]||"";}return a[a.length-1];}function length(D1){return D1.length;}function match(E1,F1){if(F1===void 0){return G1=>match(E1,G1);}const H1=F1.match(E1);return H1===null?[]:H1;}function merge(I1,J1){if(J1===void 0){return K1=>merge(I1,K1);}return Object.assign({},I1,J1);}function omit(L1,M1){if(M1===void 0){return N1=>omit(L1,N1);}const O1={};for(key in M1){if(!L1.includes(key)){O1[key]=M1[key];}}return O1;}function path(P1,Q1){if(Q1===void 0){return R1=>path(P1,R1);}let S1=Q1,T1=0;while(T1<P1.length){if(S1===null){return void 0;}S1=S1[P1[T1]];T1++;}return S1;}function pick(U1,V1){if(V1===void 0){return W1=>pick(U1,W1);}const X1={};let Y1=0;while(Y1<U1.length){if(U1[Y1]in V1){X1[U1[Y1]]=V1[U1[Y1]];}Y1++;}return X1;}function pluck(Z1,a2){if(a2===void 0){return b2=>pluck(Z1,b2);}const c2=[];map(d2=>{if(!(d2[Z1]===void 0)){c2.push(d2[Z1]);}},a2);return c2;}function prepend(e2,f2){if(f2===void 0){return g2=>prepend(e2,g2);}const h2=f2;h2.unshift(e2);return h2;}function prop(i2,j2){if(j2===void 0){return k2=>prop(i2,k2);}return j2[i2];}function propEq(l2,m2,n2){if(m2===void 0){return(o2,p2)=>propEq(l2,o2,p2);}else if(n2===void 0){return q2=>propEq(l2,m2,q2);}return n2[l2]===m2;}function range(r2,s2){const t2=[];for(let i=r2;i<s2;i++){t2.push(i);}return t2;}function repeat(a,u2){if(u2===void 0){return v2=>repeat(a,v2);}const w2=Array(u2);return w2.fill(a);}function replace(x2,y2,z2){if(y2===void 0){return(A2,B2)=>replace(x2,A2,B2);}else if(z2===void 0){return C2=>replace(x2,y2,C2);}return z2.replace(x2,y2);}function subtract(a,b){if(b===void 0){return D2=>subtract(a,D2);}return a-b;}function sort(fn,F2){if(F2===void 0){return G2=>sort(fn,G2);}const H2=Array.from(F2);return H2.sort(fn);}function sortBy(fn,J2){if(J2===void 0){return K2=>sortBy(fn,K2);}const L2=Array.from(J2);return L2.sort((a,b)=>{const M2=fn(a),N2=fn(b);return M2<N2?-1:M2>N2?1:0;});}function split(O2,P2){if(P2===void 0){return Q2=>split(O2,Q2);}return P2.split(O2);}function splitEvery(R2,a){if(a===void 0){return S2=>splitEvery(R2,S2);}R2=R2>1?R2:1;const T2=[];let U2=0;while(U2<a.length){T2.push(a.slice(U2,U2+=R2));}return T2;}function tail(V2){return drop(1,V2);}function take(W2,a){if(a===void 0){return X2=>take(W2,X2);}else if(typeof a==="string"){return a.slice(0,W2);}return baseSlice(a,0,W2);}function takeLast(Y2,a){if(a===void 0){return Z2=>takeLast(Y2,Z2);}const a3=a.length;Y2=Y2>a3?a3:Y2;if(typeof a==="string"){return a.slice(a3-Y2);}Y2=a3-Y2;return baseSlice(a,Y2,a3);}function toLower(b3){return b3.toLowerCase();}function toUpper(c3){return c3.toUpperCase();}function test(d3,e3){if(e3===void 0){return f3=>test(d3,f3);}return e3.search(d3)===-1?!1:!0;}function trim(g3){return g3.trim();}function type(a){if(a===null){return"Null";}else if(Array.isArray(a)){return"Array";}else if(typeof a==="boolean"){return"Boolean";}else if(typeof a==="number"){return"Number";}else if(typeof a==="string"){return"String";}else if(a===void 0){return"Undefined";}else if(a instanceof RegExp){return"RegExp";}const h3=a.toString();if(h3.startsWith("async")){return"Async";}else if(h3.includes("function")||h3.includes("=>")){return"Function";}return"Object";}function values(i3){const j3=[];for(key in i3){j3.push(i3[key]);}return j3;}function uniq(k3){let l3=-1;const m3=[];while(++l3<k3.length){const n3=k3[l3];if(!contains(n3,m3)){m3.push(n3);}}return m3;}function update(o3,p3,q3){if(p3===void 0){return(r3,s3)=>update(o3,r3,s3);}else if(q3===void 0){return t3=>update(o3,p3,t3);}const u3=Array.from(q3);return u3.fill(p3,o3,o3+1);}function defaultTo(v3,w3){if(arguments.length===1){return x3=>defaultTo(v3,x3);}return w3===void 0||!(type(w3)===type(v3))?v3:w3;}exports.add=add;exports.adjust=adjust;exports.any=any;exports.append=append;exports.compose=compose;exports.contains=contains;exports.defaultTo=defaultTo;exports.drop=drop;exports.dropLast=dropLast;exports.equals=equals;exports.filter=filter;exports.find=find;exports.findIndex=findIndex;exports.flatten=flatten;exports.head=head;exports.indexOf=indexOf;exports.init=init;exports.join=join;exports.last=last;exports.length=length;exports.map=map;exports.match=match;exports.merge=merge;exports.omit=omit;exports.path=path;exports.pick=pick;exports.pluck=pluck;exports.prepend=prepend;exports.prop=prop;exports.propEq=propEq;exports.range=range;exports.repeat=repeat;exports.replace=replace;exports.sort=sort;exports.sortBy=sortBy;exports.split=split;exports.splitEvery=splitEvery;exports.subtract=subtract;exports.tail=tail;exports.take=take;exports.takeLast=takeLast;exports.test=test;exports.toLower=toLower;exports.toUpper=toUpper;exports.trim=trim;exports.type=type;exports.uniq=uniq;exports.update=update;exports.values=values; |
{ | ||
"name": "rambda", | ||
"version": "0.5.6", | ||
"version": "0.5.7", | ||
"description": "Lightweight alternative to Ramda", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
123
rambda.js
@@ -386,2 +386,18 @@ function add(a, b){ | ||
function pluck(keyToPluck,arr){ | ||
if(arr === undefined){ | ||
return arrHolder => pluck(keyToPluck, arrHolder) | ||
} | ||
const willReturn = [] | ||
map( | ||
val =>{ | ||
if(!(val[keyToPluck]===undefined)){ | ||
willReturn.push(val[keyToPluck]) | ||
} | ||
}, | ||
arr | ||
) | ||
return willReturn | ||
} | ||
function prepend(val, arr) { | ||
@@ -583,3 +599,3 @@ if (arr === undefined) { | ||
} | ||
const asStr = a.toString() | ||
@@ -628,48 +644,59 @@ if(asStr.startsWith("async")){ | ||
module.exports.add = add | ||
module.exports.adjust = adjust | ||
module.exports.any = any | ||
module.exports.append = append | ||
module.exports.compose = compose | ||
module.exports.contains = contains | ||
module.exports.drop = drop | ||
module.exports.dropLast = dropLast | ||
module.exports.equals = equals | ||
module.exports.filter = filter | ||
module.exports.find = find | ||
module.exports.findIndex = findIndex | ||
module.exports.flatten = flatten | ||
module.exports.head = head | ||
module.exports.indexOf = indexOf | ||
module.exports.init = init | ||
module.exports.join = join | ||
module.exports.last = last | ||
module.exports.length = length | ||
module.exports.map = map | ||
module.exports.match = match | ||
module.exports.merge = merge | ||
module.exports.omit = omit | ||
module.exports.path = path | ||
module.exports.pick = pick | ||
module.exports.prepend = prepend | ||
module.exports.prop = prop | ||
module.exports.propEq = propEq | ||
module.exports.range = range | ||
module.exports.repeat = repeat | ||
module.exports.replace = replace | ||
module.exports.sort = sort | ||
module.exports.sortBy = sortBy | ||
module.exports.split = split | ||
module.exports.splitEvery = splitEvery | ||
module.exports.subtract = subtract | ||
module.exports.tail = tail | ||
module.exports.take = take | ||
module.exports.takeLast = takeLast | ||
module.exports.test = test | ||
module.exports.toLower = toLower | ||
module.exports.toUpper = toUpper | ||
module.exports.trim = trim | ||
module.exports.type = type | ||
module.exports.uniq = uniq | ||
module.exports.update = update | ||
module.exports.values = values | ||
function defaultTo(defaultArgument, inputArgument){ | ||
if(arguments.length === 1){ | ||
return inputArgumentHolder => defaultTo(defaultArgument,inputArgumentHolder) | ||
} | ||
return inputArgument === undefined || !(type(inputArgument)===type(defaultArgument)) ? | ||
defaultArgument : | ||
inputArgument | ||
} | ||
exports.add = add | ||
exports.adjust = adjust | ||
exports.any = any | ||
exports.append = append | ||
exports.compose = compose | ||
exports.contains = contains | ||
exports.defaultTo = defaultTo | ||
exports.drop = drop | ||
exports.dropLast = dropLast | ||
exports.equals = equals | ||
exports.filter = filter | ||
exports.find = find | ||
exports.findIndex = findIndex | ||
exports.flatten = flatten | ||
exports.head = head | ||
exports.indexOf = indexOf | ||
exports.init = init | ||
exports.join = join | ||
exports.last = last | ||
exports.length = length | ||
exports.map = map | ||
exports.match = match | ||
exports.merge = merge | ||
exports.omit = omit | ||
exports.path = path | ||
exports.pick = pick | ||
exports.pluck = pluck | ||
exports.prepend = prepend | ||
exports.prop = prop | ||
exports.propEq = propEq | ||
exports.range = range | ||
exports.repeat = repeat | ||
exports.replace = replace | ||
exports.sort = sort | ||
exports.sortBy = sortBy | ||
exports.split = split | ||
exports.splitEvery = splitEvery | ||
exports.subtract = subtract | ||
exports.tail = tail | ||
exports.take = take | ||
exports.takeLast = takeLast | ||
exports.test = test | ||
exports.toLower = toLower | ||
exports.toUpper = toUpper | ||
exports.trim = trim | ||
exports.type = type | ||
exports.uniq = uniq | ||
exports.update = update | ||
exports.values = values |
564
README.md
@@ -34,3 +34,3 @@ [![Build Status](https://travis-ci.org/selfrefactor/ils.svg?branch=master)](https://travis-ci.org/selfrefactor/rambda) | ||
``` | ||
https://cdnjs.cloudflare.com/ajax/libs/rambda/0.5.6/webVersion.js | ||
https://cdnjs.cloudflare.com/ajax/libs/rambda/0.5.7/webVersion.js | ||
``` | ||
@@ -60,17 +60,19 @@ | ||
## Disclaimer | ||
## Flowtype | ||
- Documentation of the methods below is scraped from Ramda's website and could be removed in the future, if requested from Ramda's side. | ||
I haven't tested it fully, but the partial test shows that [Ramda | ||
definitions](https://github.com/flowtype/flow-typed/blob/master/definitions/npm/ramda_v0.21.x/flow_v0.28.x-v0.30.x/ramda_v0.21.x.js) can be used. | ||
You need to replace `declare module ramda` with `declare module rambda` on line | ||
10 and store the file as rambda.js in your *flow-typed* folder | ||
## API | ||
## api-list | ||
#### add | ||
- Adds two values. | ||
> add(a: Number, b: Number): Number | ||
```javascript | ||
R.add(2, 3); //=> 5 | ||
R.add(7)(10); //=> 17 | ||
R.add(2, 3) //=> 5 | ||
``` | ||
@@ -80,9 +82,8 @@ | ||
- Applies a function to the value at the given index of an array, returning a | ||
new copy of the array with the element at the given index replaced with the | ||
result of the function application. | ||
> adjust(replaceFn: Function, i:Number, arr:Array): Array | ||
- Replaces `i` index in `arr` with the result of `replaceFn(arr[i])` | ||
```javascript | ||
R.adjust(R.add(10), 1, [0, 1, 2]); //=> [0, 11, 2] | ||
R.adjust(R.add(10))(1)([0, 1, 2]); //=> [0, 11, 2] | ||
R.adjust(a => a + 1, 0, [0, 100]) //=> [1, 100] | ||
``` | ||
@@ -92,12 +93,9 @@ | ||
- Returns true if at least one of elements of the list match the predicate, | ||
false otherwise. | ||
Dispatches to the any method of the second argument, if present. | ||
Acts as a transducer if a transformer is given in list position. | ||
> any(condition: Function, arr: Array): Boolean | ||
- Returns true if at least one member of `arr` returns true, when passed to the `condition` function | ||
```javascript | ||
var lessThan0 = R.flip(R.lt)(0); | ||
var lessThan2 = R.flip(R.lt)(2); | ||
R.any(lessThan0)([1, 2]); //=> false | ||
R.any(lessThan2)([1, 2]); //=> true | ||
R.any(a => a * a > 8)([1, 2, 3]) //=> true | ||
R.any(a => a * a > 10)([1, 2, 3]) //=> false | ||
``` | ||
@@ -107,9 +105,6 @@ | ||
- Returns a new list containing the contents of the given list, followed by | ||
the given element. | ||
> append(valueToAppend: any, arr: Array): Array | ||
```javascript | ||
R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests'] | ||
R.append('tests', []); //=> ['tests'] | ||
R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']] | ||
R.append('foo', ['bar', 'baz']) //=> ['foo', 'bar', 'baz'] | ||
``` | ||
@@ -119,23 +114,34 @@ | ||
- Returns true if the specified value is equal, in R.equals terms, to at | ||
least one element of the given list; false otherwise. | ||
> contains(valueToFind: any, arr: Array): Boolean | ||
Returns true if `valueToFind` is part of `arr` | ||
```javascript | ||
R.contains(3, [1, 2, 3]); //=> true | ||
R.contains(4, [1, 2, 3]); //=> false | ||
R.contains([42], [[42]]); //=> true | ||
R.contains(2, [1, 2]) //=> true | ||
R.contains(3, [1, 2]) //=> false | ||
``` | ||
#### defaultTo | ||
> defaultTo(defaultArgument: T, inputArgument: any): T | ||
Returns `defaultArgument` if `inputArgument` is `undefined` or the type of `inputArgument` is different of the type of `defaultArgument`. | ||
Returns `inputArgument` in any other case. | ||
```javascript | ||
R.defaultTo('foo', undefined) //=> 'foo' | ||
R.defaultTo('foo')('bar') //=> 'bar' | ||
R.defaultTo('foo')(1) //=> 'foo' | ||
``` | ||
#### drop | ||
- Returns all but the first n elements of the given list, string, or | ||
transducer/transformer (or object with a drop method). | ||
Dispatches to the drop method of the second argument, if present. | ||
> drop(howManyToDrop: Number, arrOrStr: Array|String): Array|String | ||
Returns `arrOrStr` with `howManyToDrop` items dropped from the left | ||
```javascript | ||
R.drop(1, ['foo', 'bar', 'baz']); //=> ['bar', 'baz'] | ||
R.drop(2, ['foo', 'bar', 'baz']); //=> ['baz'] | ||
R.drop(3, ['foo', 'bar', 'baz']); //=> [] | ||
R.drop(4, ['foo', 'bar', 'baz']); //=> [] | ||
R.drop(3, 'ramda'); //=> 'da' | ||
R.drop(1, ['foo', 'bar', 'baz']) //=> ['bar', 'baz'] | ||
R.drop(1, 'foo') //=> 'oo' | ||
``` | ||
@@ -145,10 +151,9 @@ | ||
- Returns a list containing all but the last n elements of the given list. | ||
> dropLast(howManyToDrop: Number, arrOrStr: Array|String): Array|String | ||
Returns `arrOrStr` with `howManyToDrop` items dropped from the right | ||
```javascript | ||
R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar'] | ||
R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo'] | ||
R.dropLast(3, ['foo', 'bar', 'baz']); //=> [] | ||
R.dropLast(4, ['foo', 'bar', 'baz']); //=> [] | ||
R.dropLast(3, 'ramda'); //=> 'ra' | ||
R.dropLast(1, ['foo', 'bar', 'baz']) //=> ['foo', 'bar'] | ||
R.dropLast(1, 'foo') //=> 'fo' | ||
``` | ||
@@ -158,15 +163,12 @@ | ||
- Returns true if its arguments are equivalent, false otherwise. Handles | ||
cyclical data structures. | ||
Dispatches symmetrically to the equals methods of both arguments, if | ||
present. | ||
> equals(a: any, b: any): Boolean | ||
- Returns equality match between `a` and `b` | ||
Doesn't handles cyclical data structures | ||
```javascript | ||
R.equals(1, 1); //=> true | ||
R.equals(1, '1'); //=> false | ||
R.equals([1, 2, 3], [1, 2, 3]); //=> true | ||
var a = {}; a.v = a; | ||
var b = {}; b.v = b; | ||
R.equals(a, b); //=> true | ||
R.equals(1, 1) //=> true | ||
R.equals({}, {}) //=> false | ||
R.equals([1, 2, 3], [1, 2, 3]) //=> true | ||
``` | ||
@@ -176,14 +178,10 @@ | ||
- Takes a predicate and a "filterable", and returns a new filterable of the | ||
same type containing the members of the given filterable which satisfy the | ||
given predicate. | ||
Dispatches to the filter method of the second argument, if present. | ||
Acts as a transducer if a transformer is given in list position. | ||
> filter(filterFn: Function, arr: Array): Array | ||
Filters `arr` throw boolean returning `filterFn` | ||
```javascript | ||
var isEven = n => n % 2 === 0; | ||
const filterFn = a => a % 2 === 0 | ||
R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4] | ||
R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} | ||
R.filter(filterFn, [1, 2, 3, 4]) //=> [2, 4] | ||
``` | ||
@@ -193,11 +191,10 @@ | ||
- Returns the first element of the list which matches the predicate, or | ||
undefined if no element matches. | ||
Dispatches to the find method of the second argument, if present. | ||
Acts as a transducer if a transformer is given in list position. | ||
> find(findFn: Function, arr: Array<T>): T|undefined | ||
Returns `undefined` or the first element of `arr` satisfying `findFn` | ||
```javascript | ||
var xs = [{a: 1}, {a: 2}, {a: 3}]; | ||
R.find(R.propEq('a', 2))(xs); //=> {a: 2} | ||
R.find(R.propEq('a', 4))(xs); //=> undefined | ||
const findFn = a => R.type(a.foo) === "Number" | ||
const arr = [{foo: "bar"}, {foo: 1}] | ||
R.find(findFn, arr) //=> {foo: 1} | ||
``` | ||
@@ -207,11 +204,10 @@ | ||
- Returns the index of the first element of the list which matches the | ||
predicate, or -1 if no element matches. | ||
Dispatches to the findIndex method of the second argument, if present. | ||
Acts as a transducer if a transformer is given in list position. | ||
> findIndex(findFn: Function, arr: Array): Number | ||
Returns `-1` or the index of the first element of `arr` satisfying `findFn` | ||
```javascript | ||
var xs = [{a: 1}, {a: 2}, {a: 3}]; | ||
R.findIndex(R.propEq('a', 2))(xs); //=> 1 | ||
R.findIndex(R.propEq('a', 4))(xs); //=> -1 | ||
const findFn = a => R.type(a.foo) === "Number" | ||
const arr = [{foo: "bar"}, {foo: 1}] | ||
R.find(findFn, arr) //=> 1 | ||
``` | ||
@@ -221,8 +217,7 @@ | ||
- Returns a new list by pulling every item out of it (and all its sub-arrays) | ||
and putting them in a new array, depth-first. | ||
> flatten(arr: Array): Array | ||
```javascript | ||
R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]); | ||
//=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] | ||
R.flatten([ 1, [ 2, [ 3 ] ] ] | ||
//=> [ 1, 2, 3 ] | ||
``` | ||
@@ -232,11 +227,9 @@ | ||
- Returns the first element of the given list or string. In some libraries | ||
this function is named first. | ||
> head(arrOrStr: Array|String): any | ||
- Returns the first element of `arrOrStr` | ||
```javascript | ||
R.head(['fi', 'fo', 'fum']); //=> 'fi' | ||
R.head([]); //=> undefined | ||
R.head('abc'); //=> 'a' | ||
R.head(''); //=> '' | ||
R.head([1, 2, 3]) //=> 1 | ||
R.head('foo') //=> 'f' | ||
``` | ||
@@ -246,9 +239,8 @@ | ||
- Returns the position of the first occurrence of an item in an array, or -1 | ||
if the item is not included in the array. R.equals is used to determine | ||
equality. | ||
> indexOf(valueToFind: any, arr: Array): Number | ||
Returns `-1` or the index of the first element of `arr` equal of `valueToFind` | ||
```javascript | ||
R.indexOf(3, [1,2,3,4]); //=> 2 | ||
R.indexOf(10, [1,2,3,4]); //=> -1 | ||
R.indexOf(1, [1, 2]) //=> 0 | ||
``` | ||
@@ -258,14 +250,9 @@ | ||
- Returns all but the last element of the given list or string. | ||
> init(arrOrStr: Array|String): Array|String | ||
- Returns all but the last element of `arrOrStr` | ||
```javascript | ||
R.init([1, 2, 3]); //=> [1, 2] | ||
R.init([1, 2]); //=> [1] | ||
R.init([1]); //=> [] | ||
R.init([]); //=> [] | ||
R.init('abc'); //=> 'ab' | ||
R.init('ab'); //=> 'a' | ||
R.init('a'); //=> '' | ||
R.init(''); //=> '' | ||
R.init([1, 2, 3]) //=> [1, 2] | ||
R.init('foo') //=> 'fo' | ||
``` | ||
@@ -275,9 +262,6 @@ | ||
- Returns a string made by inserting the separator between each element and | ||
concatenating all the elements into a single string. | ||
> join(separator: String, arr: Array): String | ||
```javascript | ||
var spacer = R.join(' '); | ||
spacer(['a', 2, 3.4]); //=> 'a 2 3.4' | ||
R.join('|', [1, 2, 3]); //=> '1|2|3' | ||
R.join('-', [1, 2, 3]) //=> '1-2-3' | ||
``` | ||
@@ -287,10 +271,9 @@ | ||
- Returns the last element of the given list or string. | ||
> last(arrOrStr: Array|String): any | ||
- Returns the last element of `arrOrStr` | ||
```javascript | ||
R.last(['fi', 'fo', 'fum']); //=> 'fum' | ||
R.last([]); //=> undefined | ||
R.last('abc'); //=> 'c' | ||
R.last(''); //=> '' | ||
R.last(['foo', 'bar', 'baz']) //=> 'baz' | ||
R.last('foo') //=> 'o' | ||
``` | ||
@@ -300,7 +283,6 @@ | ||
- Returns the number of elements in the array by returning list.length. | ||
> length(arrOrStr: Array|String): Number | ||
```javascript | ||
R.length([]); //=> 0 | ||
R.length([1, 2, 3]); //=> 3 | ||
R.length([1, 2, 3]) //=> 3 | ||
``` | ||
@@ -310,18 +292,9 @@ | ||
- Takes a function and | ||
a functor, | ||
applies the function to each of the functor's values, and returns | ||
a functor of the same shape. | ||
Ramda provides suitable map implementations for Array and Object, | ||
so this function may be applied to [1, 2, 3] or {x: 1, y: 2, z: 3}. | ||
Dispatches to the map method of the second argument, if present. | ||
Acts as a transducer if a transformer is given in list position. | ||
Also treats functions as functors and will compose them together. | ||
> map(mapFn: Function, arr: Array): Array | ||
Returns the result of looping through `arr` with `mapFn` | ||
```javascript | ||
var double = x => x * 2; | ||
R.map(double, [1, 2, 3]); //=> [2, 4, 6] | ||
R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6} | ||
const mapFn = x => x * 2; | ||
R.map(mapFn, [1, 2, 3]) //=> [2, 4, 6] | ||
``` | ||
@@ -331,11 +304,6 @@ | ||
- Tests a regular expression against a String. Note that this function will | ||
return an empty array when there are no matches. This differs from | ||
String.prototype.match | ||
which returns null when there are no matches. | ||
> map(regExpression: Regex, str: String): Array | ||
```javascript | ||
R.match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na'] | ||
R.match(/a/, 'b'); //=> [] | ||
R.match(/a/, null); //=> TypeError: null does not have a method named "match" | ||
R.match(/([a-z]a)/g, 'bananas') //=> ['ba', 'na', 'na'] | ||
``` | ||
@@ -345,12 +313,9 @@ | ||
- Create a new object with the own properties of the first object merged with | ||
the own properties of the second object. If a key exists in both objects, | ||
the value from the second object will be used. | ||
> merge(a: Object, b: Object) | ||
Returns result of `Object.assign({}, a, b)` | ||
```javascript | ||
R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); | ||
//=> { 'name': 'fred', 'age': 40 } | ||
var resetToDefault = R.merge(R.__, {x: 0}); | ||
resetToDefault({x: 5, y: 2}); //=> {x: 0, y: 2} | ||
R.merge({ 'foo': 0, 'bar': 1 }, { 'foo': 7 }) | ||
//=> { 'foo': 7, 'bar': 1 } | ||
``` | ||
@@ -360,6 +325,8 @@ | ||
- Returns a partial copy of an object omitting the keys specified. | ||
> omit(propsToOmit: Array<String>, obj: Object): Object | ||
- Returns a partial copy of an `obj` with omitting `propsToOmit` | ||
```javascript | ||
R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3} | ||
R.omit(['a', 'd'], {a: 1, b: 2, c: 3}) //=> {b: 2, c: 3} | ||
``` | ||
@@ -369,7 +336,9 @@ | ||
- Retrieve the value at a given path. | ||
> path(pathToSearch: Array<String>, obj: Object): any | ||
- Retrieve the value at `pathToSearch` in object `obj` | ||
```javascript | ||
R.path(['a', 'b'], {a: {b: 2}}); //=> 2 | ||
R.path(['a', 'b'], {c: {b: 2}}); //=> undefined | ||
R.path(['a', 'b'], {a: {b: 2}}) //=> 2 | ||
R.path(['a', 'c'], {a: {b: 2}}) //=> undefined | ||
``` | ||
@@ -379,27 +348,35 @@ | ||
- Returns a partial copy of an object containing only the keys specified. If | ||
the key does not exist, the property is ignored. | ||
> pick(propsToPick: Array<String>, obj: Object): Object | ||
- Returns a partial copy of an `obj` containing only `propsToPick` properties | ||
```javascript | ||
R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} | ||
R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1} | ||
R.pick(['a', 'c'], {a: 1, b: 2}) //=> {a: 1} | ||
``` | ||
#### pluck | ||
> pluck(prop: String, arr: Array<Object>): Array | ||
- Returns list of the values of property `prop` taken from the objects in `arr` | ||
```javascript | ||
R.pluck('a')([{a: 1}, {a: 2}]) //=> [1, 2] | ||
``` | ||
#### prepend | ||
- Returns a new list with the given element at the front, followed by the | ||
contents of the list. | ||
> prepend(valueToPrepend: any, arr: Array): Array | ||
```javascript | ||
R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum'] | ||
R.prepend('foo', ['bar', 'baz']) //=> ['foo', 'bar', 'baz'] | ||
``` | ||
#### prop | ||
#### prop(propToFind: String, obj: Object): any | ||
- Returns a function that when supplied an object returns the indicated | ||
property of that object, if it exists. | ||
Returns `undefined` or the value of property `propToFind` in `obj` | ||
```javascript | ||
R.prop('x', {x: 100}); //=> 100 | ||
R.prop('x', {}); //=> undefined | ||
R.prop('x', {x: 100}) //=> 100 | ||
R.prop('x', {}) //=> undefined | ||
``` | ||
@@ -409,13 +386,11 @@ | ||
- Returns true if the specified object property is equal, in R.equals | ||
terms, to the given value; false otherwise. | ||
> propEq(propToFind: String, valueToMatch: any, obj: Object): Boolean | ||
Returns true if `obj` has property `propToFind` and its value is equal to `valueToMatch` | ||
```javascript | ||
var abby = {name: 'Abby', age: 7, hair: 'blond'}; | ||
var fred = {name: 'Fred', age: 12, hair: 'brown'}; | ||
var rusty = {name: 'Rusty', age: 10, hair: 'brown'}; | ||
var alois = {name: 'Alois', age: 15, disposition: 'surly'}; | ||
var kids = [abby, fred, rusty, alois]; | ||
var hasBrownHair = R.propEq('hair', 'brown'); | ||
R.filter(hasBrownHair, kids); //=> [fred, rusty] | ||
const propToFind = "foo" | ||
const valueToMatch = 0 | ||
R.propEq(propToFind, valueToMatch)({foo: 0}) //=> true | ||
R.propEq(propToFind, valueToMatch)({foo: 1}) //=> false | ||
``` | ||
@@ -425,7 +400,8 @@ | ||
- Returns a list of numbers from from (inclusive) to to (exclusive). | ||
> range(start: Number, end: Number): Array<Number> | ||
- Returns a array of numbers from `start`(inclusive) to `end`(exclusive) | ||
```javascript | ||
R.range(1, 5); //=> [1, 2, 3, 4] | ||
R.range(50, 53); //=> [50, 51, 52] | ||
R.range(0, 2) //=> [0, 1] | ||
``` | ||
@@ -435,10 +411,6 @@ | ||
- Returns a fixed list of size n containing a specified identical value. | ||
> repeat(valueToRepeat: T, num: Number): Array<T> | ||
```javascript | ||
R.repeat('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi'] | ||
var obj = {}; | ||
var repeatedObjs = R.repeat(obj, 5); //=> [{}, {}, {}, {}, {}] | ||
repeatedObjs[0] === repeatedObjs[1]; //=> true | ||
R.repeat('foo', 2) //=> ['foo', 'foo'] | ||
``` | ||
@@ -448,10 +420,10 @@ | ||
- Replace a substring or regex match in a string with a replacement. | ||
> replace(strOrRegex: String|Regex, replacer: String, str: String): String | ||
Replace `strOrRegex` found in `str` with `replacer` | ||
```javascript | ||
R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo' | ||
R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo' | ||
// Use the "g" (global) flag to replace all occurrences: | ||
R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar' | ||
R.replace('foo', 'bar', 'foo foo') //=> 'bar foo' | ||
R.replace(/foo/, 'bar', 'foo foo') //=> 'bar foo' | ||
R.replace(/foo/g, 'bar', 'foo foo') //=> 'bar bar' | ||
``` | ||
@@ -461,11 +433,11 @@ | ||
- Returns a copy of the list, sorted according to the comparator function, | ||
which should accept two values at a time and return a negative number if the | ||
first value is smaller, a positive number if it's larger, and zero if they | ||
are equal. Please note that this is a copy of the list. It does not | ||
modify the original. | ||
> sort(sortFn: Function, arr: Array): Array | ||
Returns copy of `arr` sorted by `sortFn` | ||
`sortFn` must return `Number` | ||
```javascript | ||
var diff = function(a, b) { return a - b; }; | ||
R.sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7] | ||
const sortFn = (a, b) => a - b | ||
R.sort(sortFn, [3, 1, 2]) //=> [1, 2, 3] | ||
``` | ||
@@ -475,23 +447,13 @@ | ||
- Sorts the list according to the supplied function. | ||
Returns copy of `arr` sorted by `sortFn` | ||
`sortFn` must return value for comparison | ||
```javascript | ||
var sortByFirstItem = R.sortBy(R.prop(0)); | ||
var sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop('name'))); | ||
var pairs = [[-1, 1], [-2, 2], [-3, 3]]; | ||
sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]] | ||
var alice = { | ||
name: 'ALICE', | ||
age: 101 | ||
}; | ||
var bob = { | ||
name: 'Bob', | ||
age: -10 | ||
}; | ||
var clara = { | ||
name: 'clara', | ||
age: 314.159 | ||
}; | ||
var people = [clara, bob, alice]; | ||
sortByNameCaseInsensitive(people); //=> [alice, bob, clara] | ||
const sortFn = obj => obj.foo | ||
R.sortBy(sortFn, [ | ||
{foo: 1}, | ||
{foo: 0} | ||
]) | ||
//=> [{foo: 0}, {foo: 1}] | ||
``` | ||
@@ -501,10 +463,6 @@ | ||
- Splits a string into an array of strings based on the given | ||
separator. | ||
> split(separator: String, str: String): Array | ||
```javascript | ||
var pathComponents = R.split('/'); | ||
R.tail(pathComponents('/usr/local/bin/node')); //=> ['usr', 'local', 'bin', 'node'] | ||
R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd'] | ||
R.split('-', 'a-b-c') //=> ['a', 'b', 'c'] | ||
``` | ||
@@ -514,7 +472,9 @@ | ||
- Splits a collection into slices of the specified length. | ||
> splitEvery(sliceLength: Number, arrOrString: Array|String): Array | ||
- Splits `arrOrStr` into slices of `sliceLength` | ||
```javascript | ||
R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); //=> [[1, 2, 3], [4, 5, 6], [7]] | ||
R.splitEvery(3, 'foobarbaz'); //=> ['foo', 'bar', 'baz'] | ||
R.splitEvery(2, [1, 2, 3]) //=> [[1, 2], [3]] | ||
R.splitEvery(3, 'foobar') //=> ['foo', 'bar'] | ||
``` | ||
@@ -524,13 +484,8 @@ | ||
- Subtracts its second argument from its first argument. | ||
> subtract(a: Number, b: Number): Number | ||
Returns `a` minus `b` | ||
```javascript | ||
R.subtract(10, 8); //=> 2 | ||
var minus5 = R.subtract(R.__, 5); | ||
minus5(17); //=> 12 | ||
var complementaryAngle = R.subtract(90); | ||
complementaryAngle(30); //=> 60 | ||
complementaryAngle(72); //=> 18 | ||
R.subtract(3, 1) //=> 2 | ||
``` | ||
@@ -540,16 +495,9 @@ | ||
- Returns all but the first element of the given list or string (or object | ||
with a tail method). | ||
Dispatches to the slice method of the first argument, if present. | ||
> tail(arrOrStr: Array|String): Array|String | ||
- Returns all but the first element of `arrOrStr` | ||
```javascript | ||
R.tail([1, 2, 3]); //=> [2, 3] | ||
R.tail([1, 2]); //=> [2] | ||
R.tail([1]); //=> [] | ||
R.tail([]); //=> [] | ||
R.tail('abc'); //=> 'bc' | ||
R.tail('ab'); //=> 'b' | ||
R.tail('a'); //=> '' | ||
R.tail(''); //=> '' | ||
R.tail([1, 2, 3]) //=> [2, 3] | ||
R.tail('foo') //=> 'oo' | ||
``` | ||
@@ -559,27 +507,9 @@ | ||
- Returns the first n elements of the given list, string, or | ||
transducer/transformer (or object with a take method). | ||
Dispatches to the take method of the second argument, if present. | ||
> take(num: Number, arrOrStr: Array|String): Array|String | ||
- Returns the first `num` elements of `arrOrStr` | ||
```javascript | ||
R.take(1, ['foo', 'bar', 'baz']); //=> ['foo'] | ||
R.take(2, ['foo', 'bar', 'baz']); //=> ['foo', 'bar'] | ||
R.take(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] | ||
R.take(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] | ||
R.take(3, 'ramda'); //=> 'ram' | ||
var personnel = [ | ||
'Dave Brubeck', | ||
'Paul Desmond', | ||
'Eugene Wright', | ||
'Joe Morello', | ||
'Gerry Mulligan', | ||
'Bob Bates', | ||
'Joe Dodge', | ||
'Ron Crotty' | ||
]; | ||
var takeFive = R.take(5); | ||
takeFive(personnel); | ||
//=> ['Dave Brubeck', 'Paul Desmond', 'Eugene Wright', 'Joe Morello', 'Gerry Mulligan'] | ||
R.take(1, ['foo', 'bar']) //=> ['foo'] | ||
R.take(2, ['foo']) //=> 'fo' | ||
``` | ||
@@ -589,11 +519,9 @@ | ||
- Returns a new list containing the last n elements of the given list. | ||
If n > list.length, returns a list of list.length elements. | ||
> takeLast(num: Number, arrOrStr: Array|String): Array|String | ||
- Returns the last `num` elements of `arrOrStr` | ||
```javascript | ||
R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz'] | ||
R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz'] | ||
R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] | ||
R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] | ||
R.takeLast(3, 'ramda'); //=> 'mda' | ||
R.takeLast(1, ['foo', 'bar']) //=> ['bar'] | ||
R.takeLast(2, ['foo']) //=> 'oo' | ||
``` | ||
@@ -603,7 +531,9 @@ | ||
- Determines whether a given string matches a given regular expression. | ||
> test(regExpression: Regex, str: String): Boolean | ||
- Determines whether `str` matches `regExpression` | ||
```javascript | ||
R.test(/^x/, 'xyz'); //=> true | ||
R.test(/^y/, 'xyz'); //=> false | ||
R.test(/^f/, 'foo') //=> true | ||
R.test(/^f/, 'bar') //=> false | ||
``` | ||
@@ -613,6 +543,6 @@ | ||
- The lower case version of a string. | ||
> toLower(str: String): String | ||
```javascript | ||
R.toLower('XYZ'); //=> 'xyz' | ||
R.toLower('FOO') //=> 'foo' | ||
``` | ||
@@ -622,6 +552,6 @@ | ||
- The upper case version of a string. | ||
> toUpper(str: String): String | ||
```javascript | ||
R.toUpper('abc'); //=> 'ABC' | ||
R.toUpper('foo') //=> 'FOO' | ||
``` | ||
@@ -631,7 +561,5 @@ | ||
- Removes (strips) whitespace from both ends of the string. | ||
> trim(str: String): String | ||
```javascript | ||
R.trim(' xyz '); //=> 'xyz' | ||
R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z'] | ||
R.trim(' foo ') //=> 'foo' | ||
``` | ||
@@ -641,15 +569,14 @@ | ||
- Gives a single-word string description of the (native) type of a value, | ||
returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not | ||
attempt to distinguish user Object types any further, reporting them all as | ||
'Object'. | ||
> type(a: any): String | ||
```javascript | ||
R.type({}); //=> "Object" | ||
R.type(1); //=> "Number" | ||
R.type(false); //=> "Boolean" | ||
R.type('s'); //=> "String" | ||
R.type(null); //=> "Null" | ||
R.type([]); //=> "Array" | ||
R.type(/[A-z]/); //=> "RegExp" | ||
R.type(() => {}) //=> "Function" | ||
R.type(async () => {}) //=> "Async" | ||
R.type([]) //=> "Array" | ||
R.type({}) //=> "Object" | ||
R.type('s') //=> "String" | ||
R.type(1) //=> "Number" | ||
R.type(false) //=> "Boolean" | ||
R.type(null) //=> "Null" | ||
R.type(/[A-z]/) //=> "RegExp" | ||
``` | ||
@@ -659,9 +586,9 @@ | ||
- Returns a new list containing only one copy of each element in the original | ||
list. R.equals is used to determine equality. | ||
> uniq(arr: Array): Array | ||
- Returns a new array containing only one copy of each element in `arr` | ||
```javascript | ||
R.uniq([1, 1, 2, 1]); //=> [1, 2] | ||
R.uniq([1, '1']); //=> [1, '1'] | ||
R.uniq([[42], [42]]); //=> [[42]] | ||
R.uniq([1, 1, 2, 1]) //=> [1, 2] | ||
R.uniq([1, '1']) //=> [1, '1'] | ||
``` | ||
@@ -671,8 +598,9 @@ | ||
- Returns a new copy of the array with the element at the provided index | ||
replaced with the given value. | ||
> update(i: Number, replaceValue: any, arr: Array): Array | ||
- Returns a new copy of the `arr` with the element at `i` index | ||
replaced with `replaceValue` | ||
```javascript | ||
R.update(1, 11, [0, 1, 2]); //=> [0, 11, 2] | ||
R.update(1)(11)([0, 1, 2]); //=> [0, 11, 2] | ||
R.update(0, "foo", ['bar', 'baz']) //=> ['foo', baz] | ||
``` | ||
@@ -682,8 +610,26 @@ | ||
- Returns a list of all the enumerable own properties of the supplied object. | ||
Note that the order of the output array is not guaranteed across different | ||
JS platforms. | ||
> values(obj: Object): Array | ||
- Returns array with of all values in `obj` | ||
```javascript | ||
R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3] | ||
R.values({a: 1, b: 2}) //=> [1, 2] | ||
``` | ||
## Projects using Rambda | ||
- [I Learn Smarter](https://github.com/selfrefactor/ils) | ||
- [json-validity](https://www.npmjs.com/package/json-validity) | ||
- [log-fn](https://www.npmjs.com/package/log-fn) | ||
- [nightmare-helper](nightmare-helper) | ||
- [string-fn](https://www.npmjs.com/package/string-fn) | ||
- [watch-fn](https://www.npmjs.com/package/watch-fn) | ||
## Articles about Rambda | ||
- [https://survivejs.com/blog/rambda-interview/](https://survivejs.com/blog/rambda-interview/) |
@@ -1,1 +0,1 @@ | ||
(function webpackUniversalModuleDefinition(d,e){if(typeof exports==='object'&&typeof module==='object')module.exports=e();else if(typeof define==='function'&&define.amd)define([],e);else{var a=e();for(var i in a)(typeof exports==='object'?exports:d)[i]=a[i];}})(this,function(){return function(f){var g={};function __webpack_require__(h){if(g[h])return g[h].exports;var j=g[h]={i:h,l:!1,exports:{}};f[h].call(j.exports,j,j.exports,__webpack_require__);j.l=!0;return j.exports;}__webpack_require__.m=f;__webpack_require__.c=g;__webpack_require__.i=function(k){return k;};__webpack_require__.d=function(l,m,n){if(!__webpack_require__.o(l,m)){Object.defineProperty(l,m,{configurable:!1,enumerable:!0,get:n});}};__webpack_require__.n=function(o){var p=o&&o.__esModule?function getDefault(){return o['default'];}:function getModuleExports(){return o;};__webpack_require__.d(p,'a',p);return p;};__webpack_require__.o=function(q,r){return Object.prototype.hasOwnProperty.call(q,r);};__webpack_require__.p="";return __webpack_require__(__webpack_require__.s=1);}([function(s,t){function add(a,b){if(b===void 0){return c=>add(a,c);}return a+b;}function adjust(u,v,w){if(v===void 0){return(x,y)=>adjust(u,x,y);}else if(w===void 0){return z=>adjust(u,v,z);}return w.map((A,B)=>{if(B===v){return u(w[v]);}return A;});}function any(C,D){if(D===void 0){return E=>any(C,E);}let F=0;while(F<D.length){if(C(D[F])){return!0;}F++;}return!1;}function append(G,H){if(H===void 0){return I=>append(G,I);}const J=H;J.push(G);return J;}function isFunction(K){return typeof K==="function";}function compose(){const L=arguments;let M=L.length;while(M--){if(!isFunction(L[M])){throw new TypeError();}}return function(){let N=arguments,O=L.length;while(O--){N=[L[O].apply(this,N)];}return N[0];};}function contains(P,Q){if(Q===void 0){return S=>contains(P,S);}let T=-1,U=!1;while(++T<Q.length&&!U){if(equals(Q[T],P)){U=!0;}}return U;}function filter(V,W){if(W===void 0){return X=>filter(V,X);}let Y=-1,Z=0;const a1=W.length,b1=[];while(++Y<a1){const c1=W[Y];if(V(c1)){b1[Z++]=c1;}}return b1;}function find(fn,e1){if(e1===void 0){return f1=>find(fn,f1);}return e1.find(fn);}function findIndex(fn,h1){if(h1===void 0){return i1=>findIndex(fn,i1);}const j1=h1.length;let k1=-1;while(++k1<j1){if(fn(h1[k1])){return k1;}}return-1;}function flatten(l1,m1){m1=m1===void 0?[]:m1;for(let i=0;i<l1.length;i++){if(Array.isArray(l1[i])){flatten(l1[i],m1);}else{m1.push(l1[i]);}}return m1;}function drop(n1,a){if(a===void 0){return o1=>drop(n1,o1);}return a.slice(n1);}function dropLast(p1,a){if(a===void 0){return q1=>dropLast(p1,q1);}return a.slice(0,-p1);}function equals(a,b){if(b===void 0){return r1=>equals(a,r1);}else if(a===b){return a!==0||1/a===1/b;}const s1=type(a);if(s1!==type(b)){return!1;}if(s1==="Array"){const t1=a,u1=b;return t1.sort().toString()===u1.sort().toString();}if(s1==="Object"){const v1=Object.keys(a);if(v1.length===Object.keys(b).length){if(v1.length===0){return!0;}let w1=!0;v1.map(x1=>{if(w1){const y1=type(a[x1]),z1=type(b[x1]);if(y1===z1){if(y1==="Object"){if(Object.keys(a[x1]).length===Object.keys(b[x1]).length){if(Object.keys(a[x1]).length!==0){if(!equals(a[x1],b[x1])){w1=!1;}}}else{w1=!1;}}else if(!equals(a[x1],b[x1])){w1=!1;}}else{w1=!1;}}});return w1;}}return!1;}function head(a){if(typeof a==="string"){return a[0]||"";}return a[0];}function indexOf(A1,B1){if(B1===void 0){return C1=>indexOf(A1,C1);}let D1=-1;const E1=B1.length;while(++D1<E1){if(B1[D1]===A1){return D1;}}return-1;}function baseSlice(F1,G1,H1){let I1=-1,J1=F1.length;H1=H1>J1?J1:H1;if(H1<0){H1+=J1;}J1=G1>H1?0:H1-G1>>>0;G1>>>=0;const K1=Array(J1);while(++I1<J1){K1[I1]=F1[I1+G1];}return K1;}function init(a){if(typeof a==="string"){return a.slice(0,-1);}return a.length?baseSlice(a,0,-1):[];}function join(L1,M1){if(M1===void 0){return N1=>join(L1,N1);}return M1.join(L1);}function map(fn,P1){if(P1===void 0){return Q1=>map(fn,Q1);}let R1=-1;const S1=P1.length,T1=Array(S1);while(++R1<S1){T1[R1]=fn(P1[R1]);}return T1;}function last(a){if(typeof a==="string"){return a[a.length-1]||"";}return a[a.length-1];}function length(U1){return U1.length;}function match(V1,W1){if(W1===void 0){return X1=>match(V1,X1);}const Y1=W1.match(V1);return Y1===null?[]:Y1;}function merge(Z1,a2){if(a2===void 0){return b2=>merge(Z1,b2);}return Object.assign({},Z1,a2);}function omit(c2,d2){if(d2===void 0){return e2=>omit(c2,e2);}const f2={};for(key in d2){if(!c2.includes(key)){f2[key]=d2[key];}}return f2;}function path(g2,h2){if(h2===void 0){return i2=>path(g2,i2);}let j2=h2,k2=0;while(k2<g2.length){if(j2===null){return void 0;}j2=j2[g2[k2]];k2++;}return j2;}function pick(l2,m2){if(m2===void 0){return n2=>pick(l2,n2);}const o2={};let p2=0;while(p2<l2.length){if(l2[p2]in m2){o2[l2[p2]]=m2[l2[p2]];}p2++;}return o2;}function prepend(q2,r2){if(r2===void 0){return s2=>prepend(q2,s2);}const t2=r2;t2.unshift(q2);return t2;}function prop(u2,v2){if(v2===void 0){return w2=>prop(u2,w2);}return v2[u2];}function propEq(x2,y2,z2){if(y2===void 0){return(A2,B2)=>propEq(x2,A2,B2);}else if(z2===void 0){return C2=>propEq(x2,y2,C2);}return z2[x2]===y2;}function range(D2,E2){const F2=[];for(let i=D2;i<E2;i++){F2.push(i);}return F2;}function repeat(a,G2){if(G2===void 0){return H2=>repeat(a,H2);}const I2=Array(G2);return I2.fill(a);}function replace(J2,K2,L2){if(K2===void 0){return(M2,N2)=>replace(J2,M2,N2);}else if(L2===void 0){return O2=>replace(J2,K2,O2);}return L2.replace(J2,K2);}function subtract(a,b){if(b===void 0){return P2=>subtract(a,P2);}return a-b;}function sort(fn,R2){if(R2===void 0){return S2=>sort(fn,S2);}const T2=Array.from(R2);return T2.sort(fn);}function sortBy(fn,V2){if(V2===void 0){return W2=>sortBy(fn,W2);}const X2=Array.from(V2);return X2.sort((a,b)=>{const Y2=fn(a),Z2=fn(b);return Y2<Z2?-1:Y2>Z2?1:0;});}function split(a3,b3){if(b3===void 0){return c3=>split(a3,c3);}return b3.split(a3);}function splitEvery(d3,a){if(a===void 0){return e3=>splitEvery(d3,e3);}d3=d3>1?d3:1;const f3=[];let g3=0;while(g3<a.length){f3.push(a.slice(g3,g3+=d3));}return f3;}function tail(h3){return drop(1,h3);}function take(i3,a){if(a===void 0){return j3=>take(i3,j3);}else if(typeof a==="string"){return a.slice(0,i3);}return baseSlice(a,0,i3);}function takeLast(k3,a){if(a===void 0){return l3=>takeLast(k3,l3);}const m3=a.length;k3=k3>m3?m3:k3;if(typeof a==="string"){return a.slice(m3-k3);}k3=m3-k3;return baseSlice(a,k3,m3);}function toLower(n3){return n3.toLowerCase();}function toUpper(o3){return o3.toUpperCase();}function test(p3,q3){if(q3===void 0){return r3=>test(p3,r3);}return q3.search(p3)===-1?!1:!0;}function trim(s3){return s3.trim();}function type(a){if(a===null){return"Null";}else if(Array.isArray(a)){return"Array";}else if(typeof a==="boolean"){return"Boolean";}else if(typeof a==="number"){return"Number";}else if(typeof a==="string"){return"String";}else if(a===void 0){return"Undefined";}else if(a instanceof RegExp){return"RegExp";}const t3=a.toString();if(t3.startsWith("async")){return"Async";}else if(t3.includes("function")||t3.includes("=>")){return"Function";}return"Object";}function values(u3){const v3=[];for(key in u3){v3.push(u3[key]);}return v3;}function uniq(w3){let x3=-1;const y3=[];while(++x3<w3.length){const z3=w3[x3];if(!contains(z3,y3)){y3.push(z3);}}return y3;}function update(A3,B3,C3){if(B3===void 0){return(D3,E3)=>update(A3,D3,E3);}else if(C3===void 0){return F3=>update(A3,B3,F3);}const G3=Array.from(C3);return G3.fill(B3,A3,A3+1);}s.exports.add=add;s.exports.adjust=adjust;s.exports.any=any;s.exports.append=append;s.exports.compose=compose;s.exports.contains=contains;s.exports.drop=drop;s.exports.dropLast=dropLast;s.exports.equals=equals;s.exports.filter=filter;s.exports.find=find;s.exports.findIndex=findIndex;s.exports.flatten=flatten;s.exports.head=head;s.exports.indexOf=indexOf;s.exports.init=init;s.exports.join=join;s.exports.last=last;s.exports.length=length;s.exports.map=map;s.exports.match=match;s.exports.merge=merge;s.exports.omit=omit;s.exports.path=path;s.exports.pick=pick;s.exports.prepend=prepend;s.exports.prop=prop;s.exports.propEq=propEq;s.exports.range=range;s.exports.repeat=repeat;s.exports.replace=replace;s.exports.sort=sort;s.exports.sortBy=sortBy;s.exports.split=split;s.exports.splitEvery=splitEvery;s.exports.subtract=subtract;s.exports.tail=tail;s.exports.take=take;s.exports.takeLast=takeLast;s.exports.test=test;s.exports.toLower=toLower;s.exports.toUpper=toUpper;s.exports.trim=trim;s.exports.type=type;s.exports.uniq=uniq;s.exports.update=update;s.exports.values=values;},function(H3,I3,J3){const R=J3(0);H3.exports={R:R};}]);}); | ||
(function webpackUniversalModuleDefinition(d,e){if(typeof exports==='object'&&typeof module==='object')module.exports=e();else if(typeof define==='function'&&define.amd)define([],e);else{var a=e();for(var i in a)(typeof exports==='object'?exports:d)[i]=a[i];}})(this,function(){return function(f){var g={};function __webpack_require__(h){if(g[h])return g[h].exports;var j=g[h]={i:h,l:!1,exports:{}};f[h].call(j.exports,j,j.exports,__webpack_require__);j.l=!0;return j.exports;}__webpack_require__.m=f;__webpack_require__.c=g;__webpack_require__.i=function(k){return k;};__webpack_require__.d=function(l,m,n){if(!__webpack_require__.o(l,m)){Object.defineProperty(l,m,{configurable:!1,enumerable:!0,get:n});}};__webpack_require__.n=function(o){var p=o&&o.__esModule?function getDefault(){return o['default'];}:function getModuleExports(){return o;};__webpack_require__.d(p,'a',p);return p;};__webpack_require__.o=function(q,r){return Object.prototype.hasOwnProperty.call(q,r);};__webpack_require__.p="";return __webpack_require__(__webpack_require__.s=1);}([function(s,t){function add(a,b){if(b===void 0){return c=>add(a,c);}return a+b;}function adjust(u,v,w){if(v===void 0){return(x,y)=>adjust(u,x,y);}else if(w===void 0){return z=>adjust(u,v,z);}return w.map((A,B)=>{if(B===v){return u(w[v]);}return A;});}function any(C,D){if(D===void 0){return E=>any(C,E);}let F=0;while(F<D.length){if(C(D[F])){return!0;}F++;}return!1;}function append(G,H){if(H===void 0){return I=>append(G,I);}const J=H;J.push(G);return J;}function isFunction(K){return typeof K==="function";}function compose(){const L=arguments;let M=L.length;while(M--){if(!isFunction(L[M])){throw new TypeError();}}return function(){let N=arguments,O=L.length;while(O--){N=[L[O].apply(this,N)];}return N[0];};}function contains(P,Q){if(Q===void 0){return S=>contains(P,S);}let T=-1,U=!1;while(++T<Q.length&&!U){if(equals(Q[T],P)){U=!0;}}return U;}function filter(V,W){if(W===void 0){return X=>filter(V,X);}let Y=-1,Z=0;const a1=W.length,b1=[];while(++Y<a1){const c1=W[Y];if(V(c1)){b1[Z++]=c1;}}return b1;}function find(fn,e1){if(e1===void 0){return f1=>find(fn,f1);}return e1.find(fn);}function findIndex(fn,h1){if(h1===void 0){return i1=>findIndex(fn,i1);}const j1=h1.length;let k1=-1;while(++k1<j1){if(fn(h1[k1])){return k1;}}return-1;}function flatten(l1,m1){m1=m1===void 0?[]:m1;for(let i=0;i<l1.length;i++){if(Array.isArray(l1[i])){flatten(l1[i],m1);}else{m1.push(l1[i]);}}return m1;}function drop(n1,a){if(a===void 0){return o1=>drop(n1,o1);}return a.slice(n1);}function dropLast(p1,a){if(a===void 0){return q1=>dropLast(p1,q1);}return a.slice(0,-p1);}function equals(a,b){if(b===void 0){return r1=>equals(a,r1);}else if(a===b){return a!==0||1/a===1/b;}const s1=type(a);if(s1!==type(b)){return!1;}if(s1==="Array"){const t1=a,u1=b;return t1.sort().toString()===u1.sort().toString();}if(s1==="Object"){const v1=Object.keys(a);if(v1.length===Object.keys(b).length){if(v1.length===0){return!0;}let w1=!0;v1.map(x1=>{if(w1){const y1=type(a[x1]),z1=type(b[x1]);if(y1===z1){if(y1==="Object"){if(Object.keys(a[x1]).length===Object.keys(b[x1]).length){if(Object.keys(a[x1]).length!==0){if(!equals(a[x1],b[x1])){w1=!1;}}}else{w1=!1;}}else if(!equals(a[x1],b[x1])){w1=!1;}}else{w1=!1;}}});return w1;}}return!1;}function head(a){if(typeof a==="string"){return a[0]||"";}return a[0];}function indexOf(A1,B1){if(B1===void 0){return C1=>indexOf(A1,C1);}let D1=-1;const E1=B1.length;while(++D1<E1){if(B1[D1]===A1){return D1;}}return-1;}function baseSlice(F1,G1,H1){let I1=-1,J1=F1.length;H1=H1>J1?J1:H1;if(H1<0){H1+=J1;}J1=G1>H1?0:H1-G1>>>0;G1>>>=0;const K1=Array(J1);while(++I1<J1){K1[I1]=F1[I1+G1];}return K1;}function init(a){if(typeof a==="string"){return a.slice(0,-1);}return a.length?baseSlice(a,0,-1):[];}function join(L1,M1){if(M1===void 0){return N1=>join(L1,N1);}return M1.join(L1);}function map(fn,P1){if(P1===void 0){return Q1=>map(fn,Q1);}let R1=-1;const S1=P1.length,T1=Array(S1);while(++R1<S1){T1[R1]=fn(P1[R1]);}return T1;}function last(a){if(typeof a==="string"){return a[a.length-1]||"";}return a[a.length-1];}function length(U1){return U1.length;}function match(V1,W1){if(W1===void 0){return X1=>match(V1,X1);}const Y1=W1.match(V1);return Y1===null?[]:Y1;}function merge(Z1,a2){if(a2===void 0){return b2=>merge(Z1,b2);}return Object.assign({},Z1,a2);}function omit(c2,d2){if(d2===void 0){return e2=>omit(c2,e2);}const f2={};for(key in d2){if(!c2.includes(key)){f2[key]=d2[key];}}return f2;}function path(g2,h2){if(h2===void 0){return i2=>path(g2,i2);}let j2=h2,k2=0;while(k2<g2.length){if(j2===null){return void 0;}j2=j2[g2[k2]];k2++;}return j2;}function pick(l2,m2){if(m2===void 0){return n2=>pick(l2,n2);}const o2={};let p2=0;while(p2<l2.length){if(l2[p2]in m2){o2[l2[p2]]=m2[l2[p2]];}p2++;}return o2;}function pluck(q2,r2){if(r2===void 0){return s2=>pluck(q2,s2);}const t2=[];map(u2=>{if(!(u2[q2]===void 0)){t2.push(u2[q2]);}},r2);return t2;}function prepend(v2,w2){if(w2===void 0){return x2=>prepend(v2,x2);}const y2=w2;y2.unshift(v2);return y2;}function prop(z2,A2){if(A2===void 0){return B2=>prop(z2,B2);}return A2[z2];}function propEq(C2,D2,E2){if(D2===void 0){return(F2,G2)=>propEq(C2,F2,G2);}else if(E2===void 0){return H2=>propEq(C2,D2,H2);}return E2[C2]===D2;}function range(I2,J2){const K2=[];for(let i=I2;i<J2;i++){K2.push(i);}return K2;}function repeat(a,L2){if(L2===void 0){return M2=>repeat(a,M2);}const N2=Array(L2);return N2.fill(a);}function replace(O2,P2,Q2){if(P2===void 0){return(R2,S2)=>replace(O2,R2,S2);}else if(Q2===void 0){return T2=>replace(O2,P2,T2);}return Q2.replace(O2,P2);}function subtract(a,b){if(b===void 0){return U2=>subtract(a,U2);}return a-b;}function sort(fn,W2){if(W2===void 0){return X2=>sort(fn,X2);}const Y2=Array.from(W2);return Y2.sort(fn);}function sortBy(fn,a3){if(a3===void 0){return b3=>sortBy(fn,b3);}const c3=Array.from(a3);return c3.sort((a,b)=>{const d3=fn(a),e3=fn(b);return d3<e3?-1:d3>e3?1:0;});}function split(f3,g3){if(g3===void 0){return h3=>split(f3,h3);}return g3.split(f3);}function splitEvery(i3,a){if(a===void 0){return j3=>splitEvery(i3,j3);}i3=i3>1?i3:1;const k3=[];let l3=0;while(l3<a.length){k3.push(a.slice(l3,l3+=i3));}return k3;}function tail(m3){return drop(1,m3);}function take(n3,a){if(a===void 0){return o3=>take(n3,o3);}else if(typeof a==="string"){return a.slice(0,n3);}return baseSlice(a,0,n3);}function takeLast(p3,a){if(a===void 0){return q3=>takeLast(p3,q3);}const r3=a.length;p3=p3>r3?r3:p3;if(typeof a==="string"){return a.slice(r3-p3);}p3=r3-p3;return baseSlice(a,p3,r3);}function toLower(s3){return s3.toLowerCase();}function toUpper(t3){return t3.toUpperCase();}function test(u3,v3){if(v3===void 0){return w3=>test(u3,w3);}return v3.search(u3)===-1?!1:!0;}function trim(x3){return x3.trim();}function type(a){if(a===null){return"Null";}else if(Array.isArray(a)){return"Array";}else if(typeof a==="boolean"){return"Boolean";}else if(typeof a==="number"){return"Number";}else if(typeof a==="string"){return"String";}else if(a===void 0){return"Undefined";}else if(a instanceof RegExp){return"RegExp";}const y3=a.toString();if(y3.startsWith("async")){return"Async";}else if(y3.includes("function")||y3.includes("=>")){return"Function";}return"Object";}function values(z3){const A3=[];for(key in z3){A3.push(z3[key]);}return A3;}function uniq(B3){let C3=-1;const D3=[];while(++C3<B3.length){const E3=B3[C3];if(!contains(E3,D3)){D3.push(E3);}}return D3;}function update(F3,G3,H3){if(G3===void 0){return(I3,J3)=>update(F3,I3,J3);}else if(H3===void 0){return K3=>update(F3,G3,K3);}const L3=Array.from(H3);return L3.fill(G3,F3,F3+1);}function defaultTo(M3,N3){if(arguments.length===1){return O3=>defaultTo(M3,O3);}return N3===void 0||!(type(N3)===type(M3))?M3:N3;}t.add=add;t.adjust=adjust;t.any=any;t.append=append;t.compose=compose;t.contains=contains;t.defaultTo=defaultTo;t.drop=drop;t.dropLast=dropLast;t.equals=equals;t.filter=filter;t.find=find;t.findIndex=findIndex;t.flatten=flatten;t.head=head;t.indexOf=indexOf;t.init=init;t.join=join;t.last=last;t.length=length;t.map=map;t.match=match;t.merge=merge;t.omit=omit;t.path=path;t.pick=pick;t.pluck=pluck;t.prepend=prepend;t.prop=prop;t.propEq=propEq;t.range=range;t.repeat=repeat;t.replace=replace;t.sort=sort;t.sortBy=sortBy;t.split=split;t.splitEvery=splitEvery;t.subtract=subtract;t.tail=tail;t.take=take;t.takeLast=takeLast;t.test=test;t.toLower=toLower;t.toUpper=toUpper;t.trim=trim;t.type=type;t.uniq=uniq;t.update=update;t.values=values;},function(P3,Q3,R3){const R=R3(0);P3.exports={R:R};}]);}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1161066
61
2360
592