diff --git a/.babelrc b/.babelrc new file mode 100644 index 000000000..4a7eb058d --- /dev/null +++ b/.babelrc @@ -0,0 +1,17 @@ +{ + "env": { + "cjs": { + "plugins": [ + "annotate-pure-calls", + "./scripts/transpile/esm-to-cjs", + "./scripts/transpile/wrap-constructor-pattern" + ] + }, + "es": { + "plugins": [ + "annotate-pure-calls", + "./scripts/transpile/wrap-constructor-pattern" + ] + } + }, +} diff --git a/.eslintignore b/.eslintignore index ec1dd06f8..4d48d2222 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,8 @@ **/*.min.js test/index.html test/bundle.js +es/** +src/** dist/** lib/test/** node_modules/** diff --git a/.eslintrc b/.eslintrc index 18900c62f..bc8e2e3ca 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,4 +1,7 @@ { + "parserOptions": { + "sourceType": "module" + }, "env": { "node": true, "mocha": true, diff --git a/.gitignore b/.gitignore index ccc401422..fd8639809 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,9 @@ +/es +/src /lib/bench/report/ /lib/docs/public/ /node_modules/ /npm-debug.log -/ramda.js.tmp /lib/test/bundle.js /tmp /bower_components/ diff --git a/BOOKMARKLET.md b/BOOKMARKLET.md index 345e52d34..5c7d8e468 100644 --- a/BOOKMARKLET.md +++ b/BOOKMARKLET.md @@ -7,8 +7,7 @@ Use this bookmarklet to load Ramda on any website. To "install": 2. Edit the new bookmark and replace the `URL` with the following: -```javascript -javascript:!function(t,n){function r(r){var e=n.createElement("div"),u=n.body;e.innerHTML=r,e.style.position="fixed",e.style.top="20px",e.style.right="20px",e.style.padding="5px 10px",e.style.zIndex="1001",e.style.fontSize="18px",e.style.color="#222",e.style.backgroundColor="#DFF2BF",e.style.textAlign="center",e.style.border="solid 2px black",e.style.borderRadius="25px",u.appendChild(e),t.setTimeout(u.removeChild.bind(u,e),2500)}var e="???";return"undefined"!=typeof t.R?r("This page already using ramda"):(function(){"use strict";var t={"@@functional/placeholder":!0},n=function(t,n){for(var r=0,e=n.length-(t-1),u=new Array(e>=0?e:0);e>r;)u[r]=Array.prototype.slice.call(n,r,r+t),r+=1;return u},r=function(t,n){switch(t){case 0:return function(){return n.apply(this,arguments)};case 1:return function(t){return n.apply(this,arguments)};case 2:return function(t,r){return n.apply(this,arguments)};case 3:return function(t,r,e){return n.apply(this,arguments)};case 4:return function(t,r,e,u){return n.apply(this,arguments)};case 5:return function(t,r,e,u,i){return n.apply(this,arguments)};case 6:return function(t,r,e,u,i,o){return n.apply(this,arguments)};case 7:return function(t,r,e,u,i,o,c){return n.apply(this,arguments)};case 8:return function(t,r,e,u,i,o,c,a){return n.apply(this,arguments)};case 9:return function(t,r,e,u,i,o,c,a,s){return n.apply(this,arguments)};case 10:return function(t,r,e,u,i,o,c,a,s,f){return n.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}},e=function(t){for(var n,r=[];!(n=t.next()).done;)r.push(n.value);return r},u=function(t){return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""))},i=function(t){return function(){return!t.apply(this,arguments)}},o=function(t,n){t=t||[],n=n||[];var r,e=t.length,u=n.length,i=[];for(r=0;e>r;)i[i.length]=t[r],r+=1;for(r=0;u>r;)i[i.length]=n[r],r+=1;return i},c=function(t,n,r){for(var e=0,u=r.length;u>e;){if(t(n,r[e]))return!0;e+=1}return!1},a=function(t,n){for(var r=n.length-1;r>=0&&t(n[r]);)r-=1;return Array.prototype.slice.call(n,0,r+1)},s=function(t,n){for(var r=0,e=n.length,u=[];e>r;)t(n[r])&&(u[u.length]=n[r]),r+=1;return u},f=function(t){return{"@@transducer/value":t,"@@transducer/reduced":!0}},l=function(t){var n=String(t).match(/^function (\w*)/);return null==n?"":n[1]},p=function(t,n){return Object.prototype.hasOwnProperty.call(n,t)},h=function(t){return t},y=function(){var t=Object.prototype.toString;return"[object Arguments]"===t.call(arguments)?function(n){return"[object Arguments]"===t.call(n)}:function(t){return p("callee",t)}}(),g=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)},d=function(t){return"[object Function]"===Object.prototype.toString.call(t)},m=Number.isInteger||function(t){return t<<0===t},v=function(t){return"[object Number]"===Object.prototype.toString.call(t)},b=function(t){return"[object Object]"===Object.prototype.toString.call(t)},w=function(t){return null!=t&&"object"==typeof t&&t["@@functional/placeholder"]===!0},x=function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},A=function(t){return"[object String]"===Object.prototype.toString.call(t)},j=function(t){return"function"==typeof t["@@transducer/step"]},O=function(t,n){for(var r=0,e=n.length,u=Array(e);e>r;)u[r]=t(n[r]),r+=1;return u},S=function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(t),r=1,e=arguments.length;e>r;){var u=arguments[r];if(null!=u)for(var i in u)p(i,u)&&(n[i]=u[i]);r+=1}return n},E=function(t){return[t]},_=function(t,n){return function(){return n.call(this,t.apply(this,arguments))}},k=function(t,n){return function(){var r=this;return t.apply(r,arguments).then(function(t){return n.call(r,t)})}},q=function(t){var n=t.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0");return'"'+n.replace(/"/g,'\\"')+'"'},N=function(t){return t&&t["@@transducer/reduced"]?t:{"@@transducer/value":t,"@@transducer/reduced":!0}},I=function(){var t=function(t){return(10>t?"0":"")+t};return"function"==typeof Date.prototype.toISOString?function(t){return t.toISOString()}:function(n){return n.getUTCFullYear()+"-"+t(n.getUTCMonth()+1)+"-"+t(n.getUTCDate())+"T"+t(n.getUTCHours())+":"+t(n.getUTCMinutes())+":"+t(n.getUTCSeconds())+"."+(n.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"}}(),W={init:function(){return this.xf["@@transducer/init"]()},result:function(t){return this.xf["@@transducer/result"](t)}},C=function(){function t(t){this.f=t}return t.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},t.prototype["@@transducer/result"]=function(t){return t},t.prototype["@@transducer/step"]=function(t,n){return this.f(t,n)},function(n){return new t(n)}}(),T="function"==typeof Object.assign?Object.assign:S,F=function(t,n){return function(){var r=arguments.length;if(0===r)return n();var e=arguments[r-1];return g(e)||"function"!=typeof e[t]?n.apply(this,arguments):e[t].apply(e,Array.prototype.slice.call(arguments,0,r-1))}},P=function(t){return function n(r){return 0===arguments.length||w(r)?n:t.apply(this,arguments)}},R=function(t){return function n(r,e){switch(arguments.length){case 0:return n;case 1:return w(r)?n:P(function(n){return t(r,n)});default:return w(r)&&w(e)?n:w(r)?P(function(n){return t(n,e)}):w(e)?P(function(n){return t(r,n)}):t(r,e)}}},B=function(t){return function n(r,e,u){switch(arguments.length){case 0:return n;case 1:return w(r)?n:R(function(n,e){return t(r,n,e)});case 2:return w(r)&&w(e)?n:w(r)?R(function(n,r){return t(n,e,r)}):w(e)?R(function(n,e){return t(r,n,e)}):P(function(n){return t(r,e,n)});default:return w(r)&&w(e)&&w(u)?n:w(r)&&w(e)?R(function(n,r){return t(n,r,u)}):w(r)&&w(u)?R(function(n,r){return t(n,e,r)}):w(e)&&w(u)?R(function(n,e){return t(r,n,e)}):w(r)?P(function(n){return t(n,e,u)}):w(e)?P(function(n){return t(r,n,u)}):w(u)?P(function(n){return t(r,e,n)}):t(r,e,u)}}},U=function Xu(t,n,e){return function(){for(var u=[],i=0,o=t,c=0;c=arguments.length)?a=n[c]:(a=arguments[i],i+=1),u[c]=a,w(a)||(o-=1),c+=1}return 0>=o?e.apply(this,u):r(o,Xu(t,u,e))}},D=function(t,n,r){return function(){if(0===arguments.length)return r();var e=Array.prototype.slice.call(arguments,0),u=e.pop();if(!g(u)){for(var i=0;i0?t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1):!1:!1}),z=function(t){return function n(r){for(var e,u,i,o=[],c=0,a=r.length;a>c;){if(M(r[c]))for(e=t?n(r[c]):r[c],i=0,u=e.length;u>i;)o[o.length]=e[i],i+=1;else o[o.length]=r[c];c+=1}return o}},L=function(){function t(t,n){this.xf=n,this.f=t,this.all=!0}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=function(t){return this.all&&(t=this.xf["@@transducer/step"](t,!0)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,n){return this.f(n)||(this.all=!1,t=N(this.xf["@@transducer/step"](t,!1))),t},R(function(n,r){return new t(n,r)})}(),K=function(){function t(t,n){this.xf=n,this.f=t,this.any=!1}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=function(t){return this.any||(t=this.xf["@@transducer/step"](t,!1)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.any=!0,t=N(this.xf["@@transducer/step"](t,!0))),t},R(function(n,r){return new t(n,r)})}(),V=function(){function t(t,n){this.xf=n,this.pos=0,this.full=!1,this.acc=new Array(t)}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=function(t){return this.acc=null,this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,n){return this.store(n),this.full?this.xf["@@transducer/step"](t,this.getCopy()):t},t.prototype.store=function(t){this.acc[this.pos]=t,this.pos+=1,this.pos===this.acc.length&&(this.pos=0,this.full=!0)},t.prototype.getCopy=function(){return o(Array.prototype.slice.call(this.acc,this.pos),Array.prototype.slice.call(this.acc,0,this.pos))},R(function(n,r){return new t(n,r)})}(),H=function(){function t(t,n){this.xf=n,this.n=t}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=W.result,t.prototype["@@transducer/step"]=function(t,n){return this.n>0?(this.n-=1,t):this.xf["@@transducer/step"](t,n)},R(function(n,r){return new t(n,r)})}(),$=function(){function t(t,n){this.xf=n,this.pos=0,this.full=!1,this.acc=new Array(t)}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=function(t){return this.acc=null,this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,n){return this.full&&(t=this.xf["@@transducer/step"](t,this.acc[this.pos])),this.store(n),t},t.prototype.store=function(t){this.acc[this.pos]=t,this.pos+=1,this.pos===this.acc.length&&(this.pos=0,this.full=!0)},R(function(n,r){return new t(n,r)})}(),J=function(){function t(t,n){this.xf=n,this.pred=t,this.lastValue=void 0,this.seenFirstValue=!1}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=W.result,t.prototype["@@transducer/step"]=function(t,n){var r=!1;return this.seenFirstValue?this.pred(this.lastValue,n)&&(r=!0):this.seenFirstValue=!0,this.lastValue=n,r?t:this.xf["@@transducer/step"](t,n)},R(function(n,r){return new t(n,r)})}(),X=function(){function t(t,n){this.xf=n,this.f=t}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=W.result,t.prototype["@@transducer/step"]=function(t,n){if(this.f){if(this.f(n))return t;this.f=null}return this.xf["@@transducer/step"](t,n)},R(function(n,r){return new t(n,r)})}(),Y=function(){function t(t,n){this.xf=n,this.f=t}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=W.result,t.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.xf["@@transducer/step"](t,n):t},R(function(n,r){return new t(n,r)})}(),Z=function(){function t(t,n){this.xf=n,this.f=t,this.found=!1}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.found=!0,t=N(this.xf["@@transducer/step"](t,n))),t},R(function(n,r){return new t(n,r)})}(),G=function(){function t(t,n){this.xf=n,this.f=t,this.idx=-1,this.found=!1}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,-1)),this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,n){return this.idx+=1,this.f(n)&&(this.found=!0,t=N(this.xf["@@transducer/step"](t,this.idx))),t},R(function(n,r){return new t(n,r)})}(),Q=function(){function t(t,n){this.xf=n,this.f=t}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=function(t){return this.xf["@@transducer/result"](this.xf["@@transducer/step"](t,this.last))},t.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.last=n),t},R(function(n,r){return new t(n,r)})}(),tt=function(){function t(t,n){this.xf=n,this.f=t,this.idx=-1,this.lastIdx=-1}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=function(t){return this.xf["@@transducer/result"](this.xf["@@transducer/step"](t,this.lastIdx))},t.prototype["@@transducer/step"]=function(t,n){return this.idx+=1,this.f(n)&&(this.lastIdx=this.idx),t},R(function(n,r){return new t(n,r)})}(),nt=function(){function t(t,n){this.xf=n,this.f=t}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=W.result,t.prototype["@@transducer/step"]=function(t,n){return this.xf["@@transducer/step"](t,this.f(n))},R(function(n,r){return new t(n,r)})}(),rt=function(){function t(t,n,r,e){this.valueFn=t,this.valueAcc=n,this.keyFn=r,this.xf=e,this.inputs={}}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=function(t){var n;for(n in this.inputs)if(p(n,this.inputs)&&(t=this.xf["@@transducer/step"](t,this.inputs[n]),t["@@transducer/reduced"])){t=t["@@transducer/value"];break}return this.inputs=null,this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,n){var r=this.keyFn(n);return this.inputs[r]=this.inputs[r]||[r,this.valueAcc],this.inputs[r][1]=this.valueFn(this.inputs[r][1],n),t},U(4,[],function(n,r,e,u){return new t(n,r,e,u)})}(),et=function(){function t(t,n){this.xf=n,this.n=t,this.i=0}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=W.result,t.prototype["@@transducer/step"]=function(t,n){this.i+=1;var r=0===this.n?t:this.xf["@@transducer/step"](t,n);return this.n>=0&&this.i>=this.n?N(r):r},R(function(n,r){return new t(n,r)})}(),ut=function(){function t(t,n){this.xf=n,this.f=t}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=W.result,t.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.xf["@@transducer/step"](t,n):N(t)},R(function(n,r){return new t(n,r)})}(),it=R(function(t,n){return Number(t)+Number(n)}),ot=B(function(t,n,r){if(n>=r.length||n<-r.length)return r;var e=0>n?r.length:0,u=e+n,i=o(r);return i[u]=t(r[u]),i}),ct=R(D(["all"],L,function(t,n){for(var r=0;re?-1:e>u?1:0}),gt=B(function(t,n,r){var e={};for(var u in r)e[u]=r[u];return e[t]=n,e}),dt=R(function(t,n){return r(t.length,function(){return t.apply(n,arguments)})}),mt=B(function(t,n,r){if(t>n)throw new Error("min must not be greater than max in clamp(min, max, value)");return t>r?t:r>n?n:r}),vt=P(function(t){return function(n,r){return t(n,r)?-1:t(r,n)?1:0}}),bt=R(function(t,n){return 1===t?P(n):r(t,U(t,[],n))}),wt=it(-1),xt=R(function(t,n){return null==n||n!==n?t:n}),At=B(function(t,n,r){var e=t(n),u=t(r);return e>u?-1:u>e?1:0}),jt=B(function(t,n,r){for(var e=[],u=0,i=n.length;i>u;)c(t,n[u],r)||c(t,n[u],e)||e.push(n[u]),u+=1;return e}),Ot=R(function(t,n){var r={};for(var e in n)r[e]=n[e];return delete r[t],r}),St=R(function(t,n){return t/n}),Et=R(D(["dropWhile"],X,function(t,n){for(var r=0,e=n.length;e>r&&t(n[r]);)r+=1;return Array.prototype.slice.call(n,r)})),_t=P(function(t){return null!=t&&"function"==typeof t["fantasy-land/empty"]?t["fantasy-land/empty"]():null!=t&&null!=t.constructor&&"function"==typeof t.constructor["fantasy-land/empty"]?t.constructor["fantasy-land/empty"]():null!=t&&"function"==typeof t.empty?t.empty():null!=t&&null!=t.constructor&&"function"==typeof t.constructor.empty?t.constructor.empty():g(t)?[]:A(t)?"":b(t)?{}:y(t)?function(){return arguments}():void 0}),kt=R(function Yu(t,n){var r,e,u,i={};for(e in n)r=t[e],u=typeof r,i[e]="function"===u?r(n[e]):r&&"object"===u?Yu(r,n[e]):n[e];return i}),qt=R(D(["find"],Z,function(t,n){for(var r=0,e=n.length;e>r;){if(t(n[r]))return n[r];r+=1}})),Nt=R(D([],G,function(t,n){for(var r=0,e=n.length;e>r;){if(t(n[r]))return r;r+=1}return-1})),It=R(D([],Q,function(t,n){for(var r=n.length-1;r>=0;){if(t(n[r]))return n[r];r-=1}})),Wt=R(D([],tt,function(t,n){for(var r=n.length-1;r>=0;){if(t(n[r]))return r;r-=1}return-1})),Ct=P(z(!0)),Tt=R(F("forEach",function(t,n){for(var r=n.length,e=0;r>e;)t(n[e]),e+=1;return n})),Ft=P(function(t){for(var n={},r=0;re;){for(var i=e+1;u>i&&t(n[i-1],n[i]);)i+=1;r.push(n.slice(e,i)),e=i}return r}),Rt=R(function(t,n){return t>n}),Bt=R(function(t,n){return t>=n}),Ut=R(p),Dt=R(function(t,n){return t in n}),Mt=R(function(t,n){return t===n?0!==t||1/t===1/n:t!==t&&n!==n}),zt=P(h),Lt=B(function(t,n,r){return bt(Math.max(t.length,n.length,r.length),function(){return t.apply(this,arguments)?n.apply(this,arguments):r.apply(this,arguments)})}),Kt=it(1),Vt=B(function(t,n,r){return s(function(n){return c(t,n,r)},n)}),Ht=B(function(t,n,r){t=t=0?t:r.length;var e=Array.prototype.slice.call(r,0);return e.splice(t,0,n),e}),$t=B(function(t,n,r){return t=t=0?t:r.length,[].concat(Array.prototype.slice.call(r,0,t),n,Array.prototype.slice.call(r,t))}),Jt=R(F("intersperse",function(t,n){for(var r=[],e=0,u=n.length;u>e;)e===u-1?r.push(n[e]):r.push(n[e],t),e+=1;return r})),Xt=R(function(t,n){return null!=n&&n.constructor===t||n instanceof t}),Yt=P(function(t){return null==t}),Zt=function(){var t=!{toString:null}.propertyIsEnumerable("toString"),n=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],r=function(){return arguments.propertyIsEnumerable("length")}(),e=function(t,n){for(var r=0;r=0;)i=n[o],p(i,u)&&!e(c,i)&&(c[c.length]=i),o-=1;return c}:function(t){return Object(t)!==t?[]:Object.keys(t)})}(),Gt=P(function(t){var n,r=[];for(n in t)r[r.length]=n;return r}),Qt=P(function(t){return null!=t&&v(t.length)?t.length:NaN}),tn=R(function(t,n){return n>t}),nn=R(function(t,n){return n>=t}),rn=B(function(t,n,r){for(var e=0,u=r.length,i=[],o=[n];u>e;)o=t(o[0],r[e]),i[e]=o[1],e+=1;return[o[0],i]}),en=B(function(t,n,r){for(var e=r.length-1,u=[],i=[n];e>=0;)i=t(r[e],i[0]),u[e]=i[1],e-=1;return[u,i[0]]}),un=R(function(t,n){return n.match(t)||[]}),on=R(function(t,n){return m(t)?!m(n)||1>n?NaN:(t%n+n)%n:NaN}),cn=R(function(t,n){return n>t?n:t}),an=B(function(t,n,r){return t(r)>t(n)?r:n}),sn=R(function(t,n){var e={};return r(n.length,function(){var r=t.apply(this,arguments);return p(r,e)||(e[r]=n.apply(this,arguments)),e[r]})}),fn=R(function(t,n){return T({},t,n)}),ln=P(function(t){return T.apply(null,[{}].concat(t))}),pn=B(function(t,n,r){var e,u={};for(e in n)p(e,n)&&(u[e]=p(e,r)?t(e,n[e],r[e]):n[e]);for(e in r)p(e,r)&&!p(e,u)&&(u[e]=r[e]);return u}),hn=R(function(t,n){return t>n?n:t}),yn=B(function(t,n,r){return t(r)t?n.length+t:t;return A(n)?n.charAt(r):n[r]}),An=P(function(t){var n=0>t?1:t+1;return bt(n,function(){return xn(t,arguments)})}),jn=B(function(t,n,r){return t(n(r))}),On=R(function(t,n){var r={};return r[t]=n,r}),Sn=P(E),En=P(function(t){var n,e=!1;return r(t.length,function(){return e?n:(e=!0,n=t.apply(this,arguments))})}),_n=R(function(t,n){return t||n}),kn=function(){var t=function(n){return{value:n,map:function(r){return t(r(n))}}};return B(function(n,r,e){return n(function(n){return t(r(n))})(e).value})}(),qn=R(function(t,n){return[t,n]}),Nn=R(function(t,n){for(var r=n,e=0;e0&&t(Nn(n,r))}),Cn=R(function(t,n){for(var r={},e=0;ee;){var i=t[e];r[i]=n[i],e+=1}return r}),Fn=R(function(t,n){var r={};for(var e in n)t(n[e],e,n)&&(r[e]=n[e]);return r}),Pn=R(function(t,n){return o([t],n)}),Rn=R(function(t,n){return n[t]}),Bn=B(function(t,n,r){return Xt(t,r[n])}),Un=B(function(t,n,r){return null!=r&&p(n,r)?r[n]:t}),Dn=B(function(t,n,r){return t(r[n])}),Mn=R(function(t,n){for(var r=t.length,e=[],u=0;r>u;)e[u]=n[t[u]],u+=1;return e}),zn=R(function(t,n){if(!v(t)||!v(n))throw new TypeError("Both arguments to range must be numbers");for(var r=[],e=t;n>e;)r.push(e),e+=1;return r}),Ln=B(function(t,n,r){for(var e=r.length-1;e>=0;)n=t(r[e],n),e-=1;return n}),Kn=P(N),Vn=B(function(t,n,r){var e=Array.prototype.slice.call(r,0);return e.splice(t,n),e}),Hn=B(function(t,n,r){return r.replace(t,n)}),$n=P(function(t){return A(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()}),Jn=B(function(t,n,r){for(var e=0,u=r.length,i=[n];u>e;)n=t(n,r[e]),i[e+1]=n,e+=1;return i}),Xn=B(function(t,n,r){return kn(t,at(n),r)}),Yn=B(F("slice",function(t,n,r){return Array.prototype.slice.call(r,t,n)})),Zn=R(function(t,n){return Array.prototype.slice.call(n,0).sort(t)}),Gn=R(function(t,n){return Array.prototype.slice.call(n,0).sort(function(n,r){var e=t(n),u=t(r);return u>e?-1:e>u?1:0})}),Qn=R(function(t,n){return Array.prototype.slice.call(n,0).sort(function(n,r){for(var e=0,u=0;0===e&&u=t)throw new Error("First argument to splitEvery must be a positive integer");for(var r=[],e=0;er&&!t(n[r]);)u.push(n[r]),r+=1;return[u,Array.prototype.slice.call(n,r)]}),er=R(function(t,n){return Number(t)-Number(n)}),ur=P(F("tail",Yn(1,1/0))),ir=R(D(["take"],et,function(t,n){return Yn(0,0>t?1/0:t,n)})),or=R(function(t,n){for(var r=n.length-1;r>=0&&t(n[r]);)r-=1;return Array.prototype.slice.call(n,r+1)}),cr=R(D(["takeWhile"],ut,function(t,n){for(var r=0,e=n.length;e>r&&t(n[r]);)r+=1;return Array.prototype.slice.call(n,0,r)})),ar=R(function(t,n){return t(n),n}),sr=R(function(t,n){var r,e=Number(n),u=0;if(0>e||isNaN(e))throw new RangeError("n must be a non-negative number");for(r=new Array(e);e>u;)r[u]=t(u),u+=1;return r}),fr=P(function(t){var n=[];for(var r in t)p(r,t)&&(n[n.length]=[r,t[r]]);return n}),lr=P(function(t){var n=[];for(var r in t)n[n.length]=[r,t[r]];return n}),pr=P(function(t){for(var n=0,r=[];n=e&&"function"==typeof u;)r=e===t?arguments.length:i+u.length,u=u.apply(this,Array.prototype.slice.call(arguments,i,r)),e+=1,i=r;return u})}),br=R(function(t,n){for(var r=t(n),e=[];r&&r.length;)e[e.length]=r[0],r=t(r[1]);return e}),wr=R(function(t,n){for(var r,e=0,u=n.length,i=[];u>e;)r=n[e],c(t,r,i)||(i[i.length]=r),e+=1;return i}),xr=B(function(t,n,r){return t(r)?r:n(r)}),Ar=B(function(t,n,r){for(var e=r;!t(e);)e=n(e);return e}),jr=B(function(t,n,r){return ot(at(n),t,r)}),Or=R(function(t,n){return bt(n.length,function(){for(var r=[],e=0;eu;)e[u]=t[n[u]],u+=1;return e}),Er=P(function(t){var n,r=[];for(n in t)r[r.length]=t[n];return r}),_r=function(){var t=function(t){return{value:t,"fantasy-land/map":function(){return this}}};return R(function(n,r){return n(t)(r).value})}(),kr=B(function(t,n,r){return t(r)?n(r):r}),qr=R(function(t,n){for(var r in t)if(p(r,t)&&!t[r](n[r]))return!1;return!0}),Nr=R(function(t,n){for(var r,e=0,u=t.length,i=n.length,o=[];u>e;){for(r=0;i>r;)o[o.length]=[t[e],n[r]],r+=1;e+=1}return o}),Ir=R(function(t,n){for(var r=[],e=0,u=Math.min(t.length,n.length);u>e;)r[e]=[t[e],n[e]],e+=1;return r}),Wr=R(function(t,n){for(var r=0,e=Math.min(t.length,n.length),u={};e>r;)u[t[r]]=n[r],r+=1;return u}),Cr=B(function(t,n,r){for(var e=[],u=0,i=Math.min(n.length,r.length);i>u;)e[u]=t(n[u],r[u]),u+=1;return e}),Tr=at(!1),Fr=at(!0),Pr=function Zu(t,n,r,e){var i=function(u){for(var i=n.length,o=0;i>o;){if(t===n[o])return r[o];o+=1}n[o+1]=t,r[o+1]=u;for(var c in t)u[c]=e?Zu(t[c],n,r,!0):t[c];return u};switch(gr(t)){case"Object":return i({});case"Array":return i([]);case"Date":return new Date(t.valueOf());case"RegExp":return u(t);default:return t}},Rr=function(t){return R(function(n,e){return r(Math.max(0,n.length-e.length),function(){return n.apply(this,t(e,arguments))})})},Br=function(t,n){return ir(t=0;){if(r[o]===t)return u[o]===n;o-=1}for(r.push(t),u.push(n),o=i.length-1;o>=0;){var c=i[o];if(!p(c,n)||!Gu(n[c],t[c],r,u))return!1;o-=1}return r.pop(),u.pop(),!0},Dr=function(){function t(t,n,r){for(var e=0,u=r.length;u>e;){if(n=t["@@transducer/step"](n,r[e]),n&&n["@@transducer/reduced"]){n=n["@@transducer/value"];break}e+=1}return t["@@transducer/result"](n)}function n(t,n,r){for(var e=r.next();!e.done;){if(n=t["@@transducer/step"](n,e.value),n&&n["@@transducer/reduced"]){n=n["@@transducer/value"];break}e=r.next()}return t["@@transducer/result"](n)}function r(t,n,r,e){return t["@@transducer/result"](r[e](dt(t["@@transducer/step"],t),n))}var e="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";return function(u,i,o){if("function"==typeof u&&(u=C(u)),M(o))return t(u,i,o);if("function"==typeof o["fantasy-land/reduce"])return r(u,i,o,"fantasy-land/reduce");if(null!=o[e])return n(u,i,o[e]());if("function"==typeof o.next)return n(u,i,o);if("function"==typeof o.reduce)return r(u,i,o,"reduce");throw new TypeError("reduce: list must be array or iterable")}}(),Mr=function(){var t={"@@transducer/init":Array,"@@transducer/step":function(t,n){return t.push(n),t},"@@transducer/result":h},n={"@@transducer/init":String,"@@transducer/step":function(t,n){return t+n},"@@transducer/result":h},r={"@@transducer/init":Object,"@@transducer/step":function(t,n){return T(t,M(n)?On(n[0],n[1]):n)},"@@transducer/result":h};return function(e){if(j(e))return e;if(M(e))return t;if("string"==typeof e)return n;if("object"==typeof e)return r;throw new Error("Cannot create transformer for "+e)}}(),zr=function(){function t(t,n){this.f=t,this.retained=[],this.xf=n}return t.prototype["@@transducer/init"]=W.init,t.prototype["@@transducer/result"]=function(t){return this.retained=null,this.xf["@@transducer/result"](t)},t.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.retain(t,n):this.flush(t,n)},t.prototype.flush=function(t,n){return t=Dr(this.xf["@@transducer/step"],t,this.retained),this.retained=[],this.xf["@@transducer/step"](t,n)},t.prototype.retain=function(t,n){return this.retained.push(n),t},R(function(n,r){return new t(n,r)})}(),Lr=P(function(t){return bt(t.length,function(){var n=0,r=arguments[0],e=arguments[arguments.length-1],u=Array.prototype.slice.call(arguments,0);return u[0]=function(){var t=r.apply(this,o(arguments,[n,e]));return n+=1,t},t.apply(this,u)})}),Kr=B(function Qu(t,n,r){if(0===t.length)return n;var e=t[0];if(t.length>1){var u=!Yt(r)&&p(e,r)?r[e]:m(t[1])?[]:{};n=Qu(Array.prototype.slice.call(t,1),n,u)}if(m(e)&&g(r)){var i=[].concat(r);return i[e]=n,i}return gt(e,n,r)}),Vr=P(function(t){return mn(2,t)}),Hr=P(function(t){return null!=t&&"function"==typeof t.clone?t.clone():Pr(t,[],[],!0)}),$r=P(function(t){return bt(t.length,t)}),Jr=R(function ti(t,n){switch(t.length){case 0:return n;case 1:return m(t[0])?Vn(t[0],1,n):Ot(t[0],n);default:var r=t[0],e=Array.prototype.slice.call(t,1);return null==n[r]?n:m(t[0])?jr(r,ti(e,n[r]),n):gt(r,ti(e,n[r]),n)}}),Xr=R(D(["drop"],H,function(t,n){return Yn(Math.max(0,t),1/0,n)})),Yr=R(D([],$,Br)),Zr=R(D([],zr,a)),Gr=R(function(t,n){return Ur(t,n,[],[])}),Qr=R(D(["filter"],Y,function(t,n){return b(n)?Dr(function(r,e){return t(n[e])&&(r[e]=n[e]),r},{},Zt(n)):s(t,n)})),te=P(function(t){return $r(function(n,r){var e=Array.prototype.slice.call(arguments,0);return e[0]=r,e[1]=n,t.apply(this,e)})}),ne=R(function(t,n){for(var r=Zt(n),e=0;er.length?(e=n,u=r):(e=r,u=n);for(var i=[],o=0;oe;){var i=n[e],o=t[i],c=p(o,u)?u[o]:u[o]=[];c[c.length]=i,e+=1}return u}),ce=P(function(t){for(var n=Zt(t),r=n.length,e=0,u={};r>e;){var i=n[e];u[t[i]]=i,e+=1}return u}),ae=P(function(t){return null!=t&&Gr(t,_t(t))}),se=xn(-1),fe=R(function(t,n){if("function"!=typeof n.lastIndexOf||g(n)){for(var r=n.length-1;r>=0;){if(Gr(n[r],t))return r;r-=1}return-1}return n.lastIndexOf(t)}),le=R(D(["fantasy-land/map","map"],nt,function(t,n){switch(Object.prototype.toString.call(n)){case"[object Function]":return bt(n.length,function(){return t.call(this,n.apply(this,arguments))});case"[object Object]":return Dr(function(r,e){return r[e]=t(n[e]),r},{},Zt(n));default:return O(t,n)}})),pe=R(function(t,n){return Dr(function(r,e){return r[e]=t(n[e],e,n),r},{},Zt(n))}),he=B(function ni(t,n,r){return pn(function(n,r,e){return b(r)&&b(e)?ni(t,r,e):t(n,r,e)},n,r)}),ye=B(function(t,n,r){return pn(function(n,r,e){return t(r,e)},n,r)}),ge=Rr(o),de=Rr(te(o)),me=B(function(t,n,r){return Gr(Nn(t,r),n)}),ve=R(function(t,n){return le(Rn(t),n)}),be=Or(O,[Tn,zt]),we=B(function(t,n,r){return Gr(n,r[t])}),xe=B(Dr),Ae=U(4,[],D([],rt,function(t,n,r,e){return Dr(function(e,u){var i=r(u);return e[i]=t(p(i,e)?e[i]:n,u),e},{},e)})),je=U(4,[],function(t,n,r,e){return Dr(function(r,e){return t(r,e)?n(r,e):N(r)},r,e)}),Oe=R(function(t,n){return Qr(i(t),n)}),Se=R(function(t,n){return sr(at(t),n)}),Ee=R(function(t,n){return Gr(ir(t.length,n),t)}),_e=xe(it,0),ke=R(function(t,n){return Xr(t>=0?n.length-t:0,n)}),qe=bt(4,function(t,n,r,e){return Dr(t("function"==typeof n?C(n):n),r,e)}),Ne=B(function(t,n,r){return wr(t,o(n,r))}),Ie=R(function(t,n){return qr(le(Gr,t),n)}),We=function(){var t=function(t){return{"@@transducer/init":W.init,"@@transducer/result":function(n){return t["@@transducer/result"](n)},"@@transducer/step":function(n,r){var e=t["@@transducer/step"](n,r);return e["@@transducer/reduced"]?f(e):e}}};return function(n){var r=t(n);return{"@@transducer/init":W.init,"@@transducer/result":function(t){return r["@@transducer/result"](t)},"@@transducer/step":function(t,n){return M(n)?Dr(r,t,n):Dr(r,t,[n])}}}}(),Ce=function(t,n,r){var e,u;if("function"==typeof t.indexOf)switch(typeof n){case"number":if(0===n){for(e=1/n;rn;){if(!t[n].apply(this,arguments))return!1;n+=1}return!0})}),Pe=P(function(t){return bt(xe(cn,0,ve("length",t)),function(){for(var n=0,r=t.length;r>n;){if(t[n].apply(this,arguments))return!0;n+=1}return!1})}),Re=R(function(t,n){return"function"==typeof n["fantasy-land/ap"]?n["fantasy-land/ap"](t):"function"==typeof t.ap?t.ap(n):"function"==typeof t?function(r){return t(r)(n(r))}:Dr(function(t,r){return o(t,le(r,n))},[],t)}),Be=P(function ri(t){return t=le(function(t){return"function"==typeof t?t:ri(t)},t),bt(xe(cn,0,ve("length",Sr(t))),function(){var n=arguments;return le(function(t){return ht(t,n)},t)})}),Ue=$r(function(t){return t.apply(this,Array.prototype.slice.call(arguments,1))}),De=R(D(["fantasy-land/chain","chain"],Te,function(t,n){return"function"==typeof n?function(r){return t(n(r))(r)}:z(!1)(le(t,n))})),Me=P(function(t){var n=xe(cn,0,le(function(t){return t[0].length},t));return r(n,function(){for(var n=0;n10)throw new Error("Constructor with greater than ten arguments");return 0===t?function(){return new n}:$r(mn(t,function(t,r,e,u,i,o,c,a,s,f){switch(arguments.length){case 1:return new n(t);case 2:return new n(t,r);case 3:return new n(t,r,e);case 4:return new n(t,r,e,u);case 5:return new n(t,r,e,u,i);case 6:return new n(t,r,e,u,i,o);case 7:return new n(t,r,e,u,i,o,c);case 8:return new n(t,r,e,u,i,o,c,a);case 9:return new n(t,r,e,u,i,o,c,a,s);case 10:return new n(t,r,e,u,i,o,c,a,s,f)}}))}),Le=R(function(t,n){return bt(xe(cn,0,ve("length",n)),function(){var r=arguments,e=this;return t.apply(e,O(function(t){return t.apply(e,r)},n))})}),Ke=Ae(function(t,n){return t+1},0),Ve=R(D([],J,function(t,n){var r=[],e=1,u=n.length;if(0!==u)for(r[0]=n[0];u>e;)t(se(r),n[e])||(r[r.length]=n[e]),e+=1;return r})),He=R(function(t,n){return Gr(ke(t.length,n),t)}),$e=B(function(t,n,r){return Gr(t(n),t(r))}),Je=B(function(t,n,r){return Gr(n[t],r[t])}),Xe=R(F("groupBy",Ae(function(t,n){return null==t&&(t=[]),t.push(n),t},null))),Ye=Ae(function(t,n){return n},null),Ze=R(function(t,n){return"function"!=typeof n.indexOf||g(n)?Ce(n,t,0):n.indexOf(t)}),Ge=P(function(t){return Le(function(){return Array.prototype.slice.call(arguments,0)},t)}),Qe=R(function(t,n){return function(r){return function(e){return le(function(t){return n(t,e)},r(t(e)))}}}),tu=P(function(t){return Qe(xn(t),jr(t))}),nu=P(function(t){return Qe(Nn(t),Kr(t))}),ru=P(function(t){return Qe(Rn(t),gt(t))}),eu=R(function(t,n){var r=bt(t,n);return bt(t,function(){return Dr(Re,le(r,arguments[0]),Array.prototype.slice.call(arguments,1))})}),uu=P(function(t){return _e(t)/t.length}),iu=P(function(t){var n=t.length;if(0===n)return NaN;var r=2-n%2,e=(n-r)/2;return uu(Array.prototype.slice.call(t,0).sort(function(t,n){return n>t?-1:t>n?1:0}).slice(e,e+r))}),ou=R(function(t,n){return he(function(t,n,r){return n},t,n)}),cu=R(function(t,n){return he(function(t,n,r){return r},t,n)}),au=B(function(t,n,r){return he(function(n,r,e){return t(r,e)},n,r)}),su=Ge([Qr,Oe]),fu=function(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return r(arguments[0].length,xe(_,arguments[0],ur(arguments)))},lu=function(){if(0===arguments.length)throw new Error("pipeP requires at least one argument");return r(arguments[0].length,xe(k,arguments[0],ur(arguments)))},pu=xe(dn,1),hu=R(function(t,n){return"function"==typeof n.sequence?n.sequence(t):Ln(function(t,n){return Re(le(Pn,t),n)},t([]),n)}),yu=B(function(t,n,r){return"function"==typeof r["fantasy-land/traverse"]?r["fantasy-land/traverse"](n,t):hu(t,le(n,r))}),gu=De(h),du=function(t,n){return Ce(n,t,0)>=0},mu=function ei(t,n){var r=function(r){var e=n.concat([t]);return du(r,e)?"":ei(r,e)},e=function(t,n){return O(function(n){return q(n)+": "+r(t[n])},n.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+O(r,t).join(", ")+"))";case"[object Array]":return"["+O(r,t).concat(e(t,Oe(function(t){return/^\d+$/.test(t)},Zt(t)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof t?"new Boolean("+r(t.valueOf())+")":t.toString();case"[object Date]":return"new Date("+(isNaN(t.valueOf())?r(NaN):q(I(t)))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof t?"new Number("+r(t.valueOf())+")":1/t===-(1/0)?"-0":t.toString(10);case"[object String]":return"object"==typeof t?"new String("+r(t.valueOf())+")":q(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){var u=t.toString();if("[object Object]"!==u)return u}return"{"+e(t,Zt(t)).join(", ")+"}"}},vu=function(){if(0===arguments.length)throw new Error("compose requires at least one argument");return fu.apply(this,$n(arguments))},bu=function(){if(0===arguments.length)throw new Error("composeK requires at least one argument");var t=Array.prototype.slice.call(arguments),n=t.pop();return vu(vu.apply(this,le(De,t)),n)},wu=function(){if(0===arguments.length)throw new Error("composeP requires at least one argument");return lu.apply(this,$n(arguments))},xu=P(function(t){return ze(t.length,t)}),Au=R(du),ju=R(function(t,n){for(var r=[],e=0,u=t.length;u>e;)du(t[e],n)||du(t[e],r)||(r[r.length]=t[e]),e+=1;return r}),Ou=P(D([],J(Gr),Ve(Gr))),Su=P(function(t){return eu(t.length,t)}),Eu=R(function(t,n){var r={};for(var e in n)du(e,t)||(r[e]=n[e]);return r}),_u=function(){if(0===arguments.length)throw new Error("pipeK requires at least one argument");return bu.apply(this,$n(arguments))},ku=P(function(t){return mu(t,[])}),qu=R(function(t,n){return Oe(te(du)(t),n)}),Nu=function(){function t(){this._nativeSet="function"==typeof Set?new Set:null,this._items={}}function n(t,n,r){var e,u,i=typeof t;switch(i){case"string":case"number":return 0===t&&1/t===-(1/0)?r._items["-0"]?!0:(n&&(r._items["-0"]=!0),!1):null!==r._nativeSet?n?(e=r._nativeSet.size,r._nativeSet.add(t),u=r._nativeSet.size,u===e):r._nativeSet.has(t):i in r._items?t in r._items[i]?!0:(n&&(r._items[i][t]=!0),!1):(n&&(r._items[i]={},r._items[i][t]=!0),!1);case"boolean":if(i in r._items){var o=t?1:0;return r._items[i][o]?!0:(n&&(r._items[i][o]=!0),!1)}return n&&(r._items[i]=t?[!1,!0]:[!0,!1]),!1;case"function":return null!==r._nativeSet?n?(e=r._nativeSet.size,r._nativeSet.add(t),u=r._nativeSet.size,u===e):r._nativeSet.has(t):i in r._items?du(t,r._items[i])?!0:(n&&r._items[i].push(t),!1):(n&&(r._items[i]=[t]),!1);case"undefined":return r._items[i]?!0:(n&&(r._items[i]=!0),!1);case"object":if(null===t)return r._items["null"]?!0:(n&&(r._items["null"]=!0),!1);default:return i=Object.prototype.toString.call(t),i in r._items?du(t,r._items[i])?!0:(n&&r._items[i].push(t),!1):(n&&(r._items[i]=[t]),!1)}}return t.prototype.add=function(t){return!n(t,!0,this)},t.prototype.has=function(t){return n(t,!1,this)},t}(),Iu=R(function(t,n){return d(t)?function(){return t.apply(this,arguments)&&n.apply(this,arguments)}:Su(st)(t,n)}),Wu=Su(wn),Cu=R(function(t,n){if(g(t)){if(g(n))return t.concat(n);throw new TypeError(ku(n)+" is not an array")}if(A(t)){if(A(n))return t+n;throw new TypeError(ku(n)+" is not a string")}if(null!=t&&d(t["fantasy-land/concat"]))return t["fantasy-land/concat"](n);if(null!=t&&d(t.concat))return t.concat(n);throw new TypeError(ku(t)+' does not have a method named "concat" or "fantasy-land/concat"')}),Tu=R(function(t,n){return d(t)?function(){return t.apply(this,arguments)||n.apply(this,arguments)}:Su(_n)(t,n)}),Fu=R(function(t,n){return bt(t+1,function(){var r=arguments[t];if(null!=r&&d(r[n]))return r[n].apply(r,Array.prototype.slice.call(arguments,0,t));throw new TypeError(ku(r)+' does not have a method named "'+n+'"')})}),Pu=Fu(1,"join"),Ru=sn(function(){return ku(arguments)}),Bu=Fu(1,"split"),Uu=R(function(t,n){return Cu(ju(t,n),ju(n,t))}),Du=B(function(t,n,r){return Cu(jt(t,n,r),jt(t,r,n))}),Mu=R(function(t,n){if(!x(t))throw new TypeError("‘test’ requires a value of type RegExp as its first argument; received "+ku(t));return u(t).test(n)}),zu=Fu(0,"toLowerCase"),Lu=Fu(0,"toUpperCase"),Ku=R(function(t,n){for(var r,e,u=new Nu,i=[],o=0;on.length?(r=t,e=n):(r=n,e=t),Vu(s(te(du)(r),e))}),$u=R(vu(Vu,o)),Ju={F:Tr,T:Fr,__:t,add:it,addIndex:Lr,adjust:ot,all:ct,allPass:Fe,always:at,and:st,any:ft,anyPass:Pe,ap:Re,aperture:lt,append:pt,apply:ht,applySpec:Be,ascend:yt,assoc:gt,assocPath:Kr,binary:Vr,bind:dt,both:Iu,call:Ue,chain:De,clamp:mt,clone:Hr,comparator:vt,complement:Wu,compose:vu,composeK:bu,composeP:wu,concat:Cu,cond:Me,construct:xu,constructN:ze,contains:Au,converge:Le,countBy:Ke,curry:$r,curryN:bt,dec:wt,defaultTo:xt,descend:At,difference:ju,differenceWith:jt,dissoc:Ot,dissocPath:Jr,divide:St,drop:Xr,dropLast:Yr,dropLastWhile:Zr,dropRepeats:Ou,dropRepeatsWith:Ve,dropWhile:Et,either:Tu,empty:_t,endsWith:He,eqBy:$e,eqProps:Je,equals:Gr,evolve:kt,filter:Qr,find:qt,findIndex:Nt,findLast:It,findLastIndex:Wt,flatten:Ct,flip:te,forEach:Tt,forEachObjIndexed:ne,fromPairs:Ft,groupBy:Xe,groupWith:Pt,gt:Rt,gte:Bt,has:Ut,hasIn:Dt,head:re,identical:Mt,identity:zt,ifElse:Lt,inc:Kt,indexBy:Ye,indexOf:Ze,init:ee,innerJoin:Vt,insert:Ht,insertAll:$t,intersection:Hu,intersectionWith:ue,intersperse:Jt,into:ie,invert:oe,invertObj:ce,invoker:Fu,is:Xt,isEmpty:ae,isNil:Yt,join:Pu,juxt:Ge,keys:Zt,keysIn:Gt,last:se,lastIndexOf:fe,length:Qt,lens:Qe,lensIndex:tu,lensPath:nu,lensProp:ru,lift:Su,liftN:eu,lt:tn,lte:nn,map:le,mapAccum:rn,mapAccumRight:en,mapObjIndexed:pe,match:un,mathMod:on,max:cn,maxBy:an,mean:uu,median:iu,memoize:Ru,memoizeWith:sn,merge:fn,mergeAll:ln,mergeDeepLeft:ou,mergeDeepRight:cu,mergeDeepWith:au,mergeDeepWithKey:he,mergeWith:ye,mergeWithKey:pn,min:hn,minBy:yn,modulo:gn,multiply:dn,nAry:mn,negate:vn,none:bn,not:wn,nth:xn,nthArg:An,o:jn,objOf:On,of:Sn,omit:Eu,once:En,or:_n,over:kn,pair:qn,partial:ge,partialRight:de,partition:su,path:Nn,pathEq:me,pathOr:In,pathSatisfies:Wn,pick:Cn,pickAll:Tn,pickBy:Fn,pipe:fu,pipeK:_u,pipeP:lu,pluck:ve,prepend:Pn,product:pu,project:be,prop:Rn,propEq:we,propIs:Bn,propOr:Un,propSatisfies:Dn,props:Mn,range:zn,reduce:xe,reduceBy:Ae,reduceRight:Ln,reduceWhile:je,reduced:Kn,reject:Oe,remove:Vn,repeat:Se,replace:Hn,reverse:$n,scan:Jn,sequence:hu,set:Xn,slice:Yn,sort:Zn,sortBy:Gn,sortWith:Qn,split:Bu,splitAt:tr,splitEvery:nr,splitWhen:rr,startsWith:Ee,subtract:er,sum:_e,symmetricDifference:Uu,symmetricDifferenceWith:Du,tail:ur,take:ir,takeLast:ke,takeLastWhile:or,takeWhile:cr,tap:ar,test:Mu,times:sr,toLower:zu,toPairs:fr,toPairsIn:lr,toString:ku,toUpper:Lu,transduce:qe,transpose:pr,traverse:yu,trim:hr,tryCatch:yr,type:gr,unapply:dr,unary:mr,uncurryN:vr,unfold:br,union:$u,unionWith:Ne,uniq:Vu,uniqBy:Ku,uniqWith:wr,unless:xr,unnest:gu,until:Ar,update:jr,useWith:Or,values:Sr,valuesIn:Er,view:_r,when:kr,where:qr,whereEq:Ie,without:qu,xprod:Nr,zip:Ir,zipObj:Wr,zipWith:Cr};"object"==typeof exports?module.exports=Ju:"function"==typeof define&&define.amd?define(function(){return Ju}):this.R=Ju}.call(this),e="0.24.0",void r("Ramda v"+e+" loaded"))}(window,document); -``` - -[view raw (for select all + copy)](https://gist.githubusercontent.com/aretecode/1dcf06882fd0cbf729f6dbdee07e370e/raw/ac39047f552548ed06a1f55728f4e0f406f86253/ramda.js) + ```javascript + javascript:!function(t,n){function r(r){var e=n.createElement("div"),u=n.body;e.innerHTML=r,e.style.position="fixed",e.style.top="20px",e.style.right="20px",e.style.padding="5px 10px",e.style.zIndex="1001",e.style.fontSize="18px",e.style.color="#222",e.style.backgroundColor="#DFF2BF",e.style.textAlign="center",e.style.border="solid 2px black",e.style.borderRadius="25px",u.appendChild(e),t.setTimeout(u.removeChild.bind(u,e),2500)}var e="???";return"undefined"!=typeof t.R?r("This page already using ramda"):(function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.R={})}(this,function(t){"use strict";function n(t){return null!=t&&"object"==typeof t&&t["@@functional/placeholder"]===!0}function r(t){return function r(e){return 0===arguments.length||n(e)?r:t.apply(this,arguments)}}function e(t){return function e(u,i){switch(arguments.length){case 0:return e;case 1:return n(u)?e:r(function(n){return t(u,n)});default:return n(u)&&n(i)?e:n(u)?r(function(n){return t(n,i)}):n(i)?r(function(n){return t(u,n)}):t(u,i)}}}function u(t,n){t=t||[],n=n||[];var r,e=t.length,u=n.length,i=[];for(r=0;e>r;)i[i.length]=t[r],r+=1;for(r=0;u>r;)i[i.length]=n[r],r+=1;return i}function i(t,n){switch(t){case 0:return function(){return n.apply(this,arguments)};case 1:return function(t){return n.apply(this,arguments)};case 2:return function(t,r){return n.apply(this,arguments)};case 3:return function(t,r,e){return n.apply(this,arguments)};case 4:return function(t,r,e,u){return n.apply(this,arguments)};case 5:return function(t,r,e,u,i){return n.apply(this,arguments)};case 6:return function(t,r,e,u,i,o){return n.apply(this,arguments)};case 7:return function(t,r,e,u,i,o,a){return n.apply(this,arguments)};case 8:return function(t,r,e,u,i,o,a,c){return n.apply(this,arguments)};case 9:return function(t,r,e,u,i,o,a,c,s){return n.apply(this,arguments)};case 10:return function(t,r,e,u,i,o,a,c,s,f){return n.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function o(t,r,e){return function(){for(var u=[],a=0,c=t,s=0;s=arguments.length)?f=r[s]:(f=arguments[a],a+=1),u[s]=f,n(f)||(c-=1),s+=1}return 0>=c?e.apply(this,u):i(c,o(t,u,e))}}function a(t){return function u(i,o,a){switch(arguments.length){case 0:return u;case 1:return n(i)?u:e(function(n,r){return t(i,n,r)});case 2:return n(i)&&n(o)?u:n(i)?e(function(n,r){return t(n,o,r)}):n(o)?e(function(n,r){return t(i,n,r)}):r(function(n){return t(i,o,n)});default:return n(i)&&n(o)&&n(a)?u:n(i)&&n(o)?e(function(n,r){return t(n,r,a)}):n(i)&&n(a)?e(function(n,r){return t(n,o,r)}):n(o)&&n(a)?e(function(n,r){return t(i,n,r)}):n(i)?r(function(n){return t(n,o,a)}):n(o)?r(function(n){return t(i,n,a)}):n(a)?r(function(n){return t(i,o,n)}):t(i,o,a)}}}function c(t){return"function"==typeof t["@@transducer/step"]}function s(t,n,r){return function(){if(0===arguments.length)return r();var e=Array.prototype.slice.call(arguments,0),u=e.pop();if(!qt(u)){for(var i=0;ir;)u[r]=t(n[r]),r+=1;return u}function h(t){return"[object String]"===Object.prototype.toString.call(t)}function y(t){this.f=t}function g(t){return new y(t)}function d(t,n,r){for(var e=0,u=r.length;u>e;){if(n=t["@@transducer/step"](n,r[e]),n&&n["@@transducer/reduced"]){n=n["@@transducer/value"];break}e+=1}return t["@@transducer/result"](n)}function m(t,n,r){for(var e=r.next();!e.done;){if(n=t["@@transducer/step"](n,e.value),n&&n["@@transducer/reduced"]){n=n["@@transducer/value"];break}e=r.next()}return t["@@transducer/result"](n)}function v(t,n,r,e){return t["@@transducer/result"](r[e](Tt(t["@@transducer/step"],t),n))}function w(t,n,r){if("function"==typeof t&&(t=g(t)),Pt(r))return d(t,n,r);if("function"==typeof r["fantasy-land/reduce"])return v(t,n,r,"fantasy-land/reduce");if(null!=r[Ft])return m(t,n,r[Ft]());if("function"==typeof r.next)return m(t,n,r);if("function"==typeof r.reduce)return v(t,n,r,"reduce");throw new TypeError("reduce: list must be array or iterable")}function b(t,n){this.xf=n,this.f=t}function x(t,n){return Object.prototype.hasOwnProperty.call(n,t)}function j(t,n){this.xf=n,this.f=t,this.any=!1}function A(t,n){for(var r=0,e=n.length-(t-1),u=new Array(e>=0?e:0);e>r;)u[r]=Array.prototype.slice.call(n,r,r+t),r+=1;return u}function O(t,n){this.xf=n,this.pos=0,this.full=!1,this.acc=new Array(t)}function S(t){return"[object Function]"===Object.prototype.toString.call(t)}function E(t){return function n(r){for(var e,u,i,o=[],a=0,c=r.length;c>a;){if(Pt(r[a]))for(e=t?n(r[a]):r[a],i=0,u=e.length;u>i;)o[o.length]=e[i],i+=1;else o[o.length]=r[a];a+=1}return o}}function _(t){return{"@@transducer/value":t,"@@transducer/reduced":!0}}function k(t){return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""))}function q(t,n,r,e){var u=function(u){for(var i=n.length,o=0;i>o;){if(t===n[o])return r[o];o+=1}n[o+1]=t,r[o+1]=u;for(var a in t)u[a]=e?q(t[a],n,r,!0):t[a];return u};switch(En(t)){case"Object":return u({});case"Array":return u([]);case"Date":return new Date(t.valueOf());case"RegExp":return k(t);default:return t}}function N(t,n){return function(){return n.call(this,t.apply(this,arguments))}}function I(t,n){return function(){var r=arguments.length;if(0===r)return n();var e=arguments[r-1];return qt(e)||"function"!=typeof e[t]?n.apply(this,arguments):e[t].apply(e,Array.prototype.slice.call(arguments,0,r-1))}}function W(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return i(arguments[0].length,Xt(N,arguments[0],Wn(arguments)))}function C(){if(0===arguments.length)throw new Error("compose requires at least one argument");return W.apply(this,Cn(arguments))}function P(){if(0===arguments.length)throw new Error("composeK requires at least one argument");var t=Array.prototype.slice.call(arguments),n=t.pop();return C(C.apply(this,Ht(On,t)),n)}function T(t,n){return function(){var r=this;return t.apply(r,arguments).then(function(t){return n.call(r,t)})}}function F(){if(0===arguments.length)throw new Error("pipeP requires at least one argument");return i(arguments[0].length,Xt(T,arguments[0],Wn(arguments)))}function R(){if(0===arguments.length)throw new Error("composeP requires at least one argument");return F.apply(this,Cn(arguments))}function B(t){for(var n,r=[];!(n=t.next()).done;)r.push(n.value);return r}function U(t){var n=String(t).match(/^function (\w*)/);return null==n?"":n[1]}function D(t,n,r,e){if(Pn(t,n))return!0;if(En(t)!==En(n))return!1;if(null==t||null==n)return!1;if("function"==typeof t["fantasy-land/equals"]||"function"==typeof n["fantasy-land/equals"])return"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](n)&&"function"==typeof n["fantasy-land/equals"]&&n["fantasy-land/equals"](t);if("function"==typeof t.equals||"function"==typeof n.equals)return"function"==typeof t.equals&&t.equals(n)&&"function"==typeof n.equals&&n.equals(t);switch(En(t)){case"Arguments":case"Array":case"Object":if("function"==typeof t.constructor&&"Promise"===U(t.constructor))return t===n;break;case"Boolean":case"Number":case"String":if(typeof t!=typeof n||!Pn(t.valueOf(),n.valueOf()))return!1;break;case"Date":if(!Pn(t.valueOf(),n.valueOf()))return!1;break;case"Error":return t.name===n.name&&t.message===n.message;case"RegExp":if(t.source!==n.source||t.global!==n.global||t.ignoreCase!==n.ignoreCase||t.multiline!==n.multiline||t.sticky!==n.sticky||t.unicode!==n.unicode)return!1;break;case"Map":case"Set":if(!D(B(t.entries()),B(n.entries()),r,e))return!1;break;case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":break;case"ArrayBuffer":break;default:return!1}var u=Vt(t);if(u.length!==Vt(n).length)return!1;for(var i=r.length-1;i>=0;){if(r[i]===t)return e[i]===n;i-=1}for(r.push(t),e.push(n),i=u.length-1;i>=0;){var o=u[i];if(!x(o,n)||!D(n[o],t[o],r,e))return!1;i-=1}return r.pop(),e.pop(),!0}function M(t,n,r){var e,u;if("function"==typeof t.indexOf)switch(typeof n){case"number":if(0===n){for(e=1/n;r=0}function L(t){var n=t.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0");return'"'+n.replace(/"/g,'\\"')+'"'}function K(t){return function(){return!t.apply(this,arguments)}}function V(t,n){for(var r=0,e=n.length,u=[];e>r;)t(n[r])&&(u[u.length]=n[r]),r+=1;return u}function H(t){return"[object Object]"===Object.prototype.toString.call(t)}function $(t,n){this.xf=n,this.f=t}function J(t,n){var r=function(r){var e=n.concat([t]);return z(r,e)?"":J(r,e)},e=function(t,n){return p(function(n){return L(n)+": "+r(t[n])},n.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+p(r,t).join(", ")+"))";case"[object Array]":return"["+p(r,t).concat(e(t,Dn(function(t){return/^\d+$/.test(t)},Vt(t)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof t?"new Boolean("+r(t.valueOf())+")":t.toString();case"[object Date]":return"new Date("+(isNaN(t.valueOf())?r(NaN):L(Rn(t)))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof t?"new Number("+r(t.valueOf())+")":1/t===-(1/0)?"-0":t.toString(10);case"[object String]":return"object"==typeof t?"new String("+r(t.valueOf())+")":L(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){var u=t.toString();if("[object Object]"!==u)return u}return"{"+e(t,Vt(t)).join(", ")+"}"}}function X(t,n,r,e){this.valueFn=t,this.valueAcc=n,this.keyFn=r,this.xf=e,this.inputs={}}function Y(t,n,r){for(var e=0,u=r.length;u>e;){if(t(n,r[e]))return!0;e+=1}return!1}function Z(t,n){this.xf=n,this.n=t}function G(t,n){this.xf=n,this.n=t,this.i=0}function Q(t,n){return fr(t=0&&t(n[r]);)r-=1;return Array.prototype.slice.call(n,0,r+1)}function rt(t,n){this.f=t,this.retained=[],this.xf=n}function et(t,n){this.xf=n,this.pred=t,this.lastValue=void 0,this.seenFirstValue=!1}function ut(t,n){this.xf=n,this.f=t}function it(t,n){this.xf=n,this.f=t,this.found=!1}function ot(t,n){this.xf=n,this.f=t,this.idx=-1,this.found=!1}function at(t,n){this.xf=n,this.f=t}function ct(t,n){this.xf=n,this.f=t,this.idx=-1,this.lastIdx=-1}function st(t){return t}function ft(){this._nativeSet="function"==typeof Set?new Set:null,this._items={}}function lt(t,n,r){var e,u,i=typeof t;switch(i){case"string":case"number":return 0===t&&1/t===-(1/0)?r._items["-0"]?!0:(n&&(r._items["-0"]=!0),!1):null!==r._nativeSet?n?(e=r._nativeSet.size,r._nativeSet.add(t),u=r._nativeSet.size,u===e):r._nativeSet.has(t):i in r._items?t in r._items[i]?!0:(n&&(r._items[i][t]=!0),!1):(n&&(r._items[i]={},r._items[i][t]=!0),!1);case"boolean":if(i in r._items){var o=t?1:0;return r._items[i][o]?!0:(n&&(r._items[i][o]=!0),!1)}return n&&(r._items[i]=t?[!1,!0]:[!0,!1]),!1;case"function":return null!==r._nativeSet?n?(e=r._nativeSet.size,r._nativeSet.add(t),u=r._nativeSet.size,u===e):r._nativeSet.has(t):i in r._items?z(t,r._items[i])?!0:(n&&r._items[i].push(t),!1):(n&&(r._items[i]=[t]),!1);case"undefined":return r._items[i]?!0:(n&&(r._items[i]=!0),!1);case"object":if(null===t)return r._items["null"]?!0:(n&&(r._items["null"]=!0),!1);default:return i=Object.prototype.toString.call(t),i in r._items?z(t,r._items[i])?!0:(n&&r._items[i].push(t),!1):(n&&(r._items[i]=[t]),!1)}}function pt(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(t),r=1,e=arguments.length;e>r;){var u=arguments[r];if(null!=u)for(var i in u)x(i,u)&&(n[i]=u[i]);r+=1}return n}function ht(t){if(c(t))return t;if(Pt(t))return he;if("string"==typeof t)return ye;if("object"==typeof t)return ge;throw new Error("Cannot create transformer for "+t)}function yt(t){return"[object Number]"===Object.prototype.toString.call(t)}function gt(t){return[t]}function dt(t){return e(function(n,r){return i(Math.max(0,n.length-r.length),function(){return n.apply(this,t(r,arguments))})})}function mt(){if(0===arguments.length)throw new Error("pipeK requires at least one argument");return P.apply(this,Cn(arguments))}function vt(t,n){this.xf=n,this.f=t}function wt(t,n){this.xf=n,this.f=t}function bt(t){return"[object RegExp]"===Object.prototype.toString.call(t)}var xt=r(function(t){return function(){return t}}),jt=xt(!1),At=xt(!0),Ot={"@@functional/placeholder":!0},St=e(function(t,n){return Number(t)+Number(n)}),Et=e(function(t,n){return 1===t?r(n):i(t,o(t,[],n))}),_t=r(function(t){return Et(t.length,function(){var n=0,r=arguments[0],e=arguments[arguments.length-1],i=Array.prototype.slice.call(arguments,0);return i[0]=function(){var t=r.apply(this,u(arguments,[n,e]));return n+=1,t},t.apply(this,i)})}),kt=a(function(t,n,r){if(n>=r.length||n<-r.length)return r;var e=0>n?r.length:0,i=e+n,o=u(r);return o[i]=t(r[i]),o}),qt=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)},Nt={init:function(){return this.xf["@@transducer/init"]()},result:function(t){return this.xf["@@transducer/result"](t)}};l.prototype["@@transducer/init"]=Nt.init,l.prototype["@@transducer/result"]=function(t){return this.all&&(t=this.xf["@@transducer/step"](t,!0)),this.xf["@@transducer/result"](t)},l.prototype["@@transducer/step"]=function(t,n){return this.f(n)||(this.all=!1,t=f(this.xf["@@transducer/step"](t,!1))),t};var It=e(function(t,n){return new l(t,n)}),Wt=e(s(["all"],It,function(t,n){for(var r=0;rt?n:t}),Pt=r(function(t){return qt(t)?!0:t?"object"!=typeof t?!1:h(t)?!1:1===t.nodeType?!!t.length:0===t.length?!0:t.length>0?t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1):!1:!1});y.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},y.prototype["@@transducer/result"]=function(t){return t},y.prototype["@@transducer/step"]=function(t,n){return this.f(t,n)};var Tt=e(function(t,n){return i(t.length,function(){return t.apply(n,arguments)})}),Ft="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";b.prototype["@@transducer/init"]=Nt.init,b.prototype["@@transducer/result"]=Nt.result,b.prototype["@@transducer/step"]=function(t,n){return this.xf["@@transducer/step"](t,this.f(n))};var Rt=e(function(t,n){return new b(t,n)}),Bt=Object.prototype.toString,Ut=function(){return"[object Arguments]"===Bt.call(arguments)?function(t){return"[object Arguments]"===Bt.call(t)}:function(t){return x("callee",t)}},Dt=!{toString:null}.propertyIsEnumerable("toString"),Mt=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],zt=function(){return arguments.propertyIsEnumerable("length")}(),Lt=function(t,n){for(var r=0;r=0;)n=Mt[r],x(n,t)&&!Lt(e,n)&&(e[e.length]=n),r-=1;return e}:function(t){return Object(t)!==t?[]:Object.keys(t)},Vt=r(Kt),Ht=e(s(["fantasy-land/map","map"],Rt,function(t,n){switch(Object.prototype.toString.call(n)){case"[object Function]":return Et(n.length,function(){return t.call(this,n.apply(this,arguments))});case"[object Object]":return w(function(r,e){return r[e]=t(n[e]),r},{},Vt(n));default:return p(t,n)}})),$t=e(function(t,n){return n[t]}),Jt=e(function(t,n){return Ht($t(t),n)}),Xt=a(w),Yt=r(function(t){return Et(Xt(Ct,0,Jt("length",t)),function(){for(var n=0,r=t.length;r>n;){if(!t[n].apply(this,arguments))return!1;n+=1}return!0})}),Zt=e(function(t,n){return t&&n});j.prototype["@@transducer/init"]=Nt.init,j.prototype["@@transducer/result"]=function(t){return this.any||(t=this.xf["@@transducer/step"](t,!1)),this.xf["@@transducer/result"](t)},j.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.any=!0,t=f(this.xf["@@transducer/step"](t,!0))),t};var Gt=e(function(t,n){return new j(t,n)}),Qt=e(s(["any"],Gt,function(t,n){for(var r=0;rn;){if(t[n].apply(this,arguments))return!0;n+=1}return!1})}),nn=e(function(t,n){return"function"==typeof n["fantasy-land/ap"]?n["fantasy-land/ap"](t):"function"==typeof t.ap?t.ap(n):"function"==typeof t?function(r){return t(r)(n(r))}:w(function(t,r){return u(t,Ht(r,n))},[],t)});O.prototype["@@transducer/init"]=Nt.init,O.prototype["@@transducer/result"]=function(t){return this.acc=null,this.xf["@@transducer/result"](t)},O.prototype["@@transducer/step"]=function(t,n){return this.store(n),this.full?this.xf["@@transducer/step"](t,this.getCopy()):t},O.prototype.store=function(t){this.acc[this.pos]=t,this.pos+=1,this.pos===this.acc.length&&(this.pos=0,this.full=!0)},O.prototype.getCopy=function(){return u(Array.prototype.slice.call(this.acc,this.pos),Array.prototype.slice.call(this.acc,0,this.pos))};var rn=e(function(t,n){return new O(t,n)}),en=e(s([],rn,A)),un=e(function(t,n){return u(n,[t])}),on=e(function(t,n){return t.apply(this,n)}),an=r(function(t){for(var n=Vt(t),r=n.length,e=[],u=0;r>u;)e[u]=t[n[u]],u+=1;return e}),cn=r(function Ri(t){return t=Ht(function(t){return"function"==typeof t?t:Ri(t)},t),Et(Xt(Ct,0,Jt("length",an(t))),function(){var n=arguments;return Ht(function(t){return on(t,n)},t)})}),sn=a(function(t,n,r){var e=t(n),u=t(r);return u>e?-1:e>u?1:0}),fn=a(function(t,n,r){var e={};for(var u in r)e[u]=r[u];return e[t]=n,e}),ln=Number.isInteger||function(t){return t<<0===t},pn=r(function(t){return null==t}),hn=a(function Bi(t,n,r){if(0===t.length)return n;var e=t[0];if(t.length>1){var u=!pn(r)&&x(e,r)?r[e]:ln(t[1])?[]:{};n=Bi(Array.prototype.slice.call(t,1),n,u)}if(ln(e)&&qt(r)){var i=[].concat(r);return i[e]=n,i}return fn(e,n,r)}),yn=e(function(t,n){switch(t){case 0:return function(){return n.call(this)};case 1:return function(t){return n.call(this,t)};case 2:return function(t,r){return n.call(this,t,r)};case 3:return function(t,r,e){return n.call(this,t,r,e)};case 4:return function(t,r,e,u){return n.call(this,t,r,e,u)};case 5:return function(t,r,e,u,i){return n.call(this,t,r,e,u,i)};case 6:return function(t,r,e,u,i,o){return n.call(this,t,r,e,u,i,o)};case 7:return function(t,r,e,u,i,o,a){return n.call(this,t,r,e,u,i,o,a)};case 8:return function(t,r,e,u,i,o,a,c){return n.call(this,t,r,e,u,i,o,a,c)};case 9:return function(t,r,e,u,i,o,a,c,s){return n.call(this,t,r,e,u,i,o,a,c,s)};case 10:return function(t,r,e,u,i,o,a,c,s,f){return n.call(this,t,r,e,u,i,o,a,c,s,f)};default:throw new Error("First argument to nAry must be a non-negative integer no greater than ten")}}),gn=r(function(t){return yn(2,t)}),dn=e(function(t,n){var r=Et(t,n);return Et(t,function(){return w(nn,Ht(r,arguments[0]),Array.prototype.slice.call(arguments,1))})}),mn=r(function(t){return dn(t.length,t)}),vn=e(function(t,n){return S(t)?function(){return t.apply(this,arguments)&&n.apply(this,arguments)}:mn(Zt)(t,n)}),wn=r(function(t){return Et(t.length,t)}),bn=wn(function(t){return t.apply(this,Array.prototype.slice.call(arguments,1))}),xn=function(t){return{"@@transducer/init":Nt.init,"@@transducer/result":function(n){return t["@@transducer/result"](n)},"@@transducer/step":function(n,r){var e=t["@@transducer/step"](n,r);return e["@@transducer/reduced"]?_(e):e}}},jn=function(t){var n=xn(t);return{"@@transducer/init":Nt.init,"@@transducer/result":function(t){return n["@@transducer/result"](t)},"@@transducer/step":function(t,r){return Pt(r)?w(n,t,r):w(n,t,[r])}}},An=e(function(t,n){return Ht(t,jn(n))}),On=e(s(["fantasy-land/chain","chain"],An,function(t,n){return"function"==typeof n?function(r){return t(n(r))(r)}:E(!1)(Ht(t,n))})),Sn=a(function(t,n,r){if(t>n)throw new Error("min must not be greater than max in clamp(min, max, value)");return t>r?t:r>n?n:r}),En=r(function(t){return null===t?"Null":void 0===t?"Undefined":Object.prototype.toString.call(t).slice(8,-1)}),_n=r(function(t){return null!=t&&"function"==typeof t.clone?t.clone():q(t,[],[],!0)}),kn=r(function(t){return function(n,r){return t(n,r)?-1:t(r,n)?1:0}}),qn=r(function(t){return!t}),Nn=mn(qn),In=a(I("slice",function(t,n,r){return Array.prototype.slice.call(r,t,n)})),Wn=r(I("tail",In(1,1/0))),Cn=r(function(t){return h(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()}),Pn=e(function(t,n){return t===n?0!==t||1/t===1/n:t!==t&&n!==n}),Tn=e(function(t,n){return D(t,n,[],[])}),Fn=function(t){return(10>t?"0":"")+t},Rn="function"==typeof Date.prototype.toISOString?function(t){return t.toISOString()}:function(t){return t.getUTCFullYear()+"-"+Fn(t.getUTCMonth()+1)+"-"+Fn(t.getUTCDate())+"T"+Fn(t.getUTCHours())+":"+Fn(t.getUTCMinutes())+":"+Fn(t.getUTCSeconds())+"."+(t.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};$.prototype["@@transducer/init"]=Nt.init,$.prototype["@@transducer/result"]=Nt.result,$.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.xf["@@transducer/step"](t,n):t};var Bn=e(function(t,n){return new $(t,n)}),Un=e(s(["filter"],Bn,function(t,n){return H(n)?w(function(r,e){return t(n[e])&&(r[e]=n[e]),r},{},Vt(n)):V(t,n)})),Dn=e(function(t,n){return Un(K(t),n)}),Mn=r(function(t){return J(t,[])}),zn=e(function(t,n){if(qt(t)){if(qt(n))return t.concat(n);throw new TypeError(Mn(n)+" is not an array")}if(h(t)){if(h(n))return t+n;throw new TypeError(Mn(n)+" is not a string")}if(null!=t&&S(t["fantasy-land/concat"]))return t["fantasy-land/concat"](n);if(null!=t&&S(t.concat))return t.concat(n);throw new TypeError(Mn(t)+' does not have a method named "concat" or "fantasy-land/concat"')}),Ln=r(function(t){var n=Xt(Ct,0,Ht(function(t){return t[0].length},t));return i(n,function(){for(var n=0;n10)throw new Error("Constructor with greater than ten arguments");return 0===t?function(){return new n}:wn(yn(t,function(t,r,e,u,i,o,a,c,s,f){switch(arguments.length){case 1:return new n(t);case 2:return new n(t,r);case 3:return new n(t,r,e);case 4:return new n(t,r,e,u);case 5:return new n(t,r,e,u,i);case 6:return new n(t,r,e,u,i,o);case 7:return new n(t,r,e,u,i,o,a);case 8:return new n(t,r,e,u,i,o,a,c);case 9:return new n(t,r,e,u,i,o,a,c,s);case 10:return new n(t,r,e,u,i,o,a,c,s,f)}}))}),Vn=r(function(t){return Kn(t.length,t)}),Hn=e(z),$n=e(function(t,n){return Et(Xt(Ct,0,Jt("length",n)),function(){var r=arguments,e=this;return t.apply(e,p(function(t){return t.apply(e,r)},n))})});X.prototype["@@transducer/init"]=Nt.init,X.prototype["@@transducer/result"]=function(t){var n;for(n in this.inputs)if(x(n,this.inputs)&&(t=this.xf["@@transducer/step"](t,this.inputs[n]),t["@@transducer/reduced"])){t=t["@@transducer/value"];break}return this.inputs=null,this.xf["@@transducer/result"](t)},X.prototype["@@transducer/step"]=function(t,n){var r=this.keyFn(n);return this.inputs[r]=this.inputs[r]||[r,this.valueAcc],this.inputs[r][1]=this.valueFn(this.inputs[r][1],n),t};var Jn=o(4,[],function(t,n,r,e){return new X(t,n,r,e)}),Xn=o(4,[],s([],Jn,function(t,n,r,e){return w(function(e,u){var i=r(u);return e[i]=t(x(i,e)?e[i]:n,u),e},{},e)})),Yn=Xn(function(t,n){return t+1},0),Zn=St(-1),Gn=e(function(t,n){return null==n||n!==n?t:n}),Qn=a(function(t,n,r){var e=t(n),u=t(r);return e>u?-1:u>e?1:0}),tr=e(function(t,n){for(var r=[],e=0,u=t.length;u>e;)z(t[e],n)||z(t[e],r)||(r[r.length]=t[e]),e+=1;return r}),nr=a(function(t,n,r){for(var e=[],u=0,i=n.length;i>u;)Y(t,n[u],r)||Y(t,n[u],e)||e.push(n[u]),u+=1;return e}),rr=e(function(t,n){var r={};for(var e in n)r[e]=n[e];return delete r[t],r}),er=a(function(t,n,r){var e=Array.prototype.slice.call(r,0);return e.splice(t,n),e}),ur=a(function(t,n,r){return kt(xt(n),t,r)}),ir=e(function Ui(t,n){switch(t.length){case 0:return n;case 1:return ln(t[0])?er(t[0],1,n):rr(t[0],n);default:var r=t[0],e=Array.prototype.slice.call(t,1);return null==n[r]?n:ln(t[0])?ur(r,Ui(e,n[r]),n):fn(r,Ui(e,n[r]),n)}}),or=e(function(t,n){return t/n});Z.prototype["@@transducer/init"]=Nt.init,Z.prototype["@@transducer/result"]=Nt.result,Z.prototype["@@transducer/step"]=function(t,n){return this.n>0?(this.n-=1,t):this.xf["@@transducer/step"](t,n)};var ar=e(function(t,n){return new Z(t,n)}),cr=e(s(["drop"],ar,function(t,n){return In(Math.max(0,t),1/0,n)}));G.prototype["@@transducer/init"]=Nt.init,G.prototype["@@transducer/result"]=Nt.result,G.prototype["@@transducer/step"]=function(t,n){this.i+=1;var r=0===this.n?t:this.xf["@@transducer/step"](t,n);return this.n>=0&&this.i>=this.n?f(r):r};var sr=e(function(t,n){return new G(t,n)}),fr=e(s(["take"],sr,function(t,n){return In(0,0>t?1/0:t,n)}));tt.prototype["@@transducer/init"]=Nt.init,tt.prototype["@@transducer/result"]=function(t){return this.acc=null,this.xf["@@transducer/result"](t)},tt.prototype["@@transducer/step"]=function(t,n){return this.full&&(t=this.xf["@@transducer/step"](t,this.acc[this.pos])),this.store(n),t},tt.prototype.store=function(t){this.acc[this.pos]=t,this.pos+=1,this.pos===this.acc.length&&(this.pos=0,this.full=!0)};var lr=e(function(t,n){return new tt(t,n)}),pr=e(s([],lr,Q));rt.prototype["@@transducer/init"]=Nt.init,rt.prototype["@@transducer/result"]=function(t){return this.retained=null,this.xf["@@transducer/result"](t)},rt.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.retain(t,n):this.flush(t,n)},rt.prototype.flush=function(t,n){return t=w(this.xf["@@transducer/step"],t,this.retained),this.retained=[],this.xf["@@transducer/step"](t,n)},rt.prototype.retain=function(t,n){return this.retained.push(n),t};var hr=e(function(t,n){return new rt(t,n)}),yr=e(s([],hr,nt));et.prototype["@@transducer/init"]=Nt.init,et.prototype["@@transducer/result"]=Nt.result,et.prototype["@@transducer/step"]=function(t,n){var r=!1;return this.seenFirstValue?this.pred(this.lastValue,n)&&(r=!0):this.seenFirstValue=!0,this.lastValue=n,r?t:this.xf["@@transducer/step"](t,n)};var gr=e(function(t,n){return new et(t,n)}),dr=e(function(t,n){var r=0>t?n.length+t:t;return h(n)?n.charAt(r):n[r]}),mr=dr(-1),vr=e(s([],gr,function(t,n){var r=[],e=1,u=n.length;if(0!==u)for(r[0]=n[0];u>e;)t(mr(r),n[e])||(r[r.length]=n[e]),e+=1;return r})),wr=r(s([],gr(Tn),vr(Tn)));ut.prototype["@@transducer/init"]=Nt.init,ut.prototype["@@transducer/result"]=Nt.result,ut.prototype["@@transducer/step"]=function(t,n){if(this.f){if(this.f(n))return t;this.f=null}return this.xf["@@transducer/step"](t,n)};var br=e(function(t,n){return new ut(t,n)}),xr=e(s(["dropWhile"],br,function(t,n){for(var r=0,e=n.length;e>r&&t(n[r]);)r+=1;return Array.prototype.slice.call(n,r)})),jr=e(function(t,n){return t||n}),Ar=e(function(t,n){return S(t)?function(){return t.apply(this,arguments)||n.apply(this,arguments)}:mn(jr)(t,n)}),Or=r(function(t){return null!=t&&"function"==typeof t["fantasy-land/empty"]?t["fantasy-land/empty"]():null!=t&&null!=t.constructor&&"function"==typeof t.constructor["fantasy-land/empty"]?t.constructor["fantasy-land/empty"]():null!=t&&"function"==typeof t.empty?t.empty():null!=t&&null!=t.constructor&&"function"==typeof t.constructor.empty?t.constructor.empty():qt(t)?[]:h(t)?"":H(t)?{}:Ut(t)?function(){return arguments}():void 0}),Sr=e(function(t,n){return cr(t>=0?n.length-t:0,n)}),Er=e(function(t,n){return Tn(Sr(t.length,n),t)}),_r=a(function(t,n,r){return Tn(t(n),t(r))}),kr=a(function(t,n,r){return Tn(n[t],r[t])}),qr=e(function Di(t,n){var r,e,u,i={};for(e in n)r=t[e],u=typeof r,i[e]="function"===u?r(n[e]):r&&"object"===u?Di(r,n[e]):n[e];return i});it.prototype["@@transducer/init"]=Nt.init,it.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},it.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.found=!0,t=f(this.xf["@@transducer/step"](t,n))),t};var Nr=e(function(t,n){return new it(t,n)}),Ir=e(s(["find"],Nr,function(t,n){for(var r=0,e=n.length;e>r;){if(t(n[r]))return n[r];r+=1}}));ot.prototype["@@transducer/init"]=Nt.init,ot.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,-1)),this.xf["@@transducer/result"](t)},ot.prototype["@@transducer/step"]=function(t,n){return this.idx+=1,this.f(n)&&(this.found=!0,t=f(this.xf["@@transducer/step"](t,this.idx))),t};var Wr=e(function(t,n){return new ot(t,n)}),Cr=e(s([],Wr,function(t,n){for(var r=0,e=n.length;e>r;){if(t(n[r]))return r;r+=1}return-1}));at.prototype["@@transducer/init"]=Nt.init,at.prototype["@@transducer/result"]=function(t){return this.xf["@@transducer/result"](this.xf["@@transducer/step"](t,this.last))},at.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.last=n),t};var Pr=e(function(t,n){return new at(t,n)}),Tr=e(s([],Pr,function(t,n){for(var r=n.length-1;r>=0;){if(t(n[r]))return n[r];r-=1}}));ct.prototype["@@transducer/init"]=Nt.init,ct.prototype["@@transducer/result"]=function(t){return this.xf["@@transducer/result"](this.xf["@@transducer/step"](t,this.lastIdx))},ct.prototype["@@transducer/step"]=function(t,n){return this.idx+=1,this.f(n)&&(this.lastIdx=this.idx),t};var Fr=e(function(t,n){return new ct(t,n)}),Rr=e(s([],Fr,function(t,n){for(var r=n.length-1;r>=0;){if(t(n[r]))return r;r-=1}return-1})),Br=r(E(!0)),Ur=r(function(t){return wn(function(n,r){var e=Array.prototype.slice.call(arguments,0);return e[0]=r,e[1]=n,t.apply(this,e)})}),Dr=e(I("forEach",function(t,n){for(var r=n.length,e=0;r>e;)t(n[e]),e+=1;return n})),Mr=e(function(t,n){for(var r=Vt(n),e=0;ee;){for(var i=e+1;u>i&&t(n[i-1],n[i]);)i+=1;r.push(n.slice(e,i)),e=i}return r}),Vr=e(function(t,n){return t>n}),Hr=e(function(t,n){return t>=n}),$r=e(x),Jr=e(function(t,n){return t in n}),Xr=dr(0),Yr=r(st),Zr=a(function(t,n,r){return Et(Math.max(t.length,n.length,r.length),function(){return t.apply(this,arguments)?n.apply(this,arguments):r.apply(this,arguments)})}),Gr=St(1),Qr=Xn(function(t,n){return n},null),te=e(function(t,n){return"function"!=typeof n.indexOf||qt(n)?M(n,t,0):n.indexOf(t)}),ne=In(0,-1),re=a(function(t,n,r){return V(function(n){return Y(t,n,r)},n)}),ee=a(function(t,n,r){t=t=0?t:r.length;var e=Array.prototype.slice.call(r,0);return e.splice(t,0,n),e}),ue=a(function(t,n,r){return t=t=0?t:r.length,[].concat(Array.prototype.slice.call(r,0,t),n,Array.prototype.slice.call(r,t))});ft.prototype.add=function(t){return!lt(t,!0,this)},ft.prototype.has=function(t){return lt(t,!1,this)};var ie=e(function(t,n){for(var r,e,u=new ft,i=[],o=0;on.length?(r=t,e=n):(r=n,e=t),oe(V(Ur(z)(r),e))}),ce=e(function(t,n){for(var r,e=0,u=n.length,i=[];u>e;)r=n[e], +Y(t,r,i)||(i[i.length]=r),e+=1;return i}),se=a(function(t,n,r){var e,u;n.length>r.length?(e=n,u=r):(e=r,u=n);for(var i=[],o=0;oe;)e===u-1?r.push(n[e]):r.push(n[e],t),e+=1;return r})),le="function"==typeof Object.assign?Object.assign:pt,pe=e(function(t,n){var r={};return r[t]=n,r}),he={"@@transducer/init":Array,"@@transducer/step":function(t,n){return t.push(n),t},"@@transducer/result":st},ye={"@@transducer/init":String,"@@transducer/step":function(t,n){return t+n},"@@transducer/result":st},ge={"@@transducer/init":Object,"@@transducer/step":function(t,n){return le(t,Pt(n)?pe(n[0],n[1]):n)},"@@transducer/result":st},de=a(function(t,n,r){return c(t)?w(n(t),t["@@transducer/init"](),r):w(n(ht(t)),q(t,[],[],!1),r)}),me=r(function(t){for(var n=Vt(t),r=n.length,e=0,u={};r>e;){var i=n[e],o=t[i],a=x(o,u)?u[o]:u[o]=[];a[a.length]=i,e+=1}return u}),ve=r(function(t){for(var n=Vt(t),r=n.length,e=0,u={};r>e;){var i=n[e];u[t[i]]=i,e+=1}return u}),we=e(function(t,n){return Et(t+1,function(){var r=arguments[t];if(null!=r&&S(r[n]))return r[n].apply(r,Array.prototype.slice.call(arguments,0,t));throw new TypeError(Mn(r)+' does not have a method named "'+n+'"')})}),be=e(function(t,n){return null!=n&&n.constructor===t||n instanceof t}),xe=r(function(t){return null!=t&&Tn(t,Or(t))}),je=we(1,"join"),Ae=r(function(t){return $n(function(){return Array.prototype.slice.call(arguments,0)},t)}),Oe=r(function(t){var n,r=[];for(n in t)r[r.length]=n;return r}),Se=e(function(t,n){if("function"!=typeof n.lastIndexOf||qt(n)){for(var r=n.length-1;r>=0;){if(Tn(n[r],t))return r;r-=1}return-1}return n.lastIndexOf(t)}),Ee=r(function(t){return null!=t&&yt(t.length)?t.length:NaN}),_e=e(function(t,n){return function(r){return function(e){return Ht(function(t){return n(t,e)},r(t(e)))}}}),ke=r(function(t){return _e(dr(t),ur(t))}),qe=e(function(t,n){for(var r=n,e=0;et}),Ce=e(function(t,n){return n>=t}),Pe=a(function(t,n,r){for(var e=0,u=r.length,i=[],o=[n];u>e;)o=t(o[0],r[e]),i[e]=o[1],e+=1;return[o[0],i]}),Te=a(function(t,n,r){for(var e=r.length-1,u=[],i=[n];e>=0;)i=t(r[e],i[0]),u[e]=i[1],e-=1;return[u,i[0]]}),Fe=e(function(t,n){return w(function(r,e){return r[e]=t(n[e],e,n),r},{},Vt(n))}),Re=e(function(t,n){return n.match(t)||[]}),Be=e(function(t,n){return ln(t)?!ln(n)||1>n?NaN:(t%n+n)%n:NaN}),Ue=a(function(t,n,r){return t(r)>t(n)?r:n}),De=Xt(St,0),Me=r(function(t){return De(t)/t.length}),ze=r(function(t){var n=t.length;if(0===n)return NaN;var r=2-n%2,e=(n-r)/2;return Me(Array.prototype.slice.call(t,0).sort(function(t,n){return n>t?-1:t>n?1:0}).slice(e,e+r))}),Le=e(function(t,n){var r={};return i(n.length,function(){var e=t.apply(this,arguments);return x(e,r)||(r[e]=n.apply(this,arguments)),r[e]})}),Ke=Le(function(){return Mn(arguments)}),Ve=e(function(t,n){return le({},t,n)}),He=r(function(t){return le.apply(null,[{}].concat(t))}),$e=a(function(t,n,r){var e,u={};for(e in n)x(e,n)&&(u[e]=x(e,r)?t(e,n[e],r[e]):n[e]);for(e in r)x(e,r)&&!x(e,u)&&(u[e]=r[e]);return u}),Je=a(function Mi(t,n,r){return $e(function(n,r,e){return H(r)&&H(e)?Mi(t,r,e):t(n,r,e)},n,r)}),Xe=e(function(t,n){return Je(function(t,n,r){return n},t,n)}),Ye=e(function(t,n){return Je(function(t,n,r){return r},t,n)}),Ze=a(function(t,n,r){return Je(function(n,r,e){return t(r,e)},n,r)}),Ge=a(function(t,n,r){return $e(function(n,r,e){return t(r,e)},n,r)}),Qe=e(function(t,n){return t>n?n:t}),tu=a(function(t,n,r){return t(r)t?1:t+1;return Et(n,function(){return dr(t,arguments)})}),ou=a(function(t,n,r){return t(n(r))}),au=r(gt),cu=e(function(t,n){for(var r={},e={},u=0,i=t.length;i>u;)e[t[u]]=1,u+=1;for(var o in n)e.hasOwnProperty(o)||(r[o]=n[o]);return r}),su=r(function(t){var n,r=!1;return i(t.length,function(){return r?n:(r=!0,n=t.apply(this,arguments))})}),fu=function(t){return{value:t,map:function(n){return fu(n(t))}}},lu=a(function(t,n,r){return t(function(t){return fu(n(t))})(r).value}),pu=e(function(t,n){return[t,n]}),hu=dt(u),yu=dt(Ur(u)),gu=Ae([Un,Dn]),du=a(function(t,n,r){return Tn(qe(t,r),n)}),mu=a(function(t,n,r){return Gn(t,qe(n,r))}),vu=a(function(t,n,r){return n.length>0&&t(qe(n,r))}),wu=e(function(t,n){for(var r={},e=0;ee;){var i=t[e];r[i]=n[i],e+=1}return r}),xu=e(function(t,n){var r={};for(var e in n)t(n[e],e,n)&&(r[e]=n[e]);return r}),ju=e(function(t,n){return u([t],n)}),Au=Xt(ru,1),Ou=e(function(t,n){return Et(n.length,function(){for(var r=[],e=0;eu;)e[u]=n[t[u]],u+=1;return e}),Iu=e(function(t,n){if(!yt(t)||!yt(n))throw new TypeError("Both arguments to range must be numbers");for(var r=[],e=t;n>e;)r.push(e),e+=1;return r}),Wu=a(function(t,n,r){for(var e=r.length-1;e>=0;)n=t(r[e],n),e-=1;return n}),Cu=o(4,[],function(t,n,r,e){return w(function(r,e){return t(r,e)?n(r,e):f(r)},r,e)}),Pu=r(f),Tu=e(function(t,n){var r,e=Number(n),u=0;if(0>e||isNaN(e))throw new RangeError("n must be a non-negative number");for(r=new Array(e);e>u;)r[u]=t(u),u+=1;return r}),Fu=e(function(t,n){return Tu(xt(t),n)}),Ru=a(function(t,n,r){return r.replace(t,n)}),Bu=a(function(t,n,r){for(var e=0,u=r.length,i=[n];u>e;)n=t(n,r[e]),i[e+1]=n,e+=1;return i}),Uu=e(function(t,n){return"function"==typeof n.sequence?n.sequence(t):Wu(function(t,n){return nn(Ht(ju,t),n)},t([]),n)}),Du=a(function(t,n,r){return lu(t,xt(n),r)}),Mu=e(function(t,n){return Array.prototype.slice.call(n,0).sort(t)}),zu=e(function(t,n){return Array.prototype.slice.call(n,0).sort(function(n,r){var e=t(n),u=t(r);return u>e?-1:e>u?1:0})}),Lu=e(function(t,n){return Array.prototype.slice.call(n,0).sort(function(n,r){for(var e=0,u=0;0===e&&u=t)throw new Error("First argument to splitEvery must be a positive integer");for(var r=[],e=0;er&&!t(n[r]);)u.push(n[r]),r+=1;return[u,Array.prototype.slice.call(n,r)]}),Ju=e(function(t,n){return Tn(fr(t.length,n),t)}),Xu=e(function(t,n){return Number(t)-Number(n)}),Yu=e(function(t,n){return zn(tr(t,n),tr(n,t))}),Zu=a(function(t,n,r){return zn(nr(t,n,r),nr(t,r,n))}),Gu=e(function(t,n){for(var r=n.length-1;r>=0&&t(n[r]);)r-=1;return Array.prototype.slice.call(n,r+1)});vt.prototype["@@transducer/init"]=Nt.init,vt.prototype["@@transducer/result"]=Nt.result,vt.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.xf["@@transducer/step"](t,n):f(t)};var Qu=e(function(t,n){return new vt(t,n)}),ti=e(s(["takeWhile"],Qu,function(t,n){for(var r=0,e=n.length;e>r&&t(n[r]);)r+=1;return Array.prototype.slice.call(n,0,r)}));wt.prototype["@@transducer/init"]=Nt.init,wt.prototype["@@transducer/result"]=Nt.result,wt.prototype["@@transducer/step"]=function(t,n){return this.f(n),this.xf["@@transducer/step"](t,n)};var ni=e(function(t,n){return new wt(t,n)}),ri=e(s([],ni,function(t,n){return t(n),n})),ei=e(function(t,n){if(!bt(t))throw new TypeError("‘test’ requires a value of type RegExp as its first argument; received "+Mn(t));return k(t).test(n)}),ui=we(0,"toLowerCase"),ii=r(function(t){var n=[];for(var r in t)x(r,t)&&(n[n.length]=[r,t[r]]);return n}),oi=r(function(t){var n=[];for(var r in t)n[n.length]=[r,t[r]];return n}),ai=we(0,"toUpperCase"),ci=Et(4,function(t,n,r,e){return w(t("function"==typeof n?g(n):n),r,e)}),si=r(function(t){for(var n=0,r=[];n=e&&"function"==typeof u;)r=e===t?arguments.length:i+u.length,u=u.apply(this,Array.prototype.slice.call(arguments,i,r)),e+=1,i=r;return u})}),bi=e(function(t,n){for(var r=t(n),e=[];r&&r.length;)e[e.length]=r[0],r=t(r[1]);return e}),xi=e(C(oe,u)),ji=a(function(t,n,r){return ce(t,u(n,r))}),Ai=a(function(t,n,r){return t(r)?r:n(r)}),Oi=On(st),Si=a(function(t,n,r){for(var e=r;!t(e);)e=n(e);return e}),Ei=r(function(t){var n,r=[];for(n in t)r[r.length]=t[n];return r}),_i=function(t){return{value:t,"fantasy-land/map":function(){return this}}},ki=e(function(t,n){return t(_i)(n).value}),qi=a(function(t,n,r){return t(r)?n(r):r}),Ni=e(function(t,n){for(var r in t)if(x(r,t)&&!t[r](n[r]))return!1;return!0}),Ii=e(function(t,n){return Ni(Ht(Tn,t),n)}),Wi=e(function(t,n){return Dn(Ur(z)(t),n)}),Ci=e(function(t,n){for(var r,e=0,u=t.length,i=n.length,o=[];u>e;){for(r=0;i>r;)o[o.length]=[t[e],n[r]],r+=1;e+=1}return o}),Pi=e(function(t,n){for(var r=[],e=0,u=Math.min(t.length,n.length);u>e;)r[e]=[t[e],n[e]],e+=1;return r}),Ti=e(function(t,n){for(var r=0,e=Math.min(t.length,n.length),u={};e>r;)u[t[r]]=n[r],r+=1;return u}),Fi=a(function(t,n,r){for(var e=[],u=0,i=Math.min(n.length,r.length);i>u;)e[u]=t(n[u],r[u]),u+=1;return e});t.F=jt,t.T=At,t.__=Ot,t.add=St,t.addIndex=_t,t.adjust=kt,t.all=Wt,t.allPass=Yt,t.always=xt,t.and=Zt,t.any=Qt,t.anyPass=tn,t.ap=nn,t.aperture=en,t.append=un,t.apply=on,t.applySpec=cn,t.ascend=sn,t.assoc=fn,t.assocPath=hn,t.binary=gn,t.bind=Tt,t.both=vn,t.call=bn,t.chain=On,t.clamp=Sn,t.clone=_n,t.comparator=kn,t.complement=Nn,t.compose=C,t.composeK=P,t.composeP=R,t.concat=zn,t.cond=Ln,t.construct=Vn,t.constructN=Kn,t.contains=Hn,t.converge=$n,t.countBy=Yn,t.curry=wn,t.curryN=Et,t.dec=Zn,t.defaultTo=Gn,t.descend=Qn,t.difference=tr,t.differenceWith=nr,t.dissoc=rr,t.dissocPath=ir,t.divide=or,t.drop=cr,t.dropLast=pr,t.dropLastWhile=yr,t.dropRepeats=wr,t.dropRepeatsWith=vr,t.dropWhile=xr,t.either=Ar,t.empty=Or,t.endsWith=Er,t.eqBy=_r,t.eqProps=kr,t.equals=Tn,t.evolve=qr,t.filter=Un,t.find=Ir,t.findIndex=Cr,t.findLast=Tr,t.findLastIndex=Rr,t.flatten=Br,t.flip=Ur,t.forEach=Dr,t.forEachObjIndexed=Mr,t.fromPairs=zr,t.groupBy=Lr,t.groupWith=Kr,t.gt=Vr,t.gte=Hr,t.has=$r,t.hasIn=Jr,t.head=Xr,t.identical=Pn,t.identity=Yr,t.ifElse=Zr,t.inc=Gr,t.indexBy=Qr,t.indexOf=te,t.init=ne,t.innerJoin=re,t.insert=ee,t.insertAll=ue,t.intersection=ae,t.intersectionWith=se,t.intersperse=fe,t.into=de,t.invert=me,t.invertObj=ve,t.invoker=we,t.is=be,t.isEmpty=xe,t.isNil=pn,t.join=je,t.juxt=Ae,t.keys=Vt,t.keysIn=Oe,t.last=mr,t.lastIndexOf=Se,t.length=Ee,t.lens=_e,t.lensIndex=ke,t.lensPath=Ne,t.lensProp=Ie,t.lift=mn,t.liftN=dn,t.lt=We,t.lte=Ce,t.map=Ht,t.mapAccum=Pe,t.mapAccumRight=Te,t.mapObjIndexed=Fe,t.match=Re,t.mathMod=Be,t.max=Ct,t.maxBy=Ue,t.mean=Me,t.median=ze,t.memoize=Ke,t.memoizeWith=Le,t.merge=Ve,t.mergeAll=He,t.mergeDeepLeft=Xe,t.mergeDeepRight=Ye,t.mergeDeepWith=Ze,t.mergeDeepWithKey=Je,t.mergeWith=Ge,t.mergeWithKey=$e,t.min=Qe,t.minBy=tu,t.modulo=nu,t.multiply=ru,t.nAry=yn,t.negate=eu,t.none=uu,t.not=qn,t.nth=dr,t.nthArg=iu,t.o=ou,t.objOf=pe,t.of=au,t.omit=cu,t.once=su,t.or=jr,t.over=lu,t.pair=pu,t.partial=hu,t.partialRight=yu,t.partition=gu,t.path=qe,t.pathEq=du,t.pathOr=mu,t.pathSatisfies=vu,t.pick=wu,t.pickAll=bu,t.pickBy=xu,t.pipe=W,t.pipeK=mt,t.pipeP=F,t.pluck=Jt,t.prepend=ju,t.product=Au,t.project=Su,t.prop=$t,t.propEq=Eu,t.propIs=_u,t.propOr=ku,t.propSatisfies=qu,t.props=Nu,t.range=Iu,t.reduce=Xt,t.reduceBy=Xn,t.reduceRight=Wu,t.reduceWhile=Cu,t.reduced=Pu,t.reject=Dn,t.remove=er,t.repeat=Fu,t.replace=Ru,t.reverse=Cn,t.scan=Bu,t.sequence=Uu,t.set=Du,t.slice=In,t.sort=Mu,t.sortBy=zu,t.sortWith=Lu,t.split=Ku,t.splitAt=Vu,t.splitEvery=Hu,t.splitWhen=$u,t.startsWith=Ju,t.subtract=Xu,t.sum=De,t.symmetricDifference=Yu,t.symmetricDifferenceWith=Zu,t.tail=Wn,t.take=fr,t.takeLast=Sr,t.takeLastWhile=Gu,t.takeWhile=ti,t.tap=ri,t.test=ei,t.times=Tu,t.toLower=ui,t.toPairs=ii,t.toPairsIn=oi,t.toString=Mn,t.toUpper=ai,t.transduce=ci,t.transpose=si,t.traverse=fi,t.trim=gi,t.tryCatch=di,t.type=En,t.unapply=mi,t.unary=vi,t.uncurryN=wi,t.unfold=bi,t.union=xi,t.unionWith=ji,t.uniq=oe,t.uniqBy=ie,t.uniqWith=ce,t.unless=Ai,t.unnest=Oi,t.until=Si,t.update=ur,t.useWith=Ou,t.values=an,t.valuesIn=Ei,t.view=ki,t.when=qi,t.where=Ni,t.whereEq=Ii,t.without=Wi,t.xprod=Ci,t.zip=Pi,t.zipObj=Ti,t.zipWith=Fi,Object.defineProperty(t,"__esModule",{value:!0})}),e="0.24.1",void r("Ramda v"+e+" loaded"))}(window,document); + ``` diff --git a/Makefile b/Makefile index 7118ed100..120b3a67b 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,16 @@ -UGLIFY = node_modules/.bin/uglifyjs XYZ = node_modules/.bin/xyz --repo git@github.com:ramda/ramda.git --script scripts/prepublish -SRC = $(shell find src -name '*.js') +dist/ramda.js: + npm run build:umd -dist/ramda.js: scripts/build scripts/header scripts/template.js $(SRC) - git checkout -- '$@' - scripts/header >ramda.js.tmp - '$<' --complete >>ramda.js.tmp - mv ramda.js.tmp '$@' - -dist/ramda.min.js: dist/ramda.js scripts/header - scripts/header >'$@' - $(UGLIFY) --compress --mangle <'$<' >>'$@' +dist/ramda.min.js: + npm run build:umd:min .PHONY: clean clean: - rm -f -- dist/ramda.js ramda.js.tmp + rm -f -- dist/ramda.js .PHONY: lint diff --git a/README.md b/README.md index c0c9f99e8..b0e4019ab 100644 --- a/README.md +++ b/README.md @@ -125,16 +125,15 @@ Or you can inject ramda into virtually any unsuspecting website using [the bookm ### Build -* on Unix-based platforms, `npm run build` updates __dist/ramda.js__ and __dist/ramda.min.js__ -* on Windows, write the output of `scripts/build --complete` to a temporary file, then rename the temporary file __dist/ramda.js__. +`npm run build` creates `es`, `src` directories and updates both __dist/ramda.js__ and __dist/ramda.min.js__ #### Partial Builds It is possible to build Ramda with a subset of the functionality to reduce its file size. Ramda's build system supports this with command line flags. For example if you're using `R.compose`, `R.reduce`, and `R.filter` you can create a partial build with: - ./scripts/build -- src/compose.js src/reduce.js src/filter.js > dist/ramda.custom.js + npm run --silent partial-build compose reduce filter > dist/ramda.custom.js -This requires having Node/io.js installed. +This requires having Node/io.js installed and ramda's dependencies installed (just use `npm install` before running partial build). diff --git a/bower.json b/bower.json index ed682472a..6eb96be4a 100644 --- a/bower.json +++ b/bower.json @@ -21,6 +21,8 @@ "**/.*", "node_modules", "bower_components", + "source", + "es", "test", "tests", "examples", diff --git a/index.js b/index.js deleted file mode 100644 index 1b7b30263..000000000 --- a/index.js +++ /dev/null @@ -1,248 +0,0 @@ -module.exports = { - F: require('./src/F'), - T: require('./src/T'), - __: require('./src/__'), - add: require('./src/add'), - addIndex: require('./src/addIndex'), - adjust: require('./src/adjust'), - all: require('./src/all'), - allPass: require('./src/allPass'), - always: require('./src/always'), - and: require('./src/and'), - any: require('./src/any'), - anyPass: require('./src/anyPass'), - ap: require('./src/ap'), - aperture: require('./src/aperture'), - append: require('./src/append'), - apply: require('./src/apply'), - applySpec: require('./src/applySpec'), - ascend: require('./src/ascend'), - assoc: require('./src/assoc'), - assocPath: require('./src/assocPath'), - binary: require('./src/binary'), - bind: require('./src/bind'), - both: require('./src/both'), - call: require('./src/call'), - chain: require('./src/chain'), - clamp: require('./src/clamp'), - clone: require('./src/clone'), - comparator: require('./src/comparator'), - complement: require('./src/complement'), - compose: require('./src/compose'), - composeK: require('./src/composeK'), - composeP: require('./src/composeP'), - concat: require('./src/concat'), - cond: require('./src/cond'), - construct: require('./src/construct'), - constructN: require('./src/constructN'), - contains: require('./src/contains'), - converge: require('./src/converge'), - countBy: require('./src/countBy'), - curry: require('./src/curry'), - curryN: require('./src/curryN'), - dec: require('./src/dec'), - defaultTo: require('./src/defaultTo'), - descend: require('./src/descend'), - difference: require('./src/difference'), - differenceWith: require('./src/differenceWith'), - dissoc: require('./src/dissoc'), - dissocPath: require('./src/dissocPath'), - divide: require('./src/divide'), - drop: require('./src/drop'), - dropLast: require('./src/dropLast'), - dropLastWhile: require('./src/dropLastWhile'), - dropRepeats: require('./src/dropRepeats'), - dropRepeatsWith: require('./src/dropRepeatsWith'), - dropWhile: require('./src/dropWhile'), - either: require('./src/either'), - empty: require('./src/empty'), - endsWith: require('./src/endsWith'), - eqBy: require('./src/eqBy'), - eqProps: require('./src/eqProps'), - equals: require('./src/equals'), - evolve: require('./src/evolve'), - filter: require('./src/filter'), - find: require('./src/find'), - findIndex: require('./src/findIndex'), - findLast: require('./src/findLast'), - findLastIndex: require('./src/findLastIndex'), - flatten: require('./src/flatten'), - flip: require('./src/flip'), - forEach: require('./src/forEach'), - forEachObjIndexed: require('./src/forEachObjIndexed'), - fromPairs: require('./src/fromPairs'), - groupBy: require('./src/groupBy'), - groupWith: require('./src/groupWith'), - gt: require('./src/gt'), - gte: require('./src/gte'), - has: require('./src/has'), - hasIn: require('./src/hasIn'), - head: require('./src/head'), - identical: require('./src/identical'), - identity: require('./src/identity'), - ifElse: require('./src/ifElse'), - inc: require('./src/inc'), - indexBy: require('./src/indexBy'), - indexOf: require('./src/indexOf'), - init: require('./src/init'), - innerJoin: require('./src/innerJoin'), - insert: require('./src/insert'), - insertAll: require('./src/insertAll'), - intersection: require('./src/intersection'), - intersectionWith: require('./src/intersectionWith'), - intersperse: require('./src/intersperse'), - into: require('./src/into'), - invert: require('./src/invert'), - invertObj: require('./src/invertObj'), - invoker: require('./src/invoker'), - is: require('./src/is'), - isEmpty: require('./src/isEmpty'), - isNil: require('./src/isNil'), - join: require('./src/join'), - juxt: require('./src/juxt'), - keys: require('./src/keys'), - keysIn: require('./src/keysIn'), - last: require('./src/last'), - lastIndexOf: require('./src/lastIndexOf'), - length: require('./src/length'), - lens: require('./src/lens'), - lensIndex: require('./src/lensIndex'), - lensPath: require('./src/lensPath'), - lensProp: require('./src/lensProp'), - lift: require('./src/lift'), - liftN: require('./src/liftN'), - lt: require('./src/lt'), - lte: require('./src/lte'), - map: require('./src/map'), - mapAccum: require('./src/mapAccum'), - mapAccumRight: require('./src/mapAccumRight'), - mapObjIndexed: require('./src/mapObjIndexed'), - match: require('./src/match'), - mathMod: require('./src/mathMod'), - max: require('./src/max'), - maxBy: require('./src/maxBy'), - mean: require('./src/mean'), - median: require('./src/median'), - memoize: require('./src/memoize'), - memoizeWith: require('./src/memoizeWith'), - merge: require('./src/merge'), - mergeAll: require('./src/mergeAll'), - mergeDeepLeft: require('./src/mergeDeepLeft'), - mergeDeepRight: require('./src/mergeDeepRight'), - mergeDeepWith: require('./src/mergeDeepWith'), - mergeDeepWithKey: require('./src/mergeDeepWithKey'), - mergeWith: require('./src/mergeWith'), - mergeWithKey: require('./src/mergeWithKey'), - min: require('./src/min'), - minBy: require('./src/minBy'), - modulo: require('./src/modulo'), - multiply: require('./src/multiply'), - nAry: require('./src/nAry'), - negate: require('./src/negate'), - none: require('./src/none'), - not: require('./src/not'), - nth: require('./src/nth'), - nthArg: require('./src/nthArg'), - o: require('./src/o'), - objOf: require('./src/objOf'), - of: require('./src/of'), - omit: require('./src/omit'), - once: require('./src/once'), - or: require('./src/or'), - over: require('./src/over'), - pair: require('./src/pair'), - partial: require('./src/partial'), - partialRight: require('./src/partialRight'), - partition: require('./src/partition'), - path: require('./src/path'), - pathEq: require('./src/pathEq'), - pathOr: require('./src/pathOr'), - pathSatisfies: require('./src/pathSatisfies'), - pick: require('./src/pick'), - pickAll: require('./src/pickAll'), - pickBy: require('./src/pickBy'), - pipe: require('./src/pipe'), - pipeK: require('./src/pipeK'), - pipeP: require('./src/pipeP'), - pluck: require('./src/pluck'), - prepend: require('./src/prepend'), - product: require('./src/product'), - project: require('./src/project'), - prop: require('./src/prop'), - propEq: require('./src/propEq'), - propIs: require('./src/propIs'), - propOr: require('./src/propOr'), - propSatisfies: require('./src/propSatisfies'), - props: require('./src/props'), - range: require('./src/range'), - reduce: require('./src/reduce'), - reduceBy: require('./src/reduceBy'), - reduceRight: require('./src/reduceRight'), - reduceWhile: require('./src/reduceWhile'), - reduced: require('./src/reduced'), - reject: require('./src/reject'), - remove: require('./src/remove'), - repeat: require('./src/repeat'), - replace: require('./src/replace'), - reverse: require('./src/reverse'), - scan: require('./src/scan'), - sequence: require('./src/sequence'), - set: require('./src/set'), - slice: require('./src/slice'), - sort: require('./src/sort'), - sortBy: require('./src/sortBy'), - sortWith: require('./src/sortWith'), - split: require('./src/split'), - splitAt: require('./src/splitAt'), - splitEvery: require('./src/splitEvery'), - splitWhen: require('./src/splitWhen'), - startsWith: require('./src/startsWith'), - subtract: require('./src/subtract'), - sum: require('./src/sum'), - symmetricDifference: require('./src/symmetricDifference'), - symmetricDifferenceWith: require('./src/symmetricDifferenceWith'), - tail: require('./src/tail'), - take: require('./src/take'), - takeLast: require('./src/takeLast'), - takeLastWhile: require('./src/takeLastWhile'), - takeWhile: require('./src/takeWhile'), - tap: require('./src/tap'), - test: require('./src/test'), - times: require('./src/times'), - toLower: require('./src/toLower'), - toPairs: require('./src/toPairs'), - toPairsIn: require('./src/toPairsIn'), - toString: require('./src/toString'), - toUpper: require('./src/toUpper'), - transduce: require('./src/transduce'), - transpose: require('./src/transpose'), - traverse: require('./src/traverse'), - trim: require('./src/trim'), - tryCatch: require('./src/tryCatch'), - type: require('./src/type'), - unapply: require('./src/unapply'), - unary: require('./src/unary'), - uncurryN: require('./src/uncurryN'), - unfold: require('./src/unfold'), - union: require('./src/union'), - unionWith: require('./src/unionWith'), - uniq: require('./src/uniq'), - uniqBy: require('./src/uniqBy'), - uniqWith: require('./src/uniqWith'), - unless: require('./src/unless'), - unnest: require('./src/unnest'), - until: require('./src/until'), - update: require('./src/update'), - useWith: require('./src/useWith'), - values: require('./src/values'), - valuesIn: require('./src/valuesIn'), - view: require('./src/view'), - when: require('./src/when'), - where: require('./src/where'), - whereEq: require('./src/whereEq'), - without: require('./src/without'), - xprod: require('./src/xprod'), - zip: require('./src/zip'), - zipObj: require('./src/zipObj'), - zipWith: require('./src/zipWith') -}; diff --git a/package.json b/package.json index d16e7df0e..8a5bb49f9 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ ], "name": "ramda", "description": "A practical functional library for JavaScript programmers.", + "side-effects": false, "version": "0.24.1", "homepage": "http://ramdajs.com/", "license": "MIT", @@ -31,22 +32,29 @@ "type": "git", "url": "git://github.com/ramda/ramda.git" }, - "main": "index.js", + "module": "es/index.js", + "main": "src/index.js", "unpkg": "dist/ramda.min.js", "jsdelivr": "dist/ramda.min.js", "files": [ - "index.js", + "es", "src", "dist" ], "scripts": { "bench": "scripts/benchRunner", "bookmarklet": "scripts/bookmarklet", - "build": "make && make dist/ramda.min.js", - "clean": "rimraf dist/* coverage/*", + "build:es": "cross-env BABEL_ENV=es babel source --out-dir es", + "build:cjs": "cross-env BABEL_ENV=cjs babel source --out-dir src", + "build:umd": "cross-env NODE_ENV=development rollup -c -o dist/ramda.js", + "build:umd:min": "cross-env NODE_ENV=production rollup -c -o dist/ramda.min.js", + "build": "npm run build:es && npm run build:cjs && npm run build:umd && npm run build:umd:min", + "partial-build": "node ./scripts/partialBuild", + "clean": "rimraf es/* src/* dist/* coverage/*", "coverage": "istanbul cover node_modules/.bin/_mocha -- --reporter spec", "postcoverage": "npm run posttest", - "lint": "eslint scripts/bookmarklet scripts/build src/*.js src/internal/*.js test/*.js test/**/*.js lib/sauce/*.js lib/bench/*.js", + "lint": "eslint scripts/bookmarklet scripts/*.js source/*.js source/internal/*.js test/*.js test/**/*.js lib/sauce/*.js lib/bench/*.js", + "pretest": "npm run build:cjs", "test": "mocha --reporter spec", "posttest": "git checkout -- dist", "prebrowser_test": "npm run pretest", @@ -55,14 +63,15 @@ }, "dependencies": {}, "devDependencies": { - "acorn": "0.9.x", + "babel-cli": "^6.26.0", + "babel-plugin-annotate-pure-calls": "^0.2.0", + "babel-types": "^6.26.0", "benchmark": "~1.0.0", "browserify": "10.x.x", "cli-table": "0.3.x", - "commander": "2.5.x", + "cross-env": "^2.0.1", "dox": "latest", "envvar": "1.x.x", - "escodegen": "1.4.x", "eslint": "^2.11.0", "handlebars": "3.0.x", "istanbul": "^0.4.x", @@ -72,10 +81,11 @@ "q": "^1.1.1", "ramda": "0.17.x", "rimraf": "~2.3.2", + "rollup": "^0.50.0", + "rollup-plugin-uglify": "^2.0.1", "sanctuary": "0.7.x", "sinon": "^1.17.4", "testem": "0.9.x", - "uglify-js": "2.4.x", "xyz": "1.0.x" } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 000000000..98f3f05ce --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,35 @@ +var uglify = require('rollup-plugin-uglify'); +var pkg = require('./package.json'); + +var banner = '// Ramda v' + pkg.version + '\n' + + '// https://github.com/ramda/ramda\n' + + '// (c) 2013-' + new Date().getFullYear() + ' Scott Sauyet, Michael Hurley, and David Chambers\n' + + '// Ramda may be freely distributed under the MIT license.\n'; + +var input = 'source/index.js'; + +var config = { + input: input, + output: { + format: 'umd', + name: 'R', + exports: 'named' + }, + banner: banner, + plugins: [] +}; + +if (process.env.NODE_ENV === 'production') { + config.plugins.push( + uglify({ + compress: { + pure_getters: true, + unsafe: true, + unsafe_comps: true, + warnings: false + } + }) + ); +} + +module.exports = config; diff --git a/scripts/bookmarklet.tmpl.js b/scripts/bookmarklet.tmpl.js index 4e896211f..59bfab1c0 100644 --- a/scripts/bookmarklet.tmpl.js +++ b/scripts/bookmarklet.tmpl.js @@ -7,8 +7,10 @@ return showMsg('This page already using ramda'); } /* eslint-disable space-before-blocks */ + /* eslint-disable semi */ {{{ramda}}} version = '{{{version}}}'; + /* eslint-enable semi */ /* eslint-enable space-before-blocks */ showMsg('Ramda v' + version + ' loaded'); @@ -34,4 +36,4 @@ window.setTimeout(b.removeChild.bind(b, toast), 2500); } -})(window, document); +}(window, document)); diff --git a/scripts/build b/scripts/build deleted file mode 100755 index 505d08f1c..000000000 --- a/scripts/build +++ /dev/null @@ -1,265 +0,0 @@ -#!/usr/bin/env node - -'use strict'; - -var fs = require('fs'); -var path = require('path'); - -var acorn = require('acorn'); -var program = require('commander'); -var escodegen = require('escodegen'); -var R = require('ramda'); - - -var _ = R.__; - -// template :: String -var template = fs.readFileSync(path.join(__dirname, 'template.js'), - {encoding: 'utf8'}); - -// version :: String -var version = require('../package.json').version; - -// logWithPrefix = String -> String -> () -var logWithPrefix = R.curry(function(prefix, message) { - process.stderr.write(prefix + message + '\n'); -}); - -// warn :: String -> () -var warn = logWithPrefix('\u001b[33m>>> WARNING: \u001b[39;49m'); - -// abort :: String -> ! -var abort = R.pipe( - logWithPrefix('\u001b[31m>>> ERROR: \u001b[39;49m'), - R.always(1), - process.exit -); - -// filenameToIdentifier :: String -> String -var filenameToIdentifier = R.partialRight(path.basename, '.js'); - -// identifierToFilename :: String -> String -var identifierToFilename = -R.pipe(R.ifElse(R.test(/^(?!__$)_/), - R.partial(path.join, __dirname, '..', 'src', 'internal'), - R.partial(path.join, __dirname, '..', 'src')), - R.concat(_, '.js')); - -// parse :: String -> {ast: AST, comments: [Comment], tokens: [Token]} -var parse = R.memoize(function(filename) { - var comments = []; - var tokens = []; - return { - ast: acorn.parse(fs.readFileSync(filename), { - ranges: true, - locations: true, - sourceFile: filename, - onComment: comments, - onToken: tokens - }), - comments: comments, - tokens: tokens - }; -}); - -// isModuleExportsExpr :: {*} -> Boolean -var isModuleExportsExpr = R.allPass([ - R.pathEq(['type'], 'ExpressionStatement'), - R.pathEq(['expression', 'type'], 'AssignmentExpression'), - R.pathEq(['expression', 'operator'], '='), - R.pathEq(['expression', 'left', 'type'], 'MemberExpression'), - R.pathEq(['expression', 'left', 'object', 'type'], 'Identifier'), - R.pathEq(['expression', 'left', 'object', 'name'], 'module'), - R.pathEq(['expression', 'left', 'property', 'type'], 'Identifier'), - R.pathEq(['expression', 'left', 'property', 'name'], 'exports') -]); - -// isRequireExpr :: {*} -> Boolean -var isRequireExpr = R.allPass([ - R.pathEq(['init', 'type'], 'CallExpression'), - R.pathEq(['init', 'callee', 'type'], 'Identifier'), - R.pathEq(['init', 'callee', 'name'], 'require'), - R.pathEq(['init', 'arguments', 'length'], 1), - R.pathEq(['init', 'arguments', '0', 'type'], 'Literal') -]); - -// warnIgnoredTopLevel :: {*} -> {*} -var warnIgnoredTopLevel = R.tap(R.pipe( - R.chain(R.ifElse(R.propEq('type', 'VariableDeclaration'), - R.prop('declarations'), - R.of)), - R.reject(R.either(isModuleExportsExpr, isRequireExpr)), - R.map(function(ast) { - return 'Top-level declaration `' + ast.id.name + - '` ignored in ' + ast.loc.source + ':' + ast.loc.start.line; - }), - R.forEach(warn) -)); - -// abortIfNotSorted :: List[{*}] -> List[{*}] -var abortIfNotSorted = R.tap(R.cond([[ - R.complement(R.pipe( - R.pluck('id'), - R.pluck('name'), - R.converge(R.equals, R.identity, R.sortBy(R.identity)) - )), - R.pipe( - R.path(['0', 'loc', 'source']), - R.concat('Dependencies not declared in alphabetical order in '), - abort - ) -]]) -); - -// abortIfExportNotLast :: {*} -> {*} -var abortIfExportNotLast = R.tap(R.cond([[ - R.complement(R.pipe(R.prop('body'), R.last, isModuleExportsExpr)), - R.pipe( - R.path(['loc', 'source']), - R.concat('module.exports not positioned last in '), - abort - ) -]])); - -// abortIfDifferentRequireVar :: {*} -> {*} -var abortIfDifferentRequireVar = R.tap(R.forEach(R.cond([[ - R.converge( - R.complement(R.equals), - R.path(['id', 'name']), - R.pipe( - R.path(['init', 'arguments', '0', 'value']), - R.replace(/^[.][/]internal[/]/, './'), - R.replace(/^[.]{1,2}[/]/, ''), - R.replace(/[.]([a-z])/g, R.pipe(R.nthArg(1), R.toUpper)) - ) - ), - function(ast) { - abort('Dependency declared with different variable name: `' + - ast.id.name + '` & `' + - ast.init.arguments[0].value + - '` in ' + ast.loc.source - ); - } -]]))); - -// abortIfEmptyBody :: {*} -> {*} -var abortIfEmptyBody = R.tap(R.cond([[ - R.pipe(R.prop('body'), R.isEmpty), - R.pipe( - R.path(['loc', 'source']), - R.concat('Nothing parsable in '), - abort - ) -]])); - -// dependenciesOf :: String -> [String] -// -// Returns the names of the immediate dependencies of the function with -// the given name. -// -// Assumes this format: -// -// var _quux = require('./_quux'); -// var bar = require('./bar'); -// var baz = require('./baz'); -// var foo = require('./foo'); -// -// Requirements: -// -// - one `var` per import; -// - argument to require must be a string literal; and -// - require path must match identifier. -var dependenciesOf = -R.pipe(identifierToFilename, - parse, - R.prop('ast'), - R.prop('body'), - warnIgnoredTopLevel, - R.takeWhile(R.both(R.propEq('type', 'VariableDeclaration'), - R.pipe(R.prop('declarations'), - R.all(isRequireExpr)))), - R.pluck('declarations'), - R.map(R.head), - abortIfNotSorted, - abortIfDifferentRequireVar, - R.map(R.path(['id', 'name']))); - -// createDependencyGraph :: [String] -> StrMap [String] -var createDependencyGraph = function createDependencyGraph(identifiers) { - var graph = {}; - var recur = function recur(identifier) { - if (!R.has(identifier, graph)) { - graph[identifier] = dependenciesOf(identifier); - graph[identifier].forEach(recur); - } - }; - identifiers.forEach(recur); - return graph; -}; - -// orderDependencies :: StrMap [String] -> [String] -var orderDependencies = function orderDependencies(graph) { - var recur = function recur(ins, outs) { - if (R.isEmpty(ins)) { - return outs; - } else if (R.all(R.contains(_, outs), graph[R.head(ins)])) { - return recur(R.tail(ins), R.append(R.head(ins), outs)); - } else { - return recur(R.append(R.head(ins), R.tail(ins)), outs); - } - }; - return recur(R.sortBy(R.identity, R.keys(graph)), []); -}; - -// getModifiedSource :: String -> String -var getModifiedSource = function getModifiedSource(identifier) { - var obj = parse(identifierToFilename(identifier)); - escodegen.attachComments(obj.ast, obj.comments, obj.tokens); - abortIfEmptyBody(obj.ast); - abortIfExportNotLast(obj.ast); - var last = R.last(obj.ast.body); - var declarationAst = { - type: 'VariableDeclaration', - kind: 'var', - leadingComments: obj.comments, - declarations: [ - { - type: 'VariableDeclarator', - id: {type: 'Identifier', name: identifier}, - init: last.expression.right - } - ] - }; - return escodegen.generate(declarationAst, {comment: true}); -}; - -// build :: [String] -> String -var build = -R.pipe(R.map(filenameToIdentifier), - R.sortBy(R.identity), - R.converge(R.concat, - R.pipe(createDependencyGraph, - orderDependencies, - R.map(getModifiedSource), - R.join('\n\n')), - R.pipe(R.map(R.converge(R.concat, - R.concat('\n '), - R.concat(': '))), - R.join(','), - R.concat('\n\nvar R = {'), - R.concat(_, '\n};'))), - R.replace(/\n(?!$)/gm, '\n '), - R.always, - R.replace('/* global R */', _, template)); - -program -.version(version) -.option('--complete', 'Include all Ramda functions') -.parse(process.argv); - -// filenames :: [String] -var filenames = program.complete - ? R.keys(require('../')) - : program.args; - -process.stdout.write(build(R.map(path.resolve, filenames))); diff --git a/scripts/header b/scripts/header deleted file mode 100755 index 21548fd87..000000000 --- a/scripts/header +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -set -e - -cat < false */ -module.exports = always(false); +var F = always(false); +export default F; diff --git a/src/T.js b/source/T.js similarity index 79% rename from src/T.js rename to source/T.js index fc15477bb..91d670db2 100644 --- a/src/T.js +++ b/source/T.js @@ -1,4 +1,4 @@ -var always = require('./always'); +import always from './always'; /** @@ -16,4 +16,5 @@ var always = require('./always'); * * R.T(); //=> true */ -module.exports = always(true); +var T = always(true); +export default T; diff --git a/src/__.js b/source/__.js similarity index 92% rename from src/__.js rename to source/__.js index b6b7499d8..75de937a6 100644 --- a/src/__.js +++ b/source/__.js @@ -24,4 +24,4 @@ * var greet = R.replace('{name}', R.__, 'Hello, {name}!'); * greet('Alice'); //=> 'Hello, Alice!' */ -module.exports = {'@@functional/placeholder': true}; +export default {'@@functional/placeholder': true}; diff --git a/src/add.js b/source/add.js similarity index 76% rename from src/add.js rename to source/add.js index 934e25c14..9f4fd9c4c 100644 --- a/src/add.js +++ b/source/add.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -18,6 +18,7 @@ var _curry2 = require('./internal/_curry2'); * R.add(2, 3); //=> 5 * R.add(7)(10); //=> 17 */ -module.exports = _curry2(function add(a, b) { +var add = _curry2(function add(a, b) { return Number(a) + Number(b); }); +export default add; diff --git a/src/addIndex.js b/source/addIndex.js similarity index 88% rename from src/addIndex.js rename to source/addIndex.js index 982beeee6..7eced25be 100644 --- a/src/addIndex.js +++ b/source/addIndex.js @@ -1,6 +1,6 @@ -var _concat = require('./internal/_concat'); -var _curry1 = require('./internal/_curry1'); -var curryN = require('./curryN'); +import _concat from './internal/_concat'; +import _curry1 from './internal/_curry1'; +import curryN from './curryN'; /** @@ -27,7 +27,7 @@ var curryN = require('./curryN'); * mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']); * //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r'] */ -module.exports = _curry1(function addIndex(fn) { +var addIndex = _curry1(function addIndex(fn) { return curryN(fn.length, function() { var idx = 0; var origFn = arguments[0]; @@ -41,3 +41,4 @@ module.exports = _curry1(function addIndex(fn) { return fn.apply(this, args); }); }); +export default addIndex; diff --git a/src/adjust.js b/source/adjust.js similarity index 87% rename from src/adjust.js rename to source/adjust.js index ca69bf8cd..6a2ee6f05 100644 --- a/src/adjust.js +++ b/source/adjust.js @@ -1,5 +1,5 @@ -var _concat = require('./internal/_concat'); -var _curry3 = require('./internal/_curry3'); +import _concat from './internal/_concat'; +import _curry3 from './internal/_curry3'; /** @@ -27,7 +27,7 @@ var _curry3 = require('./internal/_curry3'); * @symb R.adjust(f, -1, [a, b]) = [a, f(b)] * @symb R.adjust(f, 0, [a, b]) = [f(a), b] */ -module.exports = _curry3(function adjust(fn, idx, list) { +var adjust = _curry3(function adjust(fn, idx, list) { if (idx >= list.length || idx < -list.length) { return list; } @@ -37,3 +37,4 @@ module.exports = _curry3(function adjust(fn, idx, list) { _list[_idx] = fn(list[_idx]); return _list; }); +export default adjust; diff --git a/src/all.js b/source/all.js similarity index 79% rename from src/all.js rename to source/all.js index dc8ca5d2f..ecb65f27a 100644 --- a/src/all.js +++ b/source/all.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xall = require('./internal/_xall'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xall from './internal/_xall'; /** @@ -27,7 +27,7 @@ var _xall = require('./internal/_xall'); * R.all(equals3)([3, 3, 3, 3]); //=> true * R.all(equals3)([3, 3, 1, 3]); //=> false */ -module.exports = _curry2(_dispatchable(['all'], _xall, function all(fn, list) { +var all = _curry2(_dispatchable(['all'], _xall, function all(fn, list) { var idx = 0; while (idx < list.length) { if (!fn(list[idx])) { @@ -37,3 +37,4 @@ module.exports = _curry2(_dispatchable(['all'], _xall, function all(fn, list) { } return true; })); +export default all; diff --git a/src/allPass.js b/source/allPass.js similarity index 82% rename from src/allPass.js rename to source/allPass.js index 4896a9a3f..e1295c7b0 100644 --- a/src/allPass.js +++ b/source/allPass.js @@ -1,8 +1,8 @@ -var _curry1 = require('./internal/_curry1'); -var curryN = require('./curryN'); -var max = require('./max'); -var pluck = require('./pluck'); -var reduce = require('./reduce'); +import _curry1 from './internal/_curry1'; +import curryN from './curryN'; +import max from './max'; +import pluck from './pluck'; +import reduce from './reduce'; /** @@ -30,7 +30,7 @@ var reduce = require('./reduce'); * isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false * isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true */ -module.exports = _curry1(function allPass(preds) { +var allPass = _curry1(function allPass(preds) { return curryN(reduce(max, 0, pluck('length', preds)), function() { var idx = 0; var len = preds.length; @@ -43,3 +43,4 @@ module.exports = _curry1(function allPass(preds) { return true; }); }); +export default allPass; diff --git a/src/always.js b/source/always.js similarity index 84% rename from src/always.js rename to source/always.js index 6615090a4..893f80887 100644 --- a/src/always.js +++ b/source/always.js @@ -1,4 +1,4 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; /** @@ -20,8 +20,9 @@ var _curry1 = require('./internal/_curry1'); * var t = R.always('Tee'); * t(); //=> 'Tee' */ -module.exports = _curry1(function always(val) { +var always = _curry1(function always(val) { return function() { return val; }; }); +export default always; diff --git a/src/and.js b/source/and.js similarity index 82% rename from src/and.js rename to source/and.js index 0151429a7..ac9259e5f 100644 --- a/src/and.js +++ b/source/and.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -20,6 +20,7 @@ var _curry2 = require('./internal/_curry2'); * R.and(false, true); //=> false * R.and(false, false); //=> false */ -module.exports = _curry2(function and(a, b) { +var and = _curry2(function and(a, b) { return a && b; }); +export default and; diff --git a/src/any.js b/source/any.js similarity index 80% rename from src/any.js rename to source/any.js index 9b8a7c51b..79a5f2426 100644 --- a/src/any.js +++ b/source/any.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xany = require('./internal/_xany'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xany from './internal/_xany'; /** @@ -28,7 +28,7 @@ var _xany = require('./internal/_xany'); * R.any(lessThan0)([1, 2]); //=> false * R.any(lessThan2)([1, 2]); //=> true */ -module.exports = _curry2(_dispatchable(['any'], _xany, function any(fn, list) { +var any = _curry2(_dispatchable(['any'], _xany, function any(fn, list) { var idx = 0; while (idx < list.length) { if (fn(list[idx])) { @@ -38,3 +38,4 @@ module.exports = _curry2(_dispatchable(['any'], _xany, function any(fn, list) { } return false; })); +export default any; diff --git a/src/anyPass.js b/source/anyPass.js similarity index 83% rename from src/anyPass.js rename to source/anyPass.js index 22dc16668..932e578bf 100644 --- a/src/anyPass.js +++ b/source/anyPass.js @@ -1,8 +1,8 @@ -var _curry1 = require('./internal/_curry1'); -var curryN = require('./curryN'); -var max = require('./max'); -var pluck = require('./pluck'); -var reduce = require('./reduce'); +import _curry1 from './internal/_curry1'; +import curryN from './curryN'; +import max from './max'; +import pluck from './pluck'; +import reduce from './reduce'; /** @@ -31,7 +31,7 @@ var reduce = require('./reduce'); * isBlackCard({rank: 'Q', suit: '♠'}); //=> true * isBlackCard({rank: 'Q', suit: '♦'}); //=> false */ -module.exports = _curry1(function anyPass(preds) { +var anyPass = _curry1(function anyPass(preds) { return curryN(reduce(max, 0, pluck('length', preds)), function() { var idx = 0; var len = preds.length; @@ -44,3 +44,4 @@ module.exports = _curry1(function anyPass(preds) { return false; }); }); +export default anyPass; diff --git a/src/ap.js b/source/ap.js similarity index 84% rename from src/ap.js rename to source/ap.js index 6efea5584..99c9192c0 100644 --- a/src/ap.js +++ b/source/ap.js @@ -1,7 +1,7 @@ -var _concat = require('./internal/_concat'); -var _curry2 = require('./internal/_curry2'); -var _reduce = require('./internal/_reduce'); -var map = require('./map'); +import _concat from './internal/_concat'; +import _curry2 from './internal/_curry2'; +import _reduce from './internal/_reduce'; +import map from './map'; /** @@ -30,7 +30,7 @@ var map = require('./map'); * R.ap(R.concat, R.toUpper)('Ramda') //=> 'RamdaRAMDA' * @symb R.ap([f, g], [a, b]) = [f(a), f(b), g(a), g(b)] */ -module.exports = _curry2(function ap(applyF, applyX) { +var ap = _curry2(function ap(applyF, applyX) { return ( typeof applyX['fantasy-land/ap'] === 'function' ? applyX['fantasy-land/ap'](applyF) : @@ -42,3 +42,4 @@ module.exports = _curry2(function ap(applyF, applyX) { _reduce(function(acc, f) { return _concat(acc, map(f, applyX)); }, [], applyF) ); }); +export default ap; diff --git a/src/aperture.js b/source/aperture.js similarity index 72% rename from src/aperture.js rename to source/aperture.js index a65d8337e..ffef3ef72 100644 --- a/src/aperture.js +++ b/source/aperture.js @@ -1,7 +1,7 @@ -var _aperture = require('./internal/_aperture'); -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xaperture = require('./internal/_xaperture'); +import _aperture from './internal/_aperture'; +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xaperture from './internal/_xaperture'; /** @@ -25,4 +25,5 @@ var _xaperture = require('./internal/_xaperture'); * R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]] * R.aperture(7, [1, 2, 3, 4, 5]); //=> [] */ -module.exports = _curry2(_dispatchable([], _xaperture, _aperture)); +var aperture = _curry2(_dispatchable([], _xaperture, _aperture)); +export default aperture; diff --git a/src/append.js b/source/append.js similarity index 81% rename from src/append.js rename to source/append.js index 474d447d7..6e529ef49 100644 --- a/src/append.js +++ b/source/append.js @@ -1,5 +1,5 @@ -var _concat = require('./internal/_concat'); -var _curry2 = require('./internal/_curry2'); +import _concat from './internal/_concat'; +import _curry2 from './internal/_curry2'; /** @@ -22,6 +22,7 @@ var _curry2 = require('./internal/_curry2'); * R.append('tests', []); //=> ['tests'] * R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']] */ -module.exports = _curry2(function append(el, list) { +var append = _curry2(function append(el, list) { return _concat(list, [el]); }); +export default append; diff --git a/src/apply.js b/source/apply.js similarity index 86% rename from src/apply.js rename to source/apply.js index d053b3cfd..ba4b1d8b1 100644 --- a/src/apply.js +++ b/source/apply.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -21,6 +21,7 @@ var _curry2 = require('./internal/_curry2'); * R.apply(Math.max, nums); //=> 42 * @symb R.apply(f, [a, b, c]) = f(a, b, c) */ -module.exports = _curry2(function apply(fn, args) { +var apply = _curry2(function apply(fn, args) { return fn.apply(this, args); }); +export default apply; diff --git a/src/applySpec.js b/source/applySpec.js similarity index 80% rename from src/applySpec.js rename to source/applySpec.js index fa89837b7..0cefa69a2 100644 --- a/src/applySpec.js +++ b/source/applySpec.js @@ -1,11 +1,11 @@ -var _curry1 = require('./internal/_curry1'); -var apply = require('./apply'); -var curryN = require('./curryN'); -var map = require('./map'); -var max = require('./max'); -var pluck = require('./pluck'); -var reduce = require('./reduce'); -var values = require('./values'); +import _curry1 from './internal/_curry1'; +import apply from './apply'; +import curryN from './curryN'; +import map from './map'; +import max from './max'; +import pluck from './pluck'; +import reduce from './reduce'; +import values from './values'; /** @@ -33,7 +33,7 @@ var values = require('./values'); * getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } } * @symb R.applySpec({ x: f, y: { z: g } })(a, b) = { x: f(a, b), y: { z: g(a, b) } } */ -module.exports = _curry1(function applySpec(spec) { +var applySpec = _curry1(function applySpec(spec) { spec = map(function(v) { return typeof v == 'function' ? v : applySpec(v); }, spec); return curryN(reduce(max, 0, pluck('length', values(spec))), @@ -42,3 +42,4 @@ module.exports = _curry1(function applySpec(spec) { return map(function(f) { return apply(f, args); }, spec); }); }); +export default applySpec; diff --git a/src/ascend.js b/source/ascend.js similarity index 87% rename from src/ascend.js rename to source/ascend.js index bc5cc3c6f..2d379075e 100644 --- a/src/ascend.js +++ b/source/ascend.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -23,8 +23,9 @@ var _curry3 = require('./internal/_curry3'); * ]; * var peopleByYoungestFirst = R.sort(byAge, people); */ -module.exports = _curry3(function ascend(fn, a, b) { +var ascend = _curry3(function ascend(fn, a, b) { var aa = fn(a); var bb = fn(b); return aa < bb ? -1 : aa > bb ? 1 : 0; }); +export default ascend; diff --git a/src/assoc.js b/source/assoc.js similarity index 87% rename from src/assoc.js rename to source/assoc.js index a01235578..1300c8ce6 100644 --- a/src/assoc.js +++ b/source/assoc.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -21,7 +21,7 @@ var _curry3 = require('./internal/_curry3'); * * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3} */ -module.exports = _curry3(function assoc(prop, val, obj) { +var assoc = _curry3(function assoc(prop, val, obj) { var result = {}; for (var p in obj) { result[p] = obj[p]; @@ -29,3 +29,4 @@ module.exports = _curry3(function assoc(prop, val, obj) { result[prop] = val; return result; }); +export default assoc; diff --git a/src/assocPath.js b/source/assocPath.js similarity index 81% rename from src/assocPath.js rename to source/assocPath.js index b0285fbcd..145e9de87 100644 --- a/src/assocPath.js +++ b/source/assocPath.js @@ -1,9 +1,9 @@ -var _curry3 = require('./internal/_curry3'); -var _has = require('./internal/_has'); -var _isArray = require('./internal/_isArray'); -var _isInteger = require('./internal/_isInteger'); -var assoc = require('./assoc'); -var isNil = require('./isNil'); +import _curry3 from './internal/_curry3'; +import _has from './internal/_has'; +import _isArray from './internal/_isArray'; +import _isInteger from './internal/_isInteger'; +import assoc from './assoc'; +import isNil from './isNil'; /** @@ -30,7 +30,7 @@ var isNil = require('./isNil'); * // Any missing or non-object keys in path will be overridden * R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}} */ -module.exports = _curry3(function assocPath(path, val, obj) { +var assocPath = _curry3(function assocPath(path, val, obj) { if (path.length === 0) { return val; } @@ -47,3 +47,4 @@ module.exports = _curry3(function assocPath(path, val, obj) { return assoc(idx, val, obj); } }); +export default assocPath; diff --git a/src/binary.js b/source/binary.js similarity index 87% rename from src/binary.js rename to source/binary.js index 9bafb5b75..1e837c4a6 100644 --- a/src/binary.js +++ b/source/binary.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var nAry = require('./nAry'); +import _curry1 from './internal/_curry1'; +import nAry from './nAry'; /** @@ -30,6 +30,7 @@ var nAry = require('./nAry'); * takesTwoArgs(1, 2, 3); //=> [1, 2, undefined] * @symb R.binary(f)(a, b, c) = f(a, b) */ -module.exports = _curry1(function binary(fn) { +var binary = _curry1(function binary(fn) { return nAry(2, fn); }); +export default binary; diff --git a/src/bind.js b/source/bind.js similarity index 85% rename from src/bind.js rename to source/bind.js index e90e2c656..bf6c0e41b 100644 --- a/src/bind.js +++ b/source/bind.js @@ -1,5 +1,5 @@ -var _arity = require('./internal/_arity'); -var _curry2 = require('./internal/_curry2'); +import _arity from './internal/_arity'; +import _curry2 from './internal/_curry2'; /** @@ -24,8 +24,9 @@ var _curry2 = require('./internal/_curry2'); * // logs {a: 2} * @symb R.bind(f, o)(a, b) = f.call(o, a, b) */ -module.exports = _curry2(function bind(fn, thisObj) { +var bind = _curry2(function bind(fn, thisObj) { return _arity(fn.length, function() { return fn.apply(thisObj, arguments); }); }); +export default bind; diff --git a/src/both.js b/source/both.js similarity index 84% rename from src/both.js rename to source/both.js index 0e0faf5ec..3d7d1e27b 100644 --- a/src/both.js +++ b/source/both.js @@ -1,7 +1,7 @@ -var _curry2 = require('./internal/_curry2'); -var _isFunction = require('./internal/_isFunction'); -var and = require('./and'); -var lift = require('./lift'); +import _curry2 from './internal/_curry2'; +import _isFunction from './internal/_isFunction'; +import and from './and'; +import lift from './lift'; /** @@ -32,10 +32,11 @@ var lift = require('./lift'); * f(15); //=> true * f(30); //=> false */ -module.exports = _curry2(function both(f, g) { +var both = _curry2(function both(f, g) { return _isFunction(f) ? function _both() { return f.apply(this, arguments) && g.apply(this, arguments); } : lift(and)(f, g); }); +export default both; diff --git a/src/call.js b/source/call.js similarity index 93% rename from src/call.js rename to source/call.js index 0d43299e0..6e4f67f51 100644 --- a/src/call.js +++ b/source/call.js @@ -1,4 +1,4 @@ -var curry = require('./curry'); +import curry from './curry'; /** @@ -33,6 +33,7 @@ var curry = require('./curry'); * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n' * @symb R.call(f, a, b) = f(a, b) */ -module.exports = curry(function call(fn) { +var call = curry(function call(fn) { return fn.apply(this, Array.prototype.slice.call(arguments, 1)); }); +export default call; diff --git a/src/chain.js b/source/chain.js similarity index 72% rename from src/chain.js rename to source/chain.js index 2cbfec29e..e661385a4 100644 --- a/src/chain.js +++ b/source/chain.js @@ -1,8 +1,8 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _makeFlat = require('./internal/_makeFlat'); -var _xchain = require('./internal/_xchain'); -var map = require('./map'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _makeFlat from './internal/_makeFlat'; +import _xchain from './internal/_xchain'; +import map from './map'; /** @@ -27,9 +27,10 @@ var map = require('./map'); * * R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1] */ -module.exports = _curry2(_dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) { +var chain = _curry2(_dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) { if (typeof monad === 'function') { return function(x) { return fn(monad(x))(x); }; } return _makeFlat(false)(map(fn, monad)); })); +export default chain; diff --git a/src/clamp.js b/source/clamp.js similarity index 87% rename from src/clamp.js rename to source/clamp.js index 4e1680f25..c46a612d8 100644 --- a/src/clamp.js +++ b/source/clamp.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** * Restricts a number to be within a range. @@ -20,7 +20,7 @@ var _curry3 = require('./internal/_curry3'); * R.clamp(1, 10, 15) // => 10 * R.clamp(1, 10, 4) // => 4 */ -module.exports = _curry3(function clamp(min, max, value) { +var clamp = _curry3(function clamp(min, max, value) { if (min > max) { throw new Error('min must not be greater than max in clamp(min, max, value)'); } @@ -28,3 +28,4 @@ module.exports = _curry3(function clamp(min, max, value) { value > max ? max : value; }); +export default clamp; diff --git a/src/clone.js b/source/clone.js similarity index 83% rename from src/clone.js rename to source/clone.js index 4f483667c..f75d19777 100644 --- a/src/clone.js +++ b/source/clone.js @@ -1,5 +1,5 @@ -var _clone = require('./internal/_clone'); -var _curry1 = require('./internal/_curry1'); +import _clone from './internal/_clone'; +import _curry1 from './internal/_curry1'; /** @@ -23,8 +23,9 @@ var _curry1 = require('./internal/_curry1'); * objects === objectsClone; //=> false * objects[0] === objectsClone[0]; //=> false */ -module.exports = _curry1(function clone(value) { +var clone = _curry1(function clone(value) { return value != null && typeof value.clone === 'function' ? value.clone() : _clone(value, [], [], true); }); +export default clone; diff --git a/src/comparator.js b/source/comparator.js similarity index 86% rename from src/comparator.js rename to source/comparator.js index 0ec52ada0..758f9f004 100644 --- a/src/comparator.js +++ b/source/comparator.js @@ -1,4 +1,4 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; /** @@ -21,8 +21,9 @@ var _curry1 = require('./internal/_curry1'); * ]; * var peopleByIncreasingAge = R.sort(byAge, people); */ -module.exports = _curry1(function comparator(pred) { +var comparator = _curry1(function comparator(pred) { return function(a, b) { return pred(a, b) ? -1 : pred(b, a) ? 1 : 0; }; }); +export default comparator; diff --git a/src/complement.js b/source/complement.js similarity index 85% rename from src/complement.js rename to source/complement.js index 441875179..11374a822 100644 --- a/src/complement.js +++ b/source/complement.js @@ -1,5 +1,5 @@ -var lift = require('./lift'); -var not = require('./not'); +import lift from './lift'; +import not from './not'; /** @@ -24,4 +24,5 @@ var not = require('./not'); * isNil(7); //=> false * isNotNil(7); //=> true */ -module.exports = lift(not); +var complement = lift(not); +export default complement; diff --git a/src/compose.js b/source/compose.js similarity index 90% rename from src/compose.js rename to source/compose.js index 0f4dbe85c..b516fa223 100644 --- a/src/compose.js +++ b/source/compose.js @@ -1,5 +1,5 @@ -var pipe = require('./pipe'); -var reverse = require('./reverse'); +import pipe from './pipe'; +import reverse from './reverse'; /** @@ -26,9 +26,9 @@ var reverse = require('./reverse'); * * @symb R.compose(f, g, h)(a, b) = f(g(h(a, b))) */ -module.exports = function compose() { +export default function compose() { if (arguments.length === 0) { throw new Error('compose requires at least one argument'); } return pipe.apply(this, reverse(arguments)); -}; +} diff --git a/src/composeK.js b/source/composeK.js similarity index 90% rename from src/composeK.js rename to source/composeK.js index c83cf2a8c..892ca95b4 100644 --- a/src/composeK.js +++ b/source/composeK.js @@ -1,6 +1,6 @@ -var chain = require('./chain'); -var compose = require('./compose'); -var map = require('./map'); +import chain from './chain'; +import compose from './compose'; +import map from './map'; /** @@ -33,11 +33,11 @@ var map = require('./map'); * getStateCode({}); //=> Maybe.Nothing() * @symb R.composeK(f, g, h)(a) = R.chain(f, R.chain(g, h(a))) */ -module.exports = function composeK() { +export default function composeK() { if (arguments.length === 0) { throw new Error('composeK requires at least one argument'); } var init = Array.prototype.slice.call(arguments); var last = init.pop(); return compose(compose.apply(this, map(chain, init)), last); -}; +} diff --git a/src/composeP.js b/source/composeP.js similarity index 92% rename from src/composeP.js rename to source/composeP.js index e0d22e972..b0997e435 100644 --- a/src/composeP.js +++ b/source/composeP.js @@ -1,5 +1,5 @@ -var pipeP = require('./pipeP'); -var reverse = require('./reverse'); +import pipeP from './pipeP'; +import reverse from './reverse'; /** @@ -36,9 +36,9 @@ var reverse = require('./reverse'); * followersForUser('JOE').then(followers => console.log('Followers:', followers)) * // Followers: ["STEVE","SUZY"] */ -module.exports = function composeP() { +export default function composeP() { if (arguments.length === 0) { throw new Error('composeP requires at least one argument'); } return pipeP.apply(this, reverse(arguments)); -}; +} diff --git a/src/concat.js b/source/concat.js similarity index 84% rename from src/concat.js rename to source/concat.js index cfc393fa2..13121fd72 100644 --- a/src/concat.js +++ b/source/concat.js @@ -1,8 +1,8 @@ -var _curry2 = require('./internal/_curry2'); -var _isArray = require('./internal/_isArray'); -var _isFunction = require('./internal/_isFunction'); -var _isString = require('./internal/_isString'); -var toString = require('./toString'); +import _curry2 from './internal/_curry2'; +import _isArray from './internal/_isArray'; +import _isFunction from './internal/_isFunction'; +import _isString from './internal/_isString'; +import toString from './toString'; /** @@ -33,7 +33,7 @@ var toString = require('./toString'); * R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] * R.concat([], []); //=> [] */ -module.exports = _curry2(function concat(a, b) { +var concat = _curry2(function concat(a, b) { if (_isArray(a)) { if (_isArray(b)) { return a.concat(b); @@ -54,3 +54,4 @@ module.exports = _curry2(function concat(a, b) { } throw new TypeError(toString(a) + ' does not have a method named "concat" or "fantasy-land/concat"'); }); +export default concat; diff --git a/src/cond.js b/source/cond.js similarity index 86% rename from src/cond.js rename to source/cond.js index a96822afb..7d01a7469 100644 --- a/src/cond.js +++ b/source/cond.js @@ -1,8 +1,8 @@ -var _arity = require('./internal/_arity'); -var _curry1 = require('./internal/_curry1'); -var map = require('./map'); -var max = require('./max'); -var reduce = require('./reduce'); +import _arity from './internal/_arity'; +import _curry1 from './internal/_curry1'; +import map from './map'; +import max from './max'; +import reduce from './reduce'; /** @@ -31,7 +31,7 @@ var reduce = require('./reduce'); * fn(50); //=> 'nothing special happens at 50°C' * fn(100); //=> 'water boils at 100°C' */ -module.exports = _curry1(function cond(pairs) { +var cond = _curry1(function cond(pairs) { var arity = reduce(max, 0, map(function(pair) { return pair[0].length; }, pairs)); @@ -45,3 +45,4 @@ module.exports = _curry1(function cond(pairs) { } }); }); +export default cond; diff --git a/src/construct.js b/source/construct.js similarity index 87% rename from src/construct.js rename to source/construct.js index 43dd68f62..e34e274cf 100644 --- a/src/construct.js +++ b/source/construct.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var constructN = require('./constructN'); +import _curry1 from './internal/_curry1'; +import constructN from './constructN'; /** @@ -34,6 +34,7 @@ var constructN = require('./constructN'); * var sightNewAnimal = R.compose(animalSighting, AnimalConstructor); * R.map(sightNewAnimal, animalTypes); //=> ["It's a Lion!", "It's a Tiger!", "It's a Bear!"] */ -module.exports = _curry1(function construct(Fn) { +var construct = _curry1(function construct(Fn) { return constructN(Fn.length, Fn); }); +export default construct; diff --git a/src/constructN.js b/source/constructN.js similarity index 91% rename from src/constructN.js rename to source/constructN.js index 606a240db..88a83c80f 100644 --- a/src/constructN.js +++ b/source/constructN.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var curry = require('./curry'); -var nAry = require('./nAry'); +import _curry2 from './internal/_curry2'; +import curry from './curry'; +import nAry from './nAry'; /** @@ -38,7 +38,7 @@ var nAry = require('./nAry'); * // Add a dollop of Potato Chips * // Add a dollop of Ketchup */ -module.exports = _curry2(function constructN(n, Fn) { +var constructN = _curry2(function constructN(n, Fn) { if (n > 10) { throw new Error('Constructor with greater than ten arguments'); } @@ -60,3 +60,4 @@ module.exports = _curry2(function constructN(n, Fn) { } })); }); +export default constructN; diff --git a/src/contains.js b/source/contains.js similarity index 81% rename from src/contains.js rename to source/contains.js index d0c6ae7a0..217632c7f 100644 --- a/src/contains.js +++ b/source/contains.js @@ -1,5 +1,5 @@ -var _contains = require('./internal/_contains'); -var _curry2 = require('./internal/_curry2'); +import _contains from './internal/_contains'; +import _curry2 from './internal/_curry2'; /** @@ -22,4 +22,5 @@ var _curry2 = require('./internal/_curry2'); * R.contains({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true * R.contains([42], [[42]]); //=> true */ -module.exports = _curry2(_contains); +var contains = _curry2(_contains); +export default contains; diff --git a/src/converge.js b/source/converge.js similarity index 82% rename from src/converge.js rename to source/converge.js index 237c03d8d..bc786f0ad 100644 --- a/src/converge.js +++ b/source/converge.js @@ -1,9 +1,9 @@ -var _curry2 = require('./internal/_curry2'); -var _map = require('./internal/_map'); -var curryN = require('./curryN'); -var max = require('./max'); -var pluck = require('./pluck'); -var reduce = require('./reduce'); +import _curry2 from './internal/_curry2'; +import _map from './internal/_map'; +import curryN from './curryN'; +import max from './max'; +import pluck from './pluck'; +import reduce from './reduce'; /** @@ -33,7 +33,7 @@ var reduce = require('./reduce'); * * @symb R.converge(f, [g, h])(a, b) = f(g(a, b), h(a, b)) */ -module.exports = _curry2(function converge(after, fns) { +var converge = _curry2(function converge(after, fns) { return curryN(reduce(max, 0, pluck('length', fns)), function() { var args = arguments; var context = this; @@ -42,3 +42,4 @@ module.exports = _curry2(function converge(after, fns) { }, fns)); }); }); +export default converge; diff --git a/src/countBy.js b/source/countBy.js similarity index 88% rename from src/countBy.js rename to source/countBy.js index 396a92657..e1b138626 100644 --- a/src/countBy.js +++ b/source/countBy.js @@ -1,4 +1,4 @@ -var reduceBy = require('./reduceBy'); +import reduceBy from './reduceBy'; /** @@ -25,4 +25,5 @@ var reduceBy = require('./reduceBy'); * var letters = ['a', 'b', 'A', 'a', 'B', 'c']; * R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1} */ -module.exports = reduceBy(function(acc, elem) { return acc + 1; }, 0); +var countBy = reduceBy(function(acc, elem) { return acc + 1; }, 0); +export default countBy; diff --git a/src/curry.js b/source/curry.js similarity index 90% rename from src/curry.js rename to source/curry.js index 22d22e0ce..8d07e3618 100644 --- a/src/curry.js +++ b/source/curry.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var curryN = require('./curryN'); +import _curry1 from './internal/_curry1'; +import curryN from './curryN'; /** @@ -43,6 +43,7 @@ var curryN = require('./curryN'); * var g = f(3); * g(4); //=> 10 */ -module.exports = _curry1(function curry(fn) { +var curry = _curry1(function curry(fn) { return curryN(fn.length, fn); }); +export default curry; diff --git a/src/curryN.js b/source/curryN.js similarity index 85% rename from src/curryN.js rename to source/curryN.js index a05f41dc8..036ac623d 100644 --- a/src/curryN.js +++ b/source/curryN.js @@ -1,7 +1,7 @@ -var _arity = require('./internal/_arity'); -var _curry1 = require('./internal/_curry1'); -var _curry2 = require('./internal/_curry2'); -var _curryN = require('./internal/_curryN'); +import _arity from './internal/_arity'; +import _curry1 from './internal/_curry1'; +import _curry2 from './internal/_curry2'; +import _curryN from './internal/_curryN'; /** @@ -46,9 +46,10 @@ var _curryN = require('./internal/_curryN'); * var g = f(3); * g(4); //=> 10 */ -module.exports = _curry2(function curryN(length, fn) { +var curryN = _curry2(function curryN(length, fn) { if (length === 1) { return _curry1(fn); } return _arity(length, _curryN(length, [], fn)); }); +export default curryN; diff --git a/src/dec.js b/source/dec.js similarity index 78% rename from src/dec.js rename to source/dec.js index 215ac35f6..9b85d3907 100644 --- a/src/dec.js +++ b/source/dec.js @@ -1,4 +1,4 @@ -var add = require('./add'); +import add from './add'; /** @@ -16,4 +16,5 @@ var add = require('./add'); * * R.dec(42); //=> 41 */ -module.exports = add(-1); +var dec = add(-1); +export default dec; diff --git a/src/defaultTo.js b/source/defaultTo.js similarity index 86% rename from src/defaultTo.js rename to source/defaultTo.js index c6efd5b06..e422c53c0 100644 --- a/src/defaultTo.js +++ b/source/defaultTo.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -23,6 +23,7 @@ var _curry2 = require('./internal/_curry2'); * // parseInt('string') results in NaN * defaultTo42(parseInt('string')); //=> 42 */ -module.exports = _curry2(function defaultTo(d, v) { +var defaultTo = _curry2(function defaultTo(d, v) { return v == null || v !== v ? d : v; }); +export default defaultTo; diff --git a/src/descend.js b/source/descend.js similarity index 86% rename from src/descend.js rename to source/descend.js index 6ca40c7fe..b22fef0ce 100644 --- a/src/descend.js +++ b/source/descend.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -23,8 +23,9 @@ var _curry3 = require('./internal/_curry3'); * ]; * var peopleByOldestFirst = R.sort(byAge, people); */ -module.exports = _curry3(function descend(fn, a, b) { +var descend = _curry3(function descend(fn, a, b) { var aa = fn(a); var bb = fn(b); return aa > bb ? -1 : aa < bb ? 1 : 0; }); +export default descend; diff --git a/src/difference.js b/source/difference.js similarity index 84% rename from src/difference.js rename to source/difference.js index 7071db103..e0314ae86 100644 --- a/src/difference.js +++ b/source/difference.js @@ -1,5 +1,5 @@ -var _contains = require('./internal/_contains'); -var _curry2 = require('./internal/_curry2'); +import _contains from './internal/_contains'; +import _curry2 from './internal/_curry2'; /** @@ -22,7 +22,7 @@ var _curry2 = require('./internal/_curry2'); * R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5] * R.difference([{a: 1}, {b: 2}], [{a: 1}, {c: 3}]) //=> [{b: 2}] */ -module.exports = _curry2(function difference(first, second) { +var difference = _curry2(function difference(first, second) { var out = []; var idx = 0; var firstLen = first.length; @@ -34,3 +34,4 @@ module.exports = _curry2(function difference(first, second) { } return out; }); +export default difference; diff --git a/src/differenceWith.js b/source/differenceWith.js similarity index 84% rename from src/differenceWith.js rename to source/differenceWith.js index 1dc3db5b2..8c81d77e2 100644 --- a/src/differenceWith.js +++ b/source/differenceWith.js @@ -1,5 +1,5 @@ -var _containsWith = require('./internal/_containsWith'); -var _curry3 = require('./internal/_curry3'); +import _containsWith from './internal/_containsWith'; +import _curry3 from './internal/_curry3'; /** @@ -24,7 +24,7 @@ var _curry3 = require('./internal/_curry3'); * var l2 = [{a: 3}, {a: 4}]; * R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}] */ -module.exports = _curry3(function differenceWith(pred, first, second) { +var differenceWith = _curry3(function differenceWith(pred, first, second) { var out = []; var idx = 0; var firstLen = first.length; @@ -37,3 +37,4 @@ module.exports = _curry3(function differenceWith(pred, first, second) { } return out; }); +export default differenceWith; diff --git a/src/dissoc.js b/source/dissoc.js similarity index 83% rename from src/dissoc.js rename to source/dissoc.js index f46160878..02f315126 100644 --- a/src/dissoc.js +++ b/source/dissoc.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -17,7 +17,7 @@ var _curry2 = require('./internal/_curry2'); * * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3} */ -module.exports = _curry2(function dissoc(prop, obj) { +var dissoc = _curry2(function dissoc(prop, obj) { var result = {}; for (var p in obj) { result[p] = obj[p]; @@ -25,3 +25,4 @@ module.exports = _curry2(function dissoc(prop, obj) { delete result[prop]; return result; }); +export default dissoc; diff --git a/src/dissocPath.js b/source/dissocPath.js similarity index 79% rename from src/dissocPath.js rename to source/dissocPath.js index cf96b9df1..ce847f154 100644 --- a/src/dissocPath.js +++ b/source/dissocPath.js @@ -1,9 +1,9 @@ -var _curry2 = require('./internal/_curry2'); -var _isInteger = require('./internal/_isInteger'); -var assoc = require('./assoc'); -var dissoc = require('./dissoc'); -var remove = require('./remove'); -var update = require('./update'); +import _curry2 from './internal/_curry2'; +import _isInteger from './internal/_isInteger'; +import assoc from './assoc'; +import dissoc from './dissoc'; +import remove from './remove'; +import update from './update'; /** @@ -25,7 +25,7 @@ var update = require('./update'); * * R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}} */ -module.exports = _curry2(function dissocPath(path, obj) { +var dissocPath = _curry2(function dissocPath(path, obj) { switch (path.length) { case 0: return obj; @@ -43,3 +43,4 @@ module.exports = _curry2(function dissocPath(path, obj) { } } }); +export default dissocPath; diff --git a/src/divide.js b/source/divide.js similarity index 79% rename from src/divide.js rename to source/divide.js index 18299798d..dfc7f4828 100644 --- a/src/divide.js +++ b/source/divide.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -23,4 +23,5 @@ var _curry2 = require('./internal/_curry2'); * var reciprocal = R.divide(1); * reciprocal(4); //=> 0.25 */ -module.exports = _curry2(function divide(a, b) { return a / b; }); +var divide = _curry2(function divide(a, b) { return a / b; }); +export default divide; diff --git a/src/drop.js b/source/drop.js similarity index 76% rename from src/drop.js rename to source/drop.js index 150364585..b9e6fb981 100644 --- a/src/drop.js +++ b/source/drop.js @@ -1,7 +1,7 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xdrop = require('./internal/_xdrop'); -var slice = require('./slice'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xdrop from './internal/_xdrop'; +import slice from './slice'; /** @@ -28,6 +28,7 @@ var slice = require('./slice'); * R.drop(4, ['foo', 'bar', 'baz']); //=> [] * R.drop(3, 'ramda'); //=> 'da' */ -module.exports = _curry2(_dispatchable(['drop'], _xdrop, function drop(n, xs) { +var drop = _curry2(_dispatchable(['drop'], _xdrop, function drop(n, xs) { return slice(Math.max(0, n), Infinity, xs); })); +export default drop; diff --git a/src/dropLast.js b/source/dropLast.js similarity index 73% rename from src/dropLast.js rename to source/dropLast.js index 8fd298bd8..59466408a 100644 --- a/src/dropLast.js +++ b/source/dropLast.js @@ -1,7 +1,7 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _dropLast = require('./internal/_dropLast'); -var _xdropLast = require('./internal/_xdropLast'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _dropLast from './internal/_dropLast'; +import _xdropLast from './internal/_xdropLast'; /** @@ -25,4 +25,5 @@ var _xdropLast = require('./internal/_xdropLast'); * R.dropLast(4, ['foo', 'bar', 'baz']); //=> [] * R.dropLast(3, 'ramda'); //=> 'ra' */ -module.exports = _curry2(_dispatchable([], _xdropLast, _dropLast)); +var dropLast = _curry2(_dispatchable([], _xdropLast, _dropLast)); +export default dropLast; diff --git a/src/dropLastWhile.js b/source/dropLastWhile.js similarity index 75% rename from src/dropLastWhile.js rename to source/dropLastWhile.js index 41211a2c5..16ae8e66a 100644 --- a/src/dropLastWhile.js +++ b/source/dropLastWhile.js @@ -1,7 +1,7 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _dropLastWhile = require('./internal/_dropLastWhile'); -var _xdropLastWhile = require('./internal/_xdropLastWhile'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _dropLastWhile from './internal/_dropLastWhile'; +import _xdropLastWhile from './internal/_xdropLastWhile'; /** @@ -29,4 +29,5 @@ var _xdropLastWhile = require('./internal/_xdropLastWhile'); * * R.dropLastWhile(x => x !== 'd' , 'Ramda'); //=> 'Ramd' */ -module.exports = _curry2(_dispatchable([], _xdropLastWhile, _dropLastWhile)); +var dropLastWhile = _curry2(_dispatchable([], _xdropLastWhile, _dropLastWhile)); +export default dropLastWhile; diff --git a/src/dropRepeats.js b/source/dropRepeats.js similarity index 51% rename from src/dropRepeats.js rename to source/dropRepeats.js index 3604eb2ed..2cc247f86 100644 --- a/src/dropRepeats.js +++ b/source/dropRepeats.js @@ -1,8 +1,8 @@ -var _curry1 = require('./internal/_curry1'); -var _dispatchable = require('./internal/_dispatchable'); -var _xdropRepeatsWith = require('./internal/_xdropRepeatsWith'); -var dropRepeatsWith = require('./dropRepeatsWith'); -var equals = require('./equals'); +import _curry1 from './internal/_curry1'; +import _dispatchable from './internal/_dispatchable'; +import _xdropRepeatsWith from './internal/_xdropRepeatsWith'; +import dropRepeatsWith from './dropRepeatsWith'; +import equals from './equals'; /** @@ -23,4 +23,7 @@ var equals = require('./equals'); * * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2] */ -module.exports = _curry1(_dispatchable([], _xdropRepeatsWith(equals), dropRepeatsWith(equals))); +var dropRepeats = _curry1(_dispatchable([], + _xdropRepeatsWith(equals), + dropRepeatsWith(equals))); +export default dropRepeats; diff --git a/src/dropRepeatsWith.js b/source/dropRepeatsWith.js similarity index 76% rename from src/dropRepeatsWith.js rename to source/dropRepeatsWith.js index 18023e7ec..c1c5dcde6 100644 --- a/src/dropRepeatsWith.js +++ b/source/dropRepeatsWith.js @@ -1,7 +1,7 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xdropRepeatsWith = require('./internal/_xdropRepeatsWith'); -var last = require('./last'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xdropRepeatsWith from './internal/_xdropRepeatsWith'; +import last from './last'; /** @@ -25,7 +25,7 @@ var last = require('./last'); * var l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3]; * R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3] */ -module.exports = _curry2(_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) { +var dropRepeatsWith = _curry2(_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) { var result = []; var idx = 1; var len = list.length; @@ -40,3 +40,4 @@ module.exports = _curry2(_dispatchable([], _xdropRepeatsWith, function dropRepea } return result; })); +export default dropRepeatsWith; diff --git a/src/dropWhile.js b/source/dropWhile.js similarity index 78% rename from src/dropWhile.js rename to source/dropWhile.js index d4aa84e60..173bd70cf 100644 --- a/src/dropWhile.js +++ b/source/dropWhile.js @@ -1,7 +1,7 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xdropWhile = require('./internal/_xdropWhile'); -var slice = require('./slice'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xdropWhile from './internal/_xdropWhile'; +import slice from './slice'; /** @@ -32,7 +32,7 @@ var slice = require('./slice'); * * R.dropWhile(x => x !== 'd' , 'Ramda'); //=> 'da' */ -module.exports = _curry2(_dispatchable(['dropWhile'], _xdropWhile, function dropWhile(pred, xs) { +var dropWhile = _curry2(_dispatchable(['dropWhile'], _xdropWhile, function dropWhile(pred, xs) { var idx = 0; var len = xs.length; while (idx < len && pred(xs[idx])) { @@ -40,3 +40,4 @@ module.exports = _curry2(_dispatchable(['dropWhile'], _xdropWhile, function drop } return slice(idx, Infinity, xs); })); +export default dropWhile; diff --git a/src/either.js b/source/either.js similarity index 83% rename from src/either.js rename to source/either.js index e9cc6eea2..858e62571 100644 --- a/src/either.js +++ b/source/either.js @@ -1,7 +1,7 @@ -var _curry2 = require('./internal/_curry2'); -var _isFunction = require('./internal/_isFunction'); -var lift = require('./lift'); -var or = require('./or'); +import _curry2 from './internal/_curry2'; +import _isFunction from './internal/_isFunction'; +import lift from './lift'; +import or from './or'; /** @@ -31,10 +31,11 @@ var or = require('./or'); * f(101); //=> true * f(8); //=> true */ -module.exports = _curry2(function either(f, g) { +var either = _curry2(function either(f, g) { return _isFunction(f) ? function _either() { return f.apply(this, arguments) || g.apply(this, arguments); } : lift(or)(f, g); }); +export default either; diff --git a/src/empty.js b/source/empty.js similarity index 82% rename from src/empty.js rename to source/empty.js index d881aaf61..2a1a1fcb2 100644 --- a/src/empty.js +++ b/source/empty.js @@ -1,8 +1,8 @@ -var _curry1 = require('./internal/_curry1'); -var _isArguments = require('./internal/_isArguments'); -var _isArray = require('./internal/_isArray'); -var _isObject = require('./internal/_isObject'); -var _isString = require('./internal/_isString'); +import _curry1 from './internal/_curry1'; +import _isArguments from './internal/_isArguments'; +import _isArray from './internal/_isArray'; +import _isObject from './internal/_isObject'; +import _isString from './internal/_isString'; /** @@ -28,7 +28,7 @@ var _isString = require('./internal/_isString'); * R.empty('unicorns'); //=> '' * R.empty({x: 1, y: 2}); //=> {} */ -module.exports = _curry1(function empty(x) { +var empty = _curry1(function empty(x) { return ( (x != null && typeof x['fantasy-land/empty'] === 'function') ? x['fantasy-land/empty']() : @@ -50,3 +50,4 @@ module.exports = _curry1(function empty(x) { void 0 ); }); +export default empty; diff --git a/src/endsWith.js b/source/endsWith.js similarity index 74% rename from src/endsWith.js rename to source/endsWith.js index e4f5c910d..74c470397 100644 --- a/src/endsWith.js +++ b/source/endsWith.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var equals = require('./equals'); -var takeLast = require('./takeLast'); +import _curry2 from './internal/_curry2'; +import equals from './equals'; +import takeLast from './takeLast'; /** * Checks if a list ends with the provided values @@ -21,6 +21,7 @@ var takeLast = require('./takeLast'); * R.endsWith(['c'], ['a', 'b', 'c']) //=> true * R.endsWith(['b'], ['a', 'b', 'c']) //=> false */ -module.exports = _curry2(function(suffix, list) { +var endsWith = _curry2(function(suffix, list) { return equals(takeLast(suffix.length, list), suffix); }); +export default endsWith; diff --git a/src/eqBy.js b/source/eqBy.js similarity index 75% rename from src/eqBy.js rename to source/eqBy.js index b30a9fdd4..21d085d33 100644 --- a/src/eqBy.js +++ b/source/eqBy.js @@ -1,5 +1,5 @@ -var _curry3 = require('./internal/_curry3'); -var equals = require('./equals'); +import _curry3 from './internal/_curry3'; +import equals from './equals'; /** @@ -19,6 +19,7 @@ var equals = require('./equals'); * * R.eqBy(Math.abs, 5, -5); //=> true */ -module.exports = _curry3(function eqBy(f, x, y) { +var eqBy = _curry3(function eqBy(f, x, y) { return equals(f(x), f(y)); }); +export default eqBy; diff --git a/src/eqProps.js b/source/eqProps.js similarity index 80% rename from src/eqProps.js rename to source/eqProps.js index a26eda574..f7ab67791 100644 --- a/src/eqProps.js +++ b/source/eqProps.js @@ -1,5 +1,5 @@ -var _curry3 = require('./internal/_curry3'); -var equals = require('./equals'); +import _curry3 from './internal/_curry3'; +import equals from './equals'; /** @@ -23,6 +23,7 @@ var equals = require('./equals'); * R.eqProps('a', o1, o2); //=> false * R.eqProps('c', o1, o2); //=> true */ -module.exports = _curry3(function eqProps(prop, obj1, obj2) { +var eqProps = _curry3(function eqProps(prop, obj1, obj2) { return equals(obj1[prop], obj2[prop]); }); +export default eqProps; diff --git a/src/equals.js b/source/equals.js similarity index 80% rename from src/equals.js rename to source/equals.js index 5cc2bbe84..3a052c6c7 100644 --- a/src/equals.js +++ b/source/equals.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var _equals = require('./internal/_equals'); +import _curry2 from './internal/_curry2'; +import _equals from './internal/_equals'; /** @@ -27,6 +27,7 @@ var _equals = require('./internal/_equals'); * var b = {}; b.v = b; * R.equals(a, b); //=> true */ -module.exports = _curry2(function equals(a, b) { +var equals = _curry2(function equals(a, b) { return _equals(a, b, [], []); }); +export default equals; diff --git a/src/evolve.js b/source/evolve.js similarity index 91% rename from src/evolve.js rename to source/evolve.js index 1757dbf9f..479e75fd7 100644 --- a/src/evolve.js +++ b/source/evolve.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -28,7 +28,7 @@ var _curry2 = require('./internal/_curry2'); * }; * R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123} */ -module.exports = _curry2(function evolve(transformations, object) { +var evolve = _curry2(function evolve(transformations, object) { var result = {}; var transformation, key, type; for (key in object) { @@ -40,3 +40,4 @@ module.exports = _curry2(function evolve(transformations, object) { } return result; }); +export default evolve; diff --git a/src/filter.js b/source/filter.js similarity index 73% rename from src/filter.js rename to source/filter.js index 7cef2b9a5..1b0e71f5c 100644 --- a/src/filter.js +++ b/source/filter.js @@ -1,10 +1,10 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _filter = require('./internal/_filter'); -var _isObject = require('./internal/_isObject'); -var _reduce = require('./internal/_reduce'); -var _xfilter = require('./internal/_xfilter'); -var keys = require('./keys'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _filter from './internal/_filter'; +import _isObject from './internal/_isObject'; +import _reduce from './internal/_reduce'; +import _xfilter from './internal/_xfilter'; +import keys from './keys'; /** @@ -34,7 +34,7 @@ var keys = require('./keys'); * * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} */ -module.exports = _curry2(_dispatchable(['filter'], _xfilter, function(pred, filterable) { +var filter = _curry2(_dispatchable(['filter'], _xfilter, function(pred, filterable) { return ( _isObject(filterable) ? _reduce(function(acc, key) { @@ -47,3 +47,4 @@ module.exports = _curry2(_dispatchable(['filter'], _xfilter, function(pred, filt _filter(pred, filterable) ); })); +export default filter; diff --git a/src/find.js b/source/find.js similarity index 79% rename from src/find.js rename to source/find.js index acc3e2d58..2808f1326 100644 --- a/src/find.js +++ b/source/find.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xfind = require('./internal/_xfind'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xfind from './internal/_xfind'; /** @@ -27,7 +27,7 @@ var _xfind = require('./internal/_xfind'); * R.find(R.propEq('a', 2))(xs); //=> {a: 2} * R.find(R.propEq('a', 4))(xs); //=> undefined */ -module.exports = _curry2(_dispatchable(['find'], _xfind, function find(fn, list) { +var find = _curry2(_dispatchable(['find'], _xfind, function find(fn, list) { var idx = 0; var len = list.length; while (idx < len) { @@ -37,3 +37,4 @@ module.exports = _curry2(_dispatchable(['find'], _xfind, function find(fn, list) idx += 1; } })); +export default find; diff --git a/src/findIndex.js b/source/findIndex.js similarity index 76% rename from src/findIndex.js rename to source/findIndex.js index fb9bfb147..5b1bada37 100644 --- a/src/findIndex.js +++ b/source/findIndex.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xfindIndex = require('./internal/_xfindIndex'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xfindIndex from './internal/_xfindIndex'; /** @@ -25,7 +25,7 @@ var _xfindIndex = require('./internal/_xfindIndex'); * R.findIndex(R.propEq('a', 2))(xs); //=> 1 * R.findIndex(R.propEq('a', 4))(xs); //=> -1 */ -module.exports = _curry2(_dispatchable([], _xfindIndex, function findIndex(fn, list) { +var findIndex = _curry2(_dispatchable([], _xfindIndex, function findIndex(fn, list) { var idx = 0; var len = list.length; while (idx < len) { @@ -36,3 +36,4 @@ module.exports = _curry2(_dispatchable([], _xfindIndex, function findIndex(fn, l } return -1; })); +export default findIndex; diff --git a/src/findLast.js b/source/findLast.js similarity index 76% rename from src/findLast.js rename to source/findLast.js index c878603ef..774d6723d 100644 --- a/src/findLast.js +++ b/source/findLast.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xfindLast = require('./internal/_xfindLast'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xfindLast from './internal/_xfindLast'; /** @@ -25,7 +25,7 @@ var _xfindLast = require('./internal/_xfindLast'); * R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1} * R.findLast(R.propEq('a', 4))(xs); //=> undefined */ -module.exports = _curry2(_dispatchable([], _xfindLast, function findLast(fn, list) { +var findLast = _curry2(_dispatchable([], _xfindLast, function findLast(fn, list) { var idx = list.length - 1; while (idx >= 0) { if (fn(list[idx])) { @@ -34,3 +34,4 @@ module.exports = _curry2(_dispatchable([], _xfindLast, function findLast(fn, lis idx -= 1; } })); +export default findLast; diff --git a/src/findLastIndex.js b/source/findLastIndex.js similarity index 74% rename from src/findLastIndex.js rename to source/findLastIndex.js index 72b55f77a..8d3114026 100644 --- a/src/findLastIndex.js +++ b/source/findLastIndex.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xfindLastIndex = require('./internal/_xfindLastIndex'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xfindLastIndex from './internal/_xfindLastIndex'; /** @@ -25,7 +25,7 @@ var _xfindLastIndex = require('./internal/_xfindLastIndex'); * R.findLastIndex(R.propEq('a', 1))(xs); //=> 1 * R.findLastIndex(R.propEq('a', 4))(xs); //=> -1 */ -module.exports = _curry2(_dispatchable([], _xfindLastIndex, function findLastIndex(fn, list) { +var findLastIndex = _curry2(_dispatchable([], _xfindLastIndex, function findLastIndex(fn, list) { var idx = list.length - 1; while (idx >= 0) { if (fn(list[idx])) { @@ -35,3 +35,4 @@ module.exports = _curry2(_dispatchable([], _xfindLastIndex, function findLastInd } return -1; })); +export default findLastIndex; diff --git a/src/flatten.js b/source/flatten.js similarity index 75% rename from src/flatten.js rename to source/flatten.js index 5fe66610c..0ad999281 100644 --- a/src/flatten.js +++ b/source/flatten.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var _makeFlat = require('./internal/_makeFlat'); +import _curry1 from './internal/_curry1'; +import _makeFlat from './internal/_makeFlat'; /** @@ -19,4 +19,5 @@ var _makeFlat = require('./internal/_makeFlat'); * 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] */ -module.exports = _curry1(_makeFlat(true)); +var flatten = _curry1(_makeFlat(true)); +export default flatten; diff --git a/src/flip.js b/source/flip.js similarity index 86% rename from src/flip.js rename to source/flip.js index 136c33b30..4203b3ec1 100644 --- a/src/flip.js +++ b/source/flip.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var curry = require('./curry'); +import _curry1 from './internal/_curry1'; +import curry from './curry'; /** @@ -22,7 +22,7 @@ var curry = require('./curry'); * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3] * @symb R.flip(f)(a, b, c) = f(b, a, c) */ -module.exports = _curry1(function flip(fn) { +var flip = _curry1(function flip(fn) { return curry(function(a, b) { var args = Array.prototype.slice.call(arguments, 0); args[0] = b; @@ -30,3 +30,4 @@ module.exports = _curry1(function flip(fn) { return fn.apply(this, args); }); }); +export default flip; diff --git a/src/forEach.js b/source/forEach.js similarity index 86% rename from src/forEach.js rename to source/forEach.js index 1fc0073ca..96feb1d58 100644 --- a/src/forEach.js +++ b/source/forEach.js @@ -1,5 +1,5 @@ -var _checkForMethod = require('./internal/_checkForMethod'); -var _curry2 = require('./internal/_curry2'); +import _checkForMethod from './internal/_checkForMethod'; +import _curry2 from './internal/_curry2'; /** @@ -36,7 +36,7 @@ var _curry2 = require('./internal/_curry2'); * // logs 8 * @symb R.forEach(f, [a, b, c]) = [a, b, c] */ -module.exports = _curry2(_checkForMethod('forEach', function forEach(fn, list) { +var forEach = _curry2(_checkForMethod('forEach', function forEach(fn, list) { var len = list.length; var idx = 0; while (idx < len) { @@ -45,3 +45,4 @@ module.exports = _curry2(_checkForMethod('forEach', function forEach(fn, list) { } return list; })); +export default forEach; diff --git a/src/forEachObjIndexed.js b/source/forEachObjIndexed.js similarity index 84% rename from src/forEachObjIndexed.js rename to source/forEachObjIndexed.js index fa67250c6..711f4a826 100644 --- a/src/forEachObjIndexed.js +++ b/source/forEachObjIndexed.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var keys = require('./keys'); +import _curry2 from './internal/_curry2'; +import keys from './keys'; /** @@ -24,7 +24,7 @@ var keys = require('./keys'); * // logs y:2 * @symb R.forEachObjIndexed(f, {x: a, y: b}) = {x: a, y: b} */ -module.exports = _curry2(function forEachObjIndexed(fn, obj) { +var forEachObjIndexed = _curry2(function forEachObjIndexed(fn, obj) { var keyList = keys(obj); var idx = 0; while (idx < keyList.length) { @@ -34,3 +34,4 @@ module.exports = _curry2(function forEachObjIndexed(fn, obj) { } return obj; }); +export default forEachObjIndexed; diff --git a/src/fromPairs.js b/source/fromPairs.js similarity index 85% rename from src/fromPairs.js rename to source/fromPairs.js index 5e24e97fd..03a6fb9c4 100644 --- a/src/fromPairs.js +++ b/source/fromPairs.js @@ -1,4 +1,4 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; /** @@ -17,7 +17,7 @@ var _curry1 = require('./internal/_curry1'); * * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3} */ -module.exports = _curry1(function fromPairs(pairs) { +var fromPairs = _curry1(function fromPairs(pairs) { var result = {}; var idx = 0; while (idx < pairs.length) { @@ -26,3 +26,4 @@ module.exports = _curry1(function fromPairs(pairs) { } return result; }); +export default fromPairs; diff --git a/src/groupBy.js b/source/groupBy.js similarity index 85% rename from src/groupBy.js rename to source/groupBy.js index cfdabdcfd..c5d35a80d 100644 --- a/src/groupBy.js +++ b/source/groupBy.js @@ -1,6 +1,6 @@ -var _checkForMethod = require('./internal/_checkForMethod'); -var _curry2 = require('./internal/_curry2'); -var reduceBy = require('./reduceBy'); +import _checkForMethod from './internal/_checkForMethod'; +import _curry2 from './internal/_curry2'; +import reduceBy from './reduceBy'; /** * Splits a list into sub-lists stored in an object, based on the result of @@ -42,10 +42,11 @@ var reduceBy = require('./reduceBy'); * // 'F': [{name: 'Eddy', score: 58}] * // } */ -module.exports = _curry2(_checkForMethod('groupBy', reduceBy(function(acc, item) { +var groupBy = _curry2(_checkForMethod('groupBy', reduceBy(function(acc, item) { if (acc == null) { acc = []; } acc.push(item); return acc; }, null))); +export default groupBy; diff --git a/src/groupWith.js b/source/groupWith.js similarity index 92% rename from src/groupWith.js rename to source/groupWith.js index 5b1b728e3..b210a8b4e 100644 --- a/src/groupWith.js +++ b/source/groupWith.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** * Takes a list and returns a list of lists where each sublist's elements are @@ -30,7 +30,7 @@ var _curry2 = require('./internal/_curry2'); * R.groupWith(R.eqBy(isVowel), 'aestiou') * //=> ['ae', 'st', 'iou'] */ -module.exports = _curry2(function(fn, list) { +var groupWith = _curry2(function(fn, list) { var res = []; var idx = 0; var len = list.length; @@ -44,3 +44,4 @@ module.exports = _curry2(function(fn, list) { } return res; }); +export default groupWith; diff --git a/src/gt.js b/source/gt.js similarity index 79% rename from src/gt.js rename to source/gt.js index 70c647adc..dc6d5a2ba 100644 --- a/src/gt.js +++ b/source/gt.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -22,4 +22,5 @@ var _curry2 = require('./internal/_curry2'); * R.gt('a', 'z'); //=> false * R.gt('z', 'a'); //=> true */ -module.exports = _curry2(function gt(a, b) { return a > b; }); +var gt = _curry2(function gt(a, b) { return a > b; }); +export default gt; diff --git a/src/gte.js b/source/gte.js similarity index 79% rename from src/gte.js rename to source/gte.js index d4a5d2d91..6e4c65221 100644 --- a/src/gte.js +++ b/source/gte.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -22,4 +22,5 @@ var _curry2 = require('./internal/_curry2'); * R.gte('a', 'z'); //=> false * R.gte('z', 'a'); //=> true */ -module.exports = _curry2(function gte(a, b) { return a >= b; }); +var gte = _curry2(function gte(a, b) { return a >= b; }); +export default gte; diff --git a/src/has.js b/source/has.js similarity index 85% rename from src/has.js rename to source/has.js index fdbdd701b..3fe8c6893 100644 --- a/src/has.js +++ b/source/has.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var _has = require('./internal/_has'); +import _curry2 from './internal/_curry2'; +import _has from './internal/_has'; /** @@ -26,4 +26,5 @@ var _has = require('./internal/_has'); * pointHas('y'); //=> true * pointHas('z'); //=> false */ -module.exports = _curry2(_has); +var has = _curry2(_has); +export default has; diff --git a/src/hasIn.js b/source/hasIn.js similarity index 87% rename from src/hasIn.js rename to source/hasIn.js index e6a54cc60..b8bd31a9f 100644 --- a/src/hasIn.js +++ b/source/hasIn.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -27,6 +27,7 @@ var _curry2 = require('./internal/_curry2'); * R.hasIn('width', square); //=> true * R.hasIn('area', square); //=> true */ -module.exports = _curry2(function hasIn(prop, obj) { +var hasIn = _curry2(function hasIn(prop, obj) { return prop in obj; }); +export default hasIn; diff --git a/src/head.js b/source/head.js similarity index 87% rename from src/head.js rename to source/head.js index 4be7bea92..bb96a91ab 100644 --- a/src/head.js +++ b/source/head.js @@ -1,4 +1,4 @@ -var nth = require('./nth'); +import nth from './nth'; /** @@ -22,4 +22,5 @@ var nth = require('./nth'); * R.head('abc'); //=> 'a' * R.head(''); //=> '' */ -module.exports = nth(0); +var head = nth(0); +export default head; diff --git a/src/identical.js b/source/identical.js similarity index 87% rename from src/identical.js rename to source/identical.js index 9284857f8..0e962f85c 100644 --- a/src/identical.js +++ b/source/identical.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -24,7 +24,7 @@ var _curry2 = require('./internal/_curry2'); * R.identical(0, -0); //=> false * R.identical(NaN, NaN); //=> true */ -module.exports = _curry2(function identical(a, b) { +var identical = _curry2(function identical(a, b) { // SameValue algorithm if (a === b) { // Steps 1-5, 7-10 // Steps 6.b-6.e: +0 != -0 @@ -34,3 +34,4 @@ module.exports = _curry2(function identical(a, b) { return a !== a && b !== b; } }); +export default identical; diff --git a/src/identity.js b/source/identity.js similarity index 74% rename from src/identity.js rename to source/identity.js index 75f0f95b7..d004b7ffd 100644 --- a/src/identity.js +++ b/source/identity.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var _identity = require('./internal/_identity'); +import _curry1 from './internal/_curry1'; +import _identity from './internal/_identity'; /** @@ -21,4 +21,5 @@ var _identity = require('./internal/_identity'); * R.identity(obj) === obj; //=> true * @symb R.identity(a) = a */ -module.exports = _curry1(_identity); +var identity = _curry1(_identity); +export default identity; diff --git a/src/ifElse.js b/source/ifElse.js similarity index 88% rename from src/ifElse.js rename to source/ifElse.js index e0e4a1d77..f16bcded3 100644 --- a/src/ifElse.js +++ b/source/ifElse.js @@ -1,5 +1,5 @@ -var _curry3 = require('./internal/_curry3'); -var curryN = require('./curryN'); +import _curry3 from './internal/_curry3'; +import curryN from './curryN'; /** @@ -27,10 +27,11 @@ var curryN = require('./curryN'); * incCount({}); //=> { count: 1 } * incCount({ count: 1 }); //=> { count: 2 } */ -module.exports = _curry3(function ifElse(condition, onTrue, onFalse) { +var ifElse = _curry3(function ifElse(condition, onTrue, onFalse) { return curryN(Math.max(condition.length, onTrue.length, onFalse.length), function _ifElse() { return condition.apply(this, arguments) ? onTrue.apply(this, arguments) : onFalse.apply(this, arguments); } ); }); +export default ifElse; diff --git a/src/inc.js b/source/inc.js similarity index 78% rename from src/inc.js rename to source/inc.js index 1f7a091ee..91b239188 100644 --- a/src/inc.js +++ b/source/inc.js @@ -1,4 +1,4 @@ -var add = require('./add'); +import add from './add'; /** @@ -16,4 +16,5 @@ var add = require('./add'); * * R.inc(42); //=> 43 */ -module.exports = add(1); +var inc = add(1); +export default inc; diff --git a/source/index.js b/source/index.js new file mode 100644 index 000000000..3d706f7ef --- /dev/null +++ b/source/index.js @@ -0,0 +1,246 @@ +export { default as F } from './F'; +export { default as T } from './T'; +export { default as __ } from './__'; +export { default as add } from './add'; +export { default as addIndex } from './addIndex'; +export { default as adjust } from './adjust'; +export { default as all } from './all'; +export { default as allPass } from './allPass'; +export { default as always } from './always'; +export { default as and } from './and'; +export { default as any } from './any'; +export { default as anyPass } from './anyPass'; +export { default as ap } from './ap'; +export { default as aperture } from './aperture'; +export { default as append } from './append'; +export { default as apply } from './apply'; +export { default as applySpec } from './applySpec'; +export { default as ascend } from './ascend'; +export { default as assoc } from './assoc'; +export { default as assocPath } from './assocPath'; +export { default as binary } from './binary'; +export { default as bind } from './bind'; +export { default as both } from './both'; +export { default as call } from './call'; +export { default as chain } from './chain'; +export { default as clamp } from './clamp'; +export { default as clone } from './clone'; +export { default as comparator } from './comparator'; +export { default as complement } from './complement'; +export { default as compose } from './compose'; +export { default as composeK } from './composeK'; +export { default as composeP } from './composeP'; +export { default as concat } from './concat'; +export { default as cond } from './cond'; +export { default as construct } from './construct'; +export { default as constructN } from './constructN'; +export { default as contains } from './contains'; +export { default as converge } from './converge'; +export { default as countBy } from './countBy'; +export { default as curry } from './curry'; +export { default as curryN } from './curryN'; +export { default as dec } from './dec'; +export { default as defaultTo } from './defaultTo'; +export { default as descend } from './descend'; +export { default as difference } from './difference'; +export { default as differenceWith } from './differenceWith'; +export { default as dissoc } from './dissoc'; +export { default as dissocPath } from './dissocPath'; +export { default as divide } from './divide'; +export { default as drop } from './drop'; +export { default as dropLast } from './dropLast'; +export { default as dropLastWhile } from './dropLastWhile'; +export { default as dropRepeats } from './dropRepeats'; +export { default as dropRepeatsWith } from './dropRepeatsWith'; +export { default as dropWhile } from './dropWhile'; +export { default as either } from './either'; +export { default as empty } from './empty'; +export { default as endsWith } from './endsWith'; +export { default as eqBy } from './eqBy'; +export { default as eqProps } from './eqProps'; +export { default as equals } from './equals'; +export { default as evolve } from './evolve'; +export { default as filter } from './filter'; +export { default as find } from './find'; +export { default as findIndex } from './findIndex'; +export { default as findLast } from './findLast'; +export { default as findLastIndex } from './findLastIndex'; +export { default as flatten } from './flatten'; +export { default as flip } from './flip'; +export { default as forEach } from './forEach'; +export { default as forEachObjIndexed } from './forEachObjIndexed'; +export { default as fromPairs } from './fromPairs'; +export { default as groupBy } from './groupBy'; +export { default as groupWith } from './groupWith'; +export { default as gt } from './gt'; +export { default as gte } from './gte'; +export { default as has } from './has'; +export { default as hasIn } from './hasIn'; +export { default as head } from './head'; +export { default as identical } from './identical'; +export { default as identity } from './identity'; +export { default as ifElse } from './ifElse'; +export { default as inc } from './inc'; +export { default as indexBy } from './indexBy'; +export { default as indexOf } from './indexOf'; +export { default as init } from './init'; +export { default as innerJoin } from './innerJoin'; +export { default as insert } from './insert'; +export { default as insertAll } from './insertAll'; +export { default as intersection } from './intersection'; +export { default as intersectionWith } from './intersectionWith'; +export { default as intersperse } from './intersperse'; +export { default as into } from './into'; +export { default as invert } from './invert'; +export { default as invertObj } from './invertObj'; +export { default as invoker } from './invoker'; +export { default as is } from './is'; +export { default as isEmpty } from './isEmpty'; +export { default as isNil } from './isNil'; +export { default as join } from './join'; +export { default as juxt } from './juxt'; +export { default as keys } from './keys'; +export { default as keysIn } from './keysIn'; +export { default as last } from './last'; +export { default as lastIndexOf } from './lastIndexOf'; +export { default as length } from './length'; +export { default as lens } from './lens'; +export { default as lensIndex } from './lensIndex'; +export { default as lensPath } from './lensPath'; +export { default as lensProp } from './lensProp'; +export { default as lift } from './lift'; +export { default as liftN } from './liftN'; +export { default as lt } from './lt'; +export { default as lte } from './lte'; +export { default as map } from './map'; +export { default as mapAccum } from './mapAccum'; +export { default as mapAccumRight } from './mapAccumRight'; +export { default as mapObjIndexed } from './mapObjIndexed'; +export { default as match } from './match'; +export { default as mathMod } from './mathMod'; +export { default as max } from './max'; +export { default as maxBy } from './maxBy'; +export { default as mean } from './mean'; +export { default as median } from './median'; +export { default as memoize } from './memoize'; +export { default as memoizeWith } from './memoizeWith'; +export { default as merge } from './merge'; +export { default as mergeAll } from './mergeAll'; +export { default as mergeDeepLeft } from './mergeDeepLeft'; +export { default as mergeDeepRight } from './mergeDeepRight'; +export { default as mergeDeepWith } from './mergeDeepWith'; +export { default as mergeDeepWithKey } from './mergeDeepWithKey'; +export { default as mergeWith } from './mergeWith'; +export { default as mergeWithKey } from './mergeWithKey'; +export { default as min } from './min'; +export { default as minBy } from './minBy'; +export { default as modulo } from './modulo'; +export { default as multiply } from './multiply'; +export { default as nAry } from './nAry'; +export { default as negate } from './negate'; +export { default as none } from './none'; +export { default as not } from './not'; +export { default as nth } from './nth'; +export { default as nthArg } from './nthArg'; +export { default as o } from './o'; +export { default as objOf } from './objOf'; +export { default as of } from './of'; +export { default as omit } from './omit'; +export { default as once } from './once'; +export { default as or } from './or'; +export { default as over } from './over'; +export { default as pair } from './pair'; +export { default as partial } from './partial'; +export { default as partialRight } from './partialRight'; +export { default as partition } from './partition'; +export { default as path } from './path'; +export { default as pathEq } from './pathEq'; +export { default as pathOr } from './pathOr'; +export { default as pathSatisfies } from './pathSatisfies'; +export { default as pick } from './pick'; +export { default as pickAll } from './pickAll'; +export { default as pickBy } from './pickBy'; +export { default as pipe } from './pipe'; +export { default as pipeK } from './pipeK'; +export { default as pipeP } from './pipeP'; +export { default as pluck } from './pluck'; +export { default as prepend } from './prepend'; +export { default as product } from './product'; +export { default as project } from './project'; +export { default as prop } from './prop'; +export { default as propEq } from './propEq'; +export { default as propIs } from './propIs'; +export { default as propOr } from './propOr'; +export { default as propSatisfies } from './propSatisfies'; +export { default as props } from './props'; +export { default as range } from './range'; +export { default as reduce } from './reduce'; +export { default as reduceBy } from './reduceBy'; +export { default as reduceRight } from './reduceRight'; +export { default as reduceWhile } from './reduceWhile'; +export { default as reduced } from './reduced'; +export { default as reject } from './reject'; +export { default as remove } from './remove'; +export { default as repeat } from './repeat'; +export { default as replace } from './replace'; +export { default as reverse } from './reverse'; +export { default as scan } from './scan'; +export { default as sequence } from './sequence'; +export { default as set } from './set'; +export { default as slice } from './slice'; +export { default as sort } from './sort'; +export { default as sortBy } from './sortBy'; +export { default as sortWith } from './sortWith'; +export { default as split } from './split'; +export { default as splitAt } from './splitAt'; +export { default as splitEvery } from './splitEvery'; +export { default as splitWhen } from './splitWhen'; +export { default as startsWith } from './startsWith'; +export { default as subtract } from './subtract'; +export { default as sum } from './sum'; +export { default as symmetricDifference } from './symmetricDifference'; +export { default as symmetricDifferenceWith } from './symmetricDifferenceWith'; +export { default as tail } from './tail'; +export { default as take } from './take'; +export { default as takeLast } from './takeLast'; +export { default as takeLastWhile } from './takeLastWhile'; +export { default as takeWhile } from './takeWhile'; +export { default as tap } from './tap'; +export { default as test } from './test'; +export { default as times } from './times'; +export { default as toLower } from './toLower'; +export { default as toPairs } from './toPairs'; +export { default as toPairsIn } from './toPairsIn'; +export { default as toString } from './toString'; +export { default as toUpper } from './toUpper'; +export { default as transduce } from './transduce'; +export { default as transpose } from './transpose'; +export { default as traverse } from './traverse'; +export { default as trim } from './trim'; +export { default as tryCatch } from './tryCatch'; +export { default as type } from './type'; +export { default as unapply } from './unapply'; +export { default as unary } from './unary'; +export { default as uncurryN } from './uncurryN'; +export { default as unfold } from './unfold'; +export { default as union } from './union'; +export { default as unionWith } from './unionWith'; +export { default as uniq } from './uniq'; +export { default as uniqBy } from './uniqBy'; +export { default as uniqWith } from './uniqWith'; +export { default as unless } from './unless'; +export { default as unnest } from './unnest'; +export { default as until } from './until'; +export { default as update } from './update'; +export { default as useWith } from './useWith'; +export { default as values } from './values'; +export { default as valuesIn } from './valuesIn'; +export { default as view } from './view'; +export { default as when } from './when'; +export { default as where } from './where'; +export { default as whereEq } from './whereEq'; +export { default as without } from './without'; +export { default as xprod } from './xprod'; +export { default as zip } from './zip'; +export { default as zipObj } from './zipObj'; +export { default as zipWith } from './zipWith'; diff --git a/src/indexBy.js b/source/indexBy.js similarity index 86% rename from src/indexBy.js rename to source/indexBy.js index a888ac600..e96275f13 100644 --- a/src/indexBy.js +++ b/source/indexBy.js @@ -1,4 +1,4 @@ -var reduceBy = require('./reduceBy'); +import reduceBy from './reduceBy'; /** @@ -23,4 +23,5 @@ var reduceBy = require('./reduceBy'); * R.indexBy(R.prop('id'), list); * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}} */ -module.exports = reduceBy(function(acc, elem) { return elem; }, null); +var indexBy = reduceBy(function(acc, elem) { return elem; }, null); +export default indexBy; diff --git a/src/indexOf.js b/source/indexOf.js similarity index 76% rename from src/indexOf.js rename to source/indexOf.js index 7257f253d..238ac42ce 100644 --- a/src/indexOf.js +++ b/source/indexOf.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var _indexOf = require('./internal/_indexOf'); -var _isArray = require('./internal/_isArray'); +import _curry2 from './internal/_curry2'; +import _indexOf from './internal/_indexOf'; +import _isArray from './internal/_isArray'; /** @@ -22,8 +22,9 @@ var _isArray = require('./internal/_isArray'); * R.indexOf(3, [1,2,3,4]); //=> 2 * R.indexOf(10, [1,2,3,4]); //=> -1 */ -module.exports = _curry2(function indexOf(target, xs) { +var indexOf = _curry2(function indexOf(target, xs) { return typeof xs.indexOf === 'function' && !_isArray(xs) ? xs.indexOf(target) : _indexOf(xs, target, 0); }); +export default indexOf; diff --git a/src/init.js b/source/init.js similarity index 87% rename from src/init.js rename to source/init.js index f2fd5c81b..509969878 100644 --- a/src/init.js +++ b/source/init.js @@ -1,4 +1,4 @@ -var slice = require('./slice'); +import slice from './slice'; /** @@ -25,4 +25,5 @@ var slice = require('./slice'); * R.init('a'); //=> '' * R.init(''); //=> '' */ -module.exports = slice(0, -1); +var init = slice(0, -1); +export default init; diff --git a/src/innerJoin.js b/source/innerJoin.js similarity index 85% rename from src/innerJoin.js rename to source/innerJoin.js index 226842f09..a1ad40fb2 100644 --- a/src/innerJoin.js +++ b/source/innerJoin.js @@ -1,6 +1,6 @@ -var _containsWith = require('./internal/_containsWith'); -var _curry3 = require('./internal/_curry3'); -var _filter = require('./internal/_filter'); +import _containsWith from './internal/_containsWith'; +import _curry3 from './internal/_curry3'; +import _filter from './internal/_filter'; /** @@ -38,6 +38,7 @@ var _filter = require('./internal/_filter'); * ); * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}] */ -module.exports = _curry3(function innerJoin(pred, xs, ys) { +var innerJoin = _curry3(function innerJoin(pred, xs, ys) { return _filter(function(x) { return _containsWith(pred, x, ys); }, xs); }); +export default innerJoin; diff --git a/src/insert.js b/source/insert.js similarity index 87% rename from src/insert.js rename to source/insert.js index 70d8c440e..c74e5b4b6 100644 --- a/src/insert.js +++ b/source/insert.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -20,9 +20,10 @@ var _curry3 = require('./internal/_curry3'); * * R.insert(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4] */ -module.exports = _curry3(function insert(idx, elt, list) { +var insert = _curry3(function insert(idx, elt, list) { idx = idx < list.length && idx >= 0 ? idx : list.length; var result = Array.prototype.slice.call(list, 0); result.splice(idx, 0, elt); return result; }); +export default insert; diff --git a/src/insertAll.js b/source/insertAll.js similarity index 87% rename from src/insertAll.js rename to source/insertAll.js index 10db9ead1..a93d1f1af 100644 --- a/src/insertAll.js +++ b/source/insertAll.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -19,9 +19,10 @@ var _curry3 = require('./internal/_curry3'); * * R.insertAll(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4] */ -module.exports = _curry3(function insertAll(idx, elts, list) { +var insertAll = _curry3(function insertAll(idx, elts, list) { idx = idx < list.length && idx >= 0 ? idx : list.length; return [].concat(Array.prototype.slice.call(list, 0, idx), elts, Array.prototype.slice.call(list, idx)); }); +export default insertAll; diff --git a/source/internal/_Set.js b/source/internal/_Set.js new file mode 100644 index 000000000..65de12260 --- /dev/null +++ b/source/internal/_Set.js @@ -0,0 +1,170 @@ +import _contains from './_contains'; + + +function _Set() { + /* globals Set */ + this._nativeSet = typeof Set === 'function' ? new Set() : null; + this._items = {}; +} + +// until we figure out why jsdoc chokes on this +// @param item The item to add to the Set +// @returns {boolean} true if the item did not exist prior, otherwise false +// +_Set.prototype.add = function(item) { + return !hasOrAdd(item, true, this); +}; + +// +// @param item The item to check for existence in the Set +// @returns {boolean} true if the item exists in the Set, otherwise false +// +_Set.prototype.has = function(item) { + return hasOrAdd(item, false, this); +}; + +// +// Combines the logic for checking whether an item is a member of the set and +// for adding a new item to the set. +// +// @param item The item to check or add to the Set instance. +// @param shouldAdd If true, the item will be added to the set if it doesn't +// already exist. +// @param set The set instance to check or add to. +// @return {boolean} true if the item already existed, otherwise false. +// +function hasOrAdd(item, shouldAdd, set) { + var type = typeof item; + var prevSize, newSize; + switch (type) { + case 'string': + case 'number': + // distinguish between +0 and -0 + if (item === 0 && 1 / item === -Infinity) { + if (set._items['-0']) { + return true; + } else { + if (shouldAdd) { + set._items['-0'] = true; + } + return false; + } + } + // these types can all utilise the native Set + if (set._nativeSet !== null) { + if (shouldAdd) { + prevSize = set._nativeSet.size; + set._nativeSet.add(item); + newSize = set._nativeSet.size; + return newSize === prevSize; + } else { + return set._nativeSet.has(item); + } + } else { + if (!(type in set._items)) { + if (shouldAdd) { + set._items[type] = {}; + set._items[type][item] = true; + } + return false; + } else if (item in set._items[type]) { + return true; + } else { + if (shouldAdd) { + set._items[type][item] = true; + } + return false; + } + } + + case 'boolean': + // set._items['boolean'] holds a two element array + // representing [ falseExists, trueExists ] + if (type in set._items) { + var bIdx = item ? 1 : 0; + if (set._items[type][bIdx]) { + return true; + } else { + if (shouldAdd) { + set._items[type][bIdx] = true; + } + return false; + } + } else { + if (shouldAdd) { + set._items[type] = item ? [false, true] : [true, false]; + } + return false; + } + + case 'function': + // compare functions for reference equality + if (set._nativeSet !== null) { + if (shouldAdd) { + prevSize = set._nativeSet.size; + set._nativeSet.add(item); + newSize = set._nativeSet.size; + return newSize === prevSize; + } else { + return set._nativeSet.has(item); + } + } else { + if (!(type in set._items)) { + if (shouldAdd) { + set._items[type] = [item]; + } + return false; + } + if (!_contains(item, set._items[type])) { + if (shouldAdd) { + set._items[type].push(item); + } + return false; + } + return true; + } + + case 'undefined': + if (set._items[type]) { + return true; + } else { + if (shouldAdd) { + set._items[type] = true; + } + return false; + } + + case 'object': + if (item === null) { + if (!set._items['null']) { + if (shouldAdd) { + set._items['null'] = true; + } + return false; + } + return true; + } + /* falls through */ + default: + // reduce the search size of heterogeneous sets by creating buckets + // for each type. + type = Object.prototype.toString.call(item); + if (!(type in set._items)) { + if (shouldAdd) { + set._items[type] = [item]; + } + return false; + } + // scan through all previously applied items + if (!_contains(item, set._items[type])) { + if (shouldAdd) { + set._items[type].push(item); + } + return false; + } + return true; + } +} + +// A simple Set type that honours R.equals semantics +export default _Set; diff --git a/src/internal/_aperture.js b/source/internal/_aperture.js similarity index 81% rename from src/internal/_aperture.js rename to source/internal/_aperture.js index d932c82d2..97a4ae045 100644 --- a/src/internal/_aperture.js +++ b/source/internal/_aperture.js @@ -1,4 +1,4 @@ -module.exports = function _aperture(n, list) { +export default function _aperture(n, list) { var idx = 0; var limit = list.length - (n - 1); var acc = new Array(limit >= 0 ? limit : 0); @@ -7,4 +7,4 @@ module.exports = function _aperture(n, list) { idx += 1; } return acc; -}; +} diff --git a/src/internal/_arity.js b/source/internal/_arity.js similarity index 96% rename from src/internal/_arity.js rename to source/internal/_arity.js index ca6457411..b3695d7e2 100644 --- a/src/internal/_arity.js +++ b/source/internal/_arity.js @@ -1,4 +1,4 @@ -module.exports = function _arity(n, fn) { +export default function _arity(n, fn) { /* eslint-disable no-unused-vars */ switch (n) { case 0: return function() { return fn.apply(this, arguments); }; @@ -14,4 +14,4 @@ module.exports = function _arity(n, fn) { case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { return fn.apply(this, arguments); }; default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten'); } -}; +} diff --git a/src/internal/_arrayFromIterator.js b/source/internal/_arrayFromIterator.js similarity index 67% rename from src/internal/_arrayFromIterator.js rename to source/internal/_arrayFromIterator.js index bc4ee0bed..67d2d38b8 100644 --- a/src/internal/_arrayFromIterator.js +++ b/source/internal/_arrayFromIterator.js @@ -1,8 +1,8 @@ -module.exports = function _arrayFromIterator(iter) { +export default function _arrayFromIterator(iter) { var list = []; var next; while (!(next = iter.next()).done) { list.push(next.value); } return list; -}; +} diff --git a/src/internal/_assign.js b/source/internal/_assign.js similarity index 52% rename from src/internal/_assign.js rename to source/internal/_assign.js index bbbe2d785..954717684 100644 --- a/src/internal/_assign.js +++ b/source/internal/_assign.js @@ -1,4 +1,4 @@ -var _objectAssign = require('./_objectAssign'); +import _objectAssign from './_objectAssign'; -module.exports = +export default typeof Object.assign === 'function' ? Object.assign : _objectAssign; diff --git a/src/internal/_checkForMethod.js b/source/internal/_checkForMethod.js similarity index 87% rename from src/internal/_checkForMethod.js rename to source/internal/_checkForMethod.js index 9a27e817f..7eb9ef6d9 100644 --- a/src/internal/_checkForMethod.js +++ b/source/internal/_checkForMethod.js @@ -1,4 +1,4 @@ -var _isArray = require('./_isArray'); +import _isArray from './_isArray'; /** @@ -11,7 +11,7 @@ var _isArray = require('./_isArray'); * @param {String} methodname property to check for a custom implementation * @return {Object} Whatever the return value of the method is. */ -module.exports = function _checkForMethod(methodname, fn) { +export default function _checkForMethod(methodname, fn) { return function() { var length = arguments.length; if (length === 0) { @@ -22,4 +22,4 @@ module.exports = function _checkForMethod(methodname, fn) { fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1)); }; -}; +} diff --git a/src/internal/_clone.js b/source/internal/_clone.js similarity index 87% rename from src/internal/_clone.js rename to source/internal/_clone.js index 28c0ebd21..984174e9b 100644 --- a/src/internal/_clone.js +++ b/source/internal/_clone.js @@ -1,5 +1,5 @@ -var _cloneRegExp = require('./_cloneRegExp'); -var type = require('../type'); +import _cloneRegExp from './_cloneRegExp'; +import type from '../type'; /** @@ -12,7 +12,7 @@ var type = require('../type'); * @param {Boolean} deep Whether or not to perform deep cloning. * @return {*} The copied value. */ -module.exports = function _clone(value, refFrom, refTo, deep) { +export default function _clone(value, refFrom, refTo, deep) { var copy = function copy(copiedValue) { var len = refFrom.length; var idx = 0; @@ -37,4 +37,4 @@ module.exports = function _clone(value, refFrom, refTo, deep) { case 'RegExp': return _cloneRegExp(value); default: return value; } -}; +} diff --git a/src/internal/_cloneRegExp.js b/source/internal/_cloneRegExp.js similarity index 86% rename from src/internal/_cloneRegExp.js rename to source/internal/_cloneRegExp.js index f65403523..581890d8b 100644 --- a/src/internal/_cloneRegExp.js +++ b/source/internal/_cloneRegExp.js @@ -1,7 +1,7 @@ -module.exports = function _cloneRegExp(pattern) { +export default function _cloneRegExp(pattern) { return new RegExp(pattern.source, (pattern.global ? 'g' : '') + (pattern.ignoreCase ? 'i' : '') + (pattern.multiline ? 'm' : '') + (pattern.sticky ? 'y' : '') + (pattern.unicode ? 'u' : '')); -}; +} diff --git a/src/internal/_complement.js b/source/internal/_complement.js similarity index 58% rename from src/internal/_complement.js rename to source/internal/_complement.js index 25cdde4ad..38fa1cf0d 100644 --- a/src/internal/_complement.js +++ b/source/internal/_complement.js @@ -1,5 +1,5 @@ -module.exports = function _complement(f) { +export default function _complement(f) { return function() { return !f.apply(this, arguments); }; -}; +} diff --git a/src/internal/_concat.js b/source/internal/_concat.js similarity index 92% rename from src/internal/_concat.js rename to source/internal/_concat.js index 3c0511d05..db1882c3e 100644 --- a/src/internal/_concat.js +++ b/source/internal/_concat.js @@ -9,7 +9,7 @@ * * _concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] */ -module.exports = function _concat(set1, set2) { +export default function _concat(set1, set2) { set1 = set1 || []; set2 = set2 || []; var idx; @@ -28,4 +28,4 @@ module.exports = function _concat(set1, set2) { idx += 1; } return result; -}; +} diff --git a/source/internal/_contains.js b/source/internal/_contains.js new file mode 100644 index 000000000..43d524d8f --- /dev/null +++ b/source/internal/_contains.js @@ -0,0 +1,6 @@ +import _indexOf from './_indexOf'; + + +export default function _contains(a, list) { + return _indexOf(list, a, 0) >= 0; +} diff --git a/src/internal/_containsWith.js b/source/internal/_containsWith.js similarity index 71% rename from src/internal/_containsWith.js rename to source/internal/_containsWith.js index 3d218308a..42c8ec183 100644 --- a/src/internal/_containsWith.js +++ b/source/internal/_containsWith.js @@ -1,4 +1,4 @@ -module.exports = function _containsWith(pred, x, list) { +export default function _containsWith(pred, x, list) { var idx = 0; var len = list.length; @@ -9,4 +9,4 @@ module.exports = function _containsWith(pred, x, list) { idx += 1; } return false; -}; +} diff --git a/src/internal/_createPartialApplicator.js b/source/internal/_createPartialApplicator.js similarity index 56% rename from src/internal/_createPartialApplicator.js rename to source/internal/_createPartialApplicator.js index 60af5c4fe..a0541dce4 100644 --- a/src/internal/_createPartialApplicator.js +++ b/source/internal/_createPartialApplicator.js @@ -1,11 +1,11 @@ -var _arity = require('./_arity'); -var _curry2 = require('./_curry2'); +import _arity from './_arity'; +import _curry2 from './_curry2'; -module.exports = function _createPartialApplicator(concat) { +export default function _createPartialApplicator(concat) { return _curry2(function(fn, args) { return _arity(Math.max(0, fn.length - args.length), function() { return fn.apply(this, concat(args, arguments)); }); }); -}; +} diff --git a/src/internal/_curry1.js b/source/internal/_curry1.js similarity index 78% rename from src/internal/_curry1.js rename to source/internal/_curry1.js index a3bb2a911..e24648863 100644 --- a/src/internal/_curry1.js +++ b/source/internal/_curry1.js @@ -1,4 +1,4 @@ -var _isPlaceholder = require('./_isPlaceholder'); +import _isPlaceholder from './_isPlaceholder'; /** @@ -9,7 +9,7 @@ var _isPlaceholder = require('./_isPlaceholder'); * @param {Function} fn The function to curry. * @return {Function} The curried function. */ -module.exports = function _curry1(fn) { +export default function _curry1(fn) { return function f1(a) { if (arguments.length === 0 || _isPlaceholder(a)) { return f1; @@ -17,4 +17,4 @@ module.exports = function _curry1(fn) { return fn.apply(this, arguments); } }; -}; +} diff --git a/src/internal/_curry2.js b/source/internal/_curry2.js similarity index 83% rename from src/internal/_curry2.js rename to source/internal/_curry2.js index a884098f0..ee315eda9 100644 --- a/src/internal/_curry2.js +++ b/source/internal/_curry2.js @@ -1,5 +1,5 @@ -var _curry1 = require('./_curry1'); -var _isPlaceholder = require('./_isPlaceholder'); +import _curry1 from './_curry1'; +import _isPlaceholder from './_isPlaceholder'; /** @@ -10,7 +10,7 @@ var _isPlaceholder = require('./_isPlaceholder'); * @param {Function} fn The function to curry. * @return {Function} The curried function. */ -module.exports = function _curry2(fn) { +export default function _curry2(fn) { return function f2(a, b) { switch (arguments.length) { case 0: @@ -25,4 +25,4 @@ module.exports = function _curry2(fn) { : fn(a, b); } }; -}; +} diff --git a/src/internal/_curry3.js b/source/internal/_curry3.js similarity index 89% rename from src/internal/_curry3.js rename to source/internal/_curry3.js index e5994bd26..6630e3024 100644 --- a/src/internal/_curry3.js +++ b/source/internal/_curry3.js @@ -1,6 +1,6 @@ -var _curry1 = require('./_curry1'); -var _curry2 = require('./_curry2'); -var _isPlaceholder = require('./_isPlaceholder'); +import _curry1 from './_curry1'; +import _curry2 from './_curry2'; +import _isPlaceholder from './_isPlaceholder'; /** @@ -11,7 +11,7 @@ var _isPlaceholder = require('./_isPlaceholder'); * @param {Function} fn The function to curry. * @return {Function} The curried function. */ -module.exports = function _curry3(fn) { +export default function _curry3(fn) { return function f3(a, b, c) { switch (arguments.length) { case 0: @@ -35,4 +35,4 @@ module.exports = function _curry3(fn) { : fn(a, b, c); } }; -}; +} diff --git a/src/internal/_curryN.js b/source/internal/_curryN.js similarity index 87% rename from src/internal/_curryN.js rename to source/internal/_curryN.js index 80966eba6..1057663bc 100644 --- a/src/internal/_curryN.js +++ b/source/internal/_curryN.js @@ -1,5 +1,5 @@ -var _arity = require('./_arity'); -var _isPlaceholder = require('./_isPlaceholder'); +import _arity from './_arity'; +import _isPlaceholder from './_isPlaceholder'; /** @@ -12,7 +12,7 @@ var _isPlaceholder = require('./_isPlaceholder'); * @param {Function} fn The function to curry. * @return {Function} The curried function. */ -module.exports = function _curryN(length, received, fn) { +export default function _curryN(length, received, fn) { return function() { var combined = []; var argsIdx = 0; @@ -37,4 +37,4 @@ module.exports = function _curryN(length, received, fn) { return left <= 0 ? fn.apply(this, combined) : _arity(left, _curryN(length, combined, fn)); }; -}; +} diff --git a/src/internal/_dispatchable.js b/source/internal/_dispatchable.js similarity index 89% rename from src/internal/_dispatchable.js rename to source/internal/_dispatchable.js index c65e1c87c..2cf1728a5 100644 --- a/src/internal/_dispatchable.js +++ b/source/internal/_dispatchable.js @@ -1,5 +1,5 @@ -var _isArray = require('./_isArray'); -var _isTransformer = require('./_isTransformer'); +import _isArray from './_isArray'; +import _isTransformer from './_isTransformer'; /** @@ -16,7 +16,7 @@ var _isTransformer = require('./_isTransformer'); * @param {Function} fn default ramda implementation * @return {Function} A function that dispatches on object in list position */ -module.exports = function _dispatchable(methodNames, xf, fn) { +export default function _dispatchable(methodNames, xf, fn) { return function() { if (arguments.length === 0) { return fn(); @@ -38,4 +38,4 @@ module.exports = function _dispatchable(methodNames, xf, fn) { } return fn.apply(this, arguments); }; -}; +} diff --git a/source/internal/_dropLast.js b/source/internal/_dropLast.js new file mode 100644 index 000000000..ba845c7f9 --- /dev/null +++ b/source/internal/_dropLast.js @@ -0,0 +1,5 @@ +import take from '../take'; + +export default function dropLast(n, xs) { + return take(n < xs.length ? xs.length - n : 0, xs); +} diff --git a/src/internal/_dropLastWhile.js b/source/internal/_dropLastWhile.js similarity index 56% rename from src/internal/_dropLastWhile.js rename to source/internal/_dropLastWhile.js index 59ff6d779..0cec9548c 100644 --- a/src/internal/_dropLastWhile.js +++ b/source/internal/_dropLastWhile.js @@ -1,9 +1,9 @@ -var slice = require('../slice'); +import slice from '../slice'; -module.exports = function dropLastWhile(pred, xs) { +export default function dropLastWhile(pred, xs) { var idx = xs.length - 1; while (idx >= 0 && pred(xs[idx])) { idx -= 1; } return slice(0, idx + 1, xs); -}; +} diff --git a/source/internal/_equals.js b/source/internal/_equals.js new file mode 100644 index 000000000..98c8b697f --- /dev/null +++ b/source/internal/_equals.js @@ -0,0 +1,157 @@ +import _arrayFromIterator from './_arrayFromIterator'; +import _containsWith from './_containsWith'; +import _functionName from './_functionName'; +import _has from './_has'; +import identical from '../identical'; +import keys from '../keys'; +import type from '../type'; + +/** + * private _uniqContentEquals function. + * That function is checking equality of 2 iterator contents with 2 assumptions + * - iterators lengths are the same + * - iterators values are unique + * + * false-positive result will be returned for comparision of, e.g. + * - [1,2,3] and [1,2,3,4] + * - [1,1,1] and [1,2,3] + * */ + +function _uniqContentEquals(aIterator, bIterator, stackA, stackB) { + var a = _arrayFromIterator(aIterator); + var b = _arrayFromIterator(bIterator); + + function eq(_a, _b) { + return _equals(_a, _b, stackA.slice(), stackB.slice()); + } + + // if *a* array contains any element that is not included in *b* + return !_containsWith(function(b, aItem) { + return !_containsWith(eq, aItem, b); + }, b, a); +} + +export default function _equals(a, b, stackA, stackB) { + if (identical(a, b)) { + return true; + } + + var typeA = type(a); + + if (typeA !== type(b)) { + return false; + } + + if (a == null || b == null) { + return false; + } + + if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') { + return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && + typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a); + } + + if (typeof a.equals === 'function' || typeof b.equals === 'function') { + return typeof a.equals === 'function' && a.equals(b) && + typeof b.equals === 'function' && b.equals(a); + } + + switch (typeA) { + case 'Arguments': + case 'Array': + case 'Object': + if (typeof a.constructor === 'function' && + _functionName(a.constructor) === 'Promise') { + return a === b; + } + break; + case 'Boolean': + case 'Number': + case 'String': + if (!(typeof a === typeof b && identical(a.valueOf(), b.valueOf()))) { + return false; + } + break; + case 'Date': + if (!identical(a.valueOf(), b.valueOf())) { + return false; + } + break; + case 'Error': + return a.name === b.name && a.message === b.message; + case 'RegExp': + if (!(a.source === b.source && + a.global === b.global && + a.ignoreCase === b.ignoreCase && + a.multiline === b.multiline && + a.sticky === b.sticky && + a.unicode === b.unicode)) { + return false; + } + break; + } + + var idx = stackA.length - 1; + while (idx >= 0) { + if (stackA[idx] === a) { + return stackB[idx] === b; + } + idx -= 1; + } + + switch (typeA) { + case 'Map': + if (a.size !== b.size) { + return false; + } + + return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b])); + case 'Set': + if (a.size !== b.size) { + return false; + } + + return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b])); + case 'Arguments': + case 'Array': + case 'Object': + case 'Boolean': + case 'Number': + case 'String': + case 'Date': + case 'Error': + case 'RegExp': + case 'Int8Array': + case 'Uint8Array': + case 'Uint8ClampedArray': + case 'Int16Array': + case 'Uint16Array': + case 'Int32Array': + case 'Uint32Array': + case 'Float32Array': + case 'Float64Array': + case 'ArrayBuffer': + break; + default: + // Values of other types are only equal if identical. + return false; + } + + var keysA = keys(a); + if (keysA.length !== keys(b).length) { + return false; + } + + var extendedStackA = stackA.concat([a]); + var extendedStackB = stackB.concat([b]); + + idx = keysA.length - 1; + while (idx >= 0) { + var key = keysA[idx]; + if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) { + return false; + } + idx -= 1; + } + return true; +} diff --git a/src/internal/_filter.js b/source/internal/_filter.js similarity index 79% rename from src/internal/_filter.js rename to source/internal/_filter.js index c9b7bd586..4ab3a0ecf 100644 --- a/src/internal/_filter.js +++ b/source/internal/_filter.js @@ -1,4 +1,4 @@ -module.exports = function _filter(fn, list) { +export default function _filter(fn, list) { var idx = 0; var len = list.length; var result = []; @@ -10,4 +10,4 @@ module.exports = function _filter(fn, list) { idx += 1; } return result; -}; +} diff --git a/source/internal/_flatCat.js b/source/internal/_flatCat.js new file mode 100644 index 000000000..bad311734 --- /dev/null +++ b/source/internal/_flatCat.js @@ -0,0 +1,32 @@ +import _forceReduced from './_forceReduced'; +import _isArrayLike from './_isArrayLike'; +import _reduce from './_reduce'; +import _xfBase from './_xfBase'; + +var preservingReduced = function(xf) { + return { + '@@transducer/init': _xfBase.init, + '@@transducer/result': function(result) { + return xf['@@transducer/result'](result); + }, + '@@transducer/step': function(result, input) { + var ret = xf['@@transducer/step'](result, input); + return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret; + } + }; +}; + +var _flatCat = function _xcat(xf) { + var rxf = preservingReduced(xf); + return { + '@@transducer/init': _xfBase.init, + '@@transducer/result': function(result) { + return rxf['@@transducer/result'](result); + }, + '@@transducer/step': function(result, input) { + return !_isArrayLike(input) ? _reduce(rxf, result, [input]) : _reduce(rxf, result, input); + } + }; +}; + +export default _flatCat; diff --git a/src/internal/_forceReduced.js b/source/internal/_forceReduced.js similarity index 61% rename from src/internal/_forceReduced.js rename to source/internal/_forceReduced.js index d20f9df30..7e7e38cd4 100644 --- a/src/internal/_forceReduced.js +++ b/source/internal/_forceReduced.js @@ -1,6 +1,6 @@ -module.exports = function _forceReduced(x) { +export default function _forceReduced(x) { return { '@@transducer/value': x, '@@transducer/reduced': true }; -}; +} diff --git a/src/internal/_functionName.js b/source/internal/_functionName.js similarity index 77% rename from src/internal/_functionName.js rename to source/internal/_functionName.js index 2d5f2bf05..07a2ad657 100644 --- a/src/internal/_functionName.js +++ b/source/internal/_functionName.js @@ -1,5 +1,5 @@ -module.exports = function _functionName(f) { +export default function _functionName(f) { // String(x => x) evaluates to "x => x", so the pattern may not match. var match = String(f).match(/^function (\w*)/); return match == null ? '' : match[1]; -}; +} diff --git a/src/internal/_functionsWith.js b/source/internal/_functionsWith.js similarity index 78% rename from src/internal/_functionsWith.js rename to source/internal/_functionsWith.js index 7ae5b3a21..173352b31 100644 --- a/src/internal/_functionsWith.js +++ b/source/internal/_functionsWith.js @@ -1,4 +1,4 @@ -var _filter = require('./_filter'); +import _filter from './_filter'; /** @@ -6,8 +6,8 @@ var _filter = require('./_filter'); * @param {Function} fn The strategy for extracting function names from an object * @return {Function} A function that takes an object and returns an array of function names. */ -module.exports = function _functionsWith(fn) { +export default function _functionsWith(fn) { return function(obj) { return _filter(function(key) { return typeof obj[key] === 'function'; }, fn(obj)); }; -}; +} diff --git a/src/internal/_has.js b/source/internal/_has.js similarity index 55% rename from src/internal/_has.js rename to source/internal/_has.js index 60d0c828e..5bb1ae12b 100644 --- a/src/internal/_has.js +++ b/source/internal/_has.js @@ -1,3 +1,3 @@ -module.exports = function _has(prop, obj) { +export default function _has(prop, obj) { return Object.prototype.hasOwnProperty.call(obj, prop); -}; +} diff --git a/source/internal/_identity.js b/source/internal/_identity.js new file mode 100644 index 000000000..d9b81378f --- /dev/null +++ b/source/internal/_identity.js @@ -0,0 +1 @@ +export default function _identity(x) { return x; } diff --git a/src/internal/_indexOf.js b/source/internal/_indexOf.js similarity index 93% rename from src/internal/_indexOf.js rename to source/internal/_indexOf.js index c1e927408..b62247596 100644 --- a/src/internal/_indexOf.js +++ b/source/internal/_indexOf.js @@ -1,7 +1,7 @@ -var equals = require('../equals'); +import equals from '../equals'; -module.exports = function _indexOf(list, a, idx) { +export default function _indexOf(list, a, idx) { var inf, item; // Array.prototype.indexOf doesn't exist below IE9 if (typeof list.indexOf === 'function') { @@ -54,4 +54,4 @@ module.exports = function _indexOf(list, a, idx) { idx += 1; } return -1; -}; +} diff --git a/src/internal/_isArguments.js b/source/internal/_isArguments.js similarity index 60% rename from src/internal/_isArguments.js rename to source/internal/_isArguments.js index eb52bb6e0..a6d04dce3 100644 --- a/src/internal/_isArguments.js +++ b/source/internal/_isArguments.js @@ -1,9 +1,11 @@ -var _has = require('./_has'); +import _has from './_has'; -module.exports = (function() { - var toString = Object.prototype.toString; +var toString = Object.prototype.toString; +var _isArguments = function() { return toString.call(arguments) === '[object Arguments]' ? function _isArguments(x) { return toString.call(x) === '[object Arguments]'; } : function _isArguments(x) { return _has('callee', x); }; -}()); +}; + +export default _isArguments; diff --git a/src/internal/_isArray.js b/source/internal/_isArray.js similarity index 87% rename from src/internal/_isArray.js rename to source/internal/_isArray.js index e8f0bb9c4..38b3cdfaa 100644 --- a/src/internal/_isArray.js +++ b/source/internal/_isArray.js @@ -10,7 +10,7 @@ * _isArray(null); //=> false * _isArray({}); //=> false */ -module.exports = Array.isArray || function _isArray(val) { +export default Array.isArray || function _isArray(val) { return (val != null && val.length >= 0 && Object.prototype.toString.call(val) === '[object Array]'); diff --git a/src/internal/_isArrayLike.js b/source/internal/_isArrayLike.js similarity index 82% rename from src/internal/_isArrayLike.js rename to source/internal/_isArrayLike.js index be504faca..219330c58 100644 --- a/src/internal/_isArrayLike.js +++ b/source/internal/_isArrayLike.js @@ -1,6 +1,6 @@ -var _curry1 = require('./_curry1'); -var _isArray = require('./_isArray'); -var _isString = require('./_isString'); +import _curry1 from './_curry1'; +import _isArray from './_isArray'; +import _isString from './_isString'; /** @@ -20,7 +20,7 @@ var _isString = require('./_isString'); * _isArrayLike({length: 10}); //=> false * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true */ -module.exports = _curry1(function isArrayLike(x) { +var _isArrayLike = _curry1(function isArrayLike(x) { if (_isArray(x)) { return true; } if (!x) { return false; } if (typeof x !== 'object') { return false; } @@ -32,3 +32,4 @@ module.exports = _curry1(function isArrayLike(x) { } return false; }); +export default _isArrayLike; diff --git a/src/internal/_isFunction.js b/source/internal/_isFunction.js similarity index 59% rename from src/internal/_isFunction.js rename to source/internal/_isFunction.js index 4196d89b5..ff1f9ecdb 100644 --- a/src/internal/_isFunction.js +++ b/source/internal/_isFunction.js @@ -1,3 +1,3 @@ -module.exports = function _isFunction(x) { +export default function _isFunction(x) { return Object.prototype.toString.call(x) === '[object Function]'; -}; +} diff --git a/src/internal/_isInteger.js b/source/internal/_isInteger.js similarity index 71% rename from src/internal/_isInteger.js rename to source/internal/_isInteger.js index 2d08103fb..4e901e52a 100644 --- a/src/internal/_isInteger.js +++ b/source/internal/_isInteger.js @@ -6,6 +6,6 @@ * @category Type * @return {Boolean} */ -module.exports = Number.isInteger || function _isInteger(n) { +export default Number.isInteger || function _isInteger(n) { return (n << 0) === n; }; diff --git a/src/internal/_isNumber.js b/source/internal/_isNumber.js similarity index 60% rename from src/internal/_isNumber.js rename to source/internal/_isNumber.js index f1b5a11b3..1d541aec6 100644 --- a/src/internal/_isNumber.js +++ b/source/internal/_isNumber.js @@ -1,3 +1,3 @@ -module.exports = function _isNumber(x) { +export default function _isNumber(x) { return Object.prototype.toString.call(x) === '[object Number]'; -}; +} diff --git a/src/internal/_isObject.js b/source/internal/_isObject.js similarity index 60% rename from src/internal/_isObject.js rename to source/internal/_isObject.js index 28f9ca32b..3f1516cea 100644 --- a/src/internal/_isObject.js +++ b/source/internal/_isObject.js @@ -1,3 +1,3 @@ -module.exports = function _isObject(x) { +export default function _isObject(x) { return Object.prototype.toString.call(x) === '[object Object]'; -}; +} diff --git a/src/internal/_isPlaceholder.js b/source/internal/_isPlaceholder.js similarity index 68% rename from src/internal/_isPlaceholder.js rename to source/internal/_isPlaceholder.js index d473d9d07..f7fe0007f 100644 --- a/src/internal/_isPlaceholder.js +++ b/source/internal/_isPlaceholder.js @@ -1,5 +1,5 @@ -module.exports = function _isPlaceholder(a) { +export default function _isPlaceholder(a) { return a != null && typeof a === 'object' && a['@@functional/placeholder'] === true; -}; +} diff --git a/src/internal/_isRegExp.js b/source/internal/_isRegExp.js similarity index 60% rename from src/internal/_isRegExp.js rename to source/internal/_isRegExp.js index 05b68b64f..21f4372c5 100644 --- a/src/internal/_isRegExp.js +++ b/source/internal/_isRegExp.js @@ -1,3 +1,3 @@ -module.exports = function _isRegExp(x) { +export default function _isRegExp(x) { return Object.prototype.toString.call(x) === '[object RegExp]'; -}; +} diff --git a/src/internal/_isString.js b/source/internal/_isString.js similarity index 60% rename from src/internal/_isString.js rename to source/internal/_isString.js index 2c9fd085c..e6dc5b9f6 100644 --- a/src/internal/_isString.js +++ b/source/internal/_isString.js @@ -1,3 +1,3 @@ -module.exports = function _isString(x) { +export default function _isString(x) { return Object.prototype.toString.call(x) === '[object String]'; -}; +} diff --git a/src/internal/_isTransformer.js b/source/internal/_isTransformer.js similarity index 52% rename from src/internal/_isTransformer.js rename to source/internal/_isTransformer.js index 9e21fcc47..d7ccdf077 100644 --- a/src/internal/_isTransformer.js +++ b/source/internal/_isTransformer.js @@ -1,3 +1,3 @@ -module.exports = function _isTransformer(obj) { +export default function _isTransformer(obj) { return typeof obj['@@transducer/step'] === 'function'; -}; +} diff --git a/src/internal/_makeFlat.js b/source/internal/_makeFlat.js similarity index 86% rename from src/internal/_makeFlat.js rename to source/internal/_makeFlat.js index ebaa7a57d..a96002e32 100644 --- a/src/internal/_makeFlat.js +++ b/source/internal/_makeFlat.js @@ -1,4 +1,4 @@ -var _isArrayLike = require('./_isArrayLike'); +import _isArrayLike from './_isArrayLike'; /** @@ -7,7 +7,7 @@ var _isArrayLike = require('./_isArrayLike'); * * @private */ -module.exports = function _makeFlat(recursive) { +export default function _makeFlat(recursive) { return function flatt(list) { var value, jlen, j; var result = []; @@ -30,4 +30,4 @@ module.exports = function _makeFlat(recursive) { } return result; }; -}; +} diff --git a/src/internal/_map.js b/source/internal/_map.js similarity index 76% rename from src/internal/_map.js rename to source/internal/_map.js index 2b22f9129..8c30ca00b 100644 --- a/src/internal/_map.js +++ b/source/internal/_map.js @@ -1,4 +1,4 @@ -module.exports = function _map(fn, functor) { +export default function _map(fn, functor) { var idx = 0; var len = functor.length; var result = Array(len); @@ -7,4 +7,4 @@ module.exports = function _map(fn, functor) { idx += 1; } return result; -}; +} diff --git a/src/internal/_objectAssign.js b/source/internal/_objectAssign.js similarity index 86% rename from src/internal/_objectAssign.js rename to source/internal/_objectAssign.js index 17b223f95..08af204d8 100644 --- a/src/internal/_objectAssign.js +++ b/source/internal/_objectAssign.js @@ -1,7 +1,7 @@ -var _has = require('./_has'); +import _has from './_has'; // Based on https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign -module.exports = function _objectAssign(target) { +export default function _objectAssign(target) { if (target == null) { throw new TypeError('Cannot convert undefined or null to object'); } @@ -21,4 +21,4 @@ module.exports = function _objectAssign(target) { idx += 1; } return output; -}; +} diff --git a/source/internal/_of.js b/source/internal/_of.js new file mode 100644 index 000000000..c0f9863fa --- /dev/null +++ b/source/internal/_of.js @@ -0,0 +1 @@ +export default function _of(x) { return [x]; } diff --git a/src/internal/_pipe.js b/source/internal/_pipe.js similarity index 64% rename from src/internal/_pipe.js rename to source/internal/_pipe.js index 3cb2a69b5..a4b58ae8e 100644 --- a/src/internal/_pipe.js +++ b/source/internal/_pipe.js @@ -1,5 +1,5 @@ -module.exports = function _pipe(f, g) { +export default function _pipe(f, g) { return function() { return g.call(this, f.apply(this, arguments)); }; -}; +} diff --git a/src/internal/_pipeP.js b/source/internal/_pipeP.js similarity index 75% rename from src/internal/_pipeP.js rename to source/internal/_pipeP.js index ddfd69017..8271df0fa 100644 --- a/src/internal/_pipeP.js +++ b/source/internal/_pipeP.js @@ -1,8 +1,8 @@ -module.exports = function _pipeP(f, g) { +export default function _pipeP(f, g) { return function() { var ctx = this; return f.apply(ctx, arguments).then(function(x) { return g.call(ctx, x); }); }; -}; +} diff --git a/src/internal/_quote.js b/source/internal/_quote.js similarity index 89% rename from src/internal/_quote.js rename to source/internal/_quote.js index fe93fe7ae..b9fe84904 100644 --- a/src/internal/_quote.js +++ b/source/internal/_quote.js @@ -1,4 +1,4 @@ -module.exports = function _quote(s) { +export default function _quote(s) { var escaped = s .replace(/\\/g, '\\\\') .replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace @@ -10,4 +10,4 @@ module.exports = function _quote(s) { .replace(/\0/g, '\\0'); return '"' + escaped.replace(/"/g, '\\"') + '"'; -}; +} diff --git a/source/internal/_reduce.js b/source/internal/_reduce.js new file mode 100644 index 000000000..1ae333653 --- /dev/null +++ b/source/internal/_reduce.js @@ -0,0 +1,60 @@ +import _isArrayLike from './_isArrayLike'; +import _xwrap from './_xwrap'; +import bind from '../bind'; + + +function _arrayReduce(xf, acc, list) { + var idx = 0; + var len = list.length; + while (idx < len) { + acc = xf['@@transducer/step'](acc, list[idx]); + if (acc && acc['@@transducer/reduced']) { + acc = acc['@@transducer/value']; + break; + } + idx += 1; + } + return xf['@@transducer/result'](acc); +} + +function _iterableReduce(xf, acc, iter) { + var step = iter.next(); + while (!step.done) { + acc = xf['@@transducer/step'](acc, step.value); + if (acc && acc['@@transducer/reduced']) { + acc = acc['@@transducer/value']; + break; + } + step = iter.next(); + } + return xf['@@transducer/result'](acc); +} + +function _methodReduce(xf, acc, obj, methodName) { + return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc)); +} + +var symIterator = (typeof Symbol !== 'undefined') ? Symbol.iterator : '@@iterator'; + +export default function _reduce(fn, acc, list) { + if (typeof fn === 'function') { + fn = _xwrap(fn); + } + if (_isArrayLike(list)) { + return _arrayReduce(fn, acc, list); + } + if (typeof list['fantasy-land/reduce'] === 'function') { + return _methodReduce(fn, acc, list, 'fantasy-land/reduce'); + } + if (list[symIterator] != null) { + return _iterableReduce(fn, acc, list[symIterator]()); + } + if (typeof list.next === 'function') { + return _iterableReduce(fn, acc, list); + } + if (typeof list.reduce === 'function') { + return _methodReduce(fn, acc, list, 'reduce'); + } + + throw new TypeError('reduce: list must be array or iterable'); +} diff --git a/src/internal/_reduced.js b/source/internal/_reduced.js similarity index 74% rename from src/internal/_reduced.js rename to source/internal/_reduced.js index a82bc0eaa..83ea94ee9 100644 --- a/src/internal/_reduced.js +++ b/source/internal/_reduced.js @@ -1,7 +1,7 @@ -module.exports = function _reduced(x) { +export default function _reduced(x) { return x && x['@@transducer/reduced'] ? x : { '@@transducer/value': x, '@@transducer/reduced': true }; -}; +} diff --git a/source/internal/_stepCat.js b/source/internal/_stepCat.js new file mode 100644 index 000000000..49bedde1f --- /dev/null +++ b/source/internal/_stepCat.js @@ -0,0 +1,46 @@ +import _assign from './_assign'; +import _identity from './_identity'; +import _isArrayLike from './_isArrayLike'; +import _isTransformer from './_isTransformer'; +import objOf from '../objOf'; + + +var _stepCatArray = { + '@@transducer/init': Array, + '@@transducer/step': function(xs, x) { + xs.push(x); + return xs; + }, + '@@transducer/result': _identity +}; +var _stepCatString = { + '@@transducer/init': String, + '@@transducer/step': function(a, b) { return a + b; }, + '@@transducer/result': _identity +}; +var _stepCatObject = { + '@@transducer/init': Object, + '@@transducer/step': function(result, input) { + return _assign( + result, + _isArrayLike(input) ? objOf(input[0], input[1]) : input + ); + }, + '@@transducer/result': _identity +}; + +export default function _stepCat(obj) { + if (_isTransformer(obj)) { + return obj; + } + if (_isArrayLike(obj)) { + return _stepCatArray; + } + if (typeof obj === 'string') { + return _stepCatString; + } + if (typeof obj === 'object') { + return _stepCatObject; + } + throw new Error('Cannot create transformer for ' + obj); +} diff --git a/source/internal/_toISOString.js b/source/internal/_toISOString.js new file mode 100644 index 000000000..d665f2de9 --- /dev/null +++ b/source/internal/_toISOString.js @@ -0,0 +1,22 @@ +/** + * Polyfill from . + */ +var pad = function pad(n) { return (n < 10 ? '0' : '') + n; }; + +var _toISOString = typeof Date.prototype.toISOString === 'function' ? + function _toISOString(d) { + return d.toISOString(); + } : + function _toISOString(d) { + return ( + d.getUTCFullYear() + '-' + + pad(d.getUTCMonth() + 1) + '-' + + pad(d.getUTCDate()) + 'T' + + pad(d.getUTCHours()) + ':' + + pad(d.getUTCMinutes()) + ':' + + pad(d.getUTCSeconds()) + '.' + + (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z' + ); + }; + +export default _toISOString; diff --git a/src/internal/_toString.js b/source/internal/_toString.js similarity index 84% rename from src/internal/_toString.js rename to source/internal/_toString.js index 3ec22c893..efa59739b 100644 --- a/src/internal/_toString.js +++ b/source/internal/_toString.js @@ -1,12 +1,12 @@ -var _contains = require('./_contains'); -var _map = require('./_map'); -var _quote = require('./_quote'); -var _toISOString = require('./_toISOString'); -var keys = require('../keys'); -var reject = require('../reject'); +import _contains from './_contains'; +import _map from './_map'; +import _quote from './_quote'; +import _toISOString from './_toISOString'; +import keys from '../keys'; +import reject from '../reject'; -module.exports = function _toString(x, seen) { +export default function _toString(x, seen) { var recur = function recur(y) { var xs = seen.concat([x]); return _contains(y, xs) ? '' : _toString(y, xs); @@ -43,4 +43,4 @@ module.exports = function _toString(x, seen) { } return '{' + mapPairs(x, keys(x)).join(', ') + '}'; } -}; +} diff --git a/source/internal/_xall.js b/source/internal/_xall.js new file mode 100644 index 000000000..c11b81345 --- /dev/null +++ b/source/internal/_xall.js @@ -0,0 +1,27 @@ +import _curry2 from './_curry2'; +import _reduced from './_reduced'; +import _xfBase from './_xfBase'; + + +function XAll(f, xf) { + this.xf = xf; + this.f = f; + this.all = true; +} +XAll.prototype['@@transducer/init'] = _xfBase.init; +XAll.prototype['@@transducer/result'] = function(result) { + if (this.all) { + result = this.xf['@@transducer/step'](result, true); + } + return this.xf['@@transducer/result'](result); +}; +XAll.prototype['@@transducer/step'] = function(result, input) { + if (!this.f(input)) { + this.all = false; + result = _reduced(this.xf['@@transducer/step'](result, false)); + } + return result; +}; + +var _xall = _curry2(function _xall(f, xf) { return new XAll(f, xf); }); +export default _xall; diff --git a/source/internal/_xany.js b/source/internal/_xany.js new file mode 100644 index 000000000..84ac7d94e --- /dev/null +++ b/source/internal/_xany.js @@ -0,0 +1,27 @@ +import _curry2 from './_curry2'; +import _reduced from './_reduced'; +import _xfBase from './_xfBase'; + + +function XAny(f, xf) { + this.xf = xf; + this.f = f; + this.any = false; +} +XAny.prototype['@@transducer/init'] = _xfBase.init; +XAny.prototype['@@transducer/result'] = function(result) { + if (!this.any) { + result = this.xf['@@transducer/step'](result, false); + } + return this.xf['@@transducer/result'](result); +}; +XAny.prototype['@@transducer/step'] = function(result, input) { + if (this.f(input)) { + this.any = true; + result = _reduced(this.xf['@@transducer/step'](result, true)); + } + return result; +}; + +var _xany = _curry2(function _xany(f, xf) { return new XAny(f, xf); }); +export default _xany; diff --git a/source/internal/_xaperture.js b/source/internal/_xaperture.js new file mode 100644 index 000000000..07623728e --- /dev/null +++ b/source/internal/_xaperture.js @@ -0,0 +1,35 @@ +import _concat from './_concat'; +import _curry2 from './_curry2'; +import _xfBase from './_xfBase'; + + +function XAperture(n, xf) { + this.xf = xf; + this.pos = 0; + this.full = false; + this.acc = new Array(n); +} +XAperture.prototype['@@transducer/init'] = _xfBase.init; +XAperture.prototype['@@transducer/result'] = function(result) { + this.acc = null; + return this.xf['@@transducer/result'](result); +}; +XAperture.prototype['@@transducer/step'] = function(result, input) { + this.store(input); + return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result; +}; +XAperture.prototype.store = function(input) { + this.acc[this.pos] = input; + this.pos += 1; + if (this.pos === this.acc.length) { + this.pos = 0; + this.full = true; + } +}; +XAperture.prototype.getCopy = function() { + return _concat(Array.prototype.slice.call(this.acc, this.pos), + Array.prototype.slice.call(this.acc, 0, this.pos)); +}; + +var _xaperture = _curry2(function _xaperture(n, xf) { return new XAperture(n, xf); }); +export default _xaperture; diff --git a/source/internal/_xchain.js b/source/internal/_xchain.js new file mode 100644 index 000000000..75c9a9789 --- /dev/null +++ b/source/internal/_xchain.js @@ -0,0 +1,9 @@ +import _curry2 from './_curry2'; +import _flatCat from './_flatCat'; +import map from '../map'; + + +var _xchain = _curry2(function _xchain(f, xf) { + return map(f, _flatCat(xf)); +}); +export default _xchain; diff --git a/source/internal/_xdrop.js b/source/internal/_xdrop.js new file mode 100644 index 000000000..4201543ed --- /dev/null +++ b/source/internal/_xdrop.js @@ -0,0 +1,20 @@ +import _curry2 from './_curry2'; +import _xfBase from './_xfBase'; + + +function XDrop(n, xf) { + this.xf = xf; + this.n = n; +} +XDrop.prototype['@@transducer/init'] = _xfBase.init; +XDrop.prototype['@@transducer/result'] = _xfBase.result; +XDrop.prototype['@@transducer/step'] = function(result, input) { + if (this.n > 0) { + this.n -= 1; + return result; + } + return this.xf['@@transducer/step'](result, input); +}; + +var _xdrop = _curry2(function _xdrop(n, xf) { return new XDrop(n, xf); }); +export default _xdrop; diff --git a/source/internal/_xdropLast.js b/source/internal/_xdropLast.js new file mode 100644 index 000000000..513423bef --- /dev/null +++ b/source/internal/_xdropLast.js @@ -0,0 +1,33 @@ +import _curry2 from './_curry2'; +import _xfBase from './_xfBase'; + + +function XDropLast(n, xf) { + this.xf = xf; + this.pos = 0; + this.full = false; + this.acc = new Array(n); +} +XDropLast.prototype['@@transducer/init'] = _xfBase.init; +XDropLast.prototype['@@transducer/result'] = function(result) { + this.acc = null; + return this.xf['@@transducer/result'](result); +}; +XDropLast.prototype['@@transducer/step'] = function(result, input) { + if (this.full) { + result = this.xf['@@transducer/step'](result, this.acc[this.pos]); + } + this.store(input); + return result; +}; +XDropLast.prototype.store = function(input) { + this.acc[this.pos] = input; + this.pos += 1; + if (this.pos === this.acc.length) { + this.pos = 0; + this.full = true; + } +}; + +var _xdropLast = _curry2(function _xdropLast(n, xf) { return new XDropLast(n, xf); }); +export default _xdropLast; diff --git a/source/internal/_xdropLastWhile.js b/source/internal/_xdropLastWhile.js new file mode 100644 index 000000000..a44528377 --- /dev/null +++ b/source/internal/_xdropLastWhile.js @@ -0,0 +1,35 @@ +import _curry2 from './_curry2'; +import _reduce from './_reduce'; +import _xfBase from './_xfBase'; + + +function XDropLastWhile(fn, xf) { + this.f = fn; + this.retained = []; + this.xf = xf; +} +XDropLastWhile.prototype['@@transducer/init'] = _xfBase.init; +XDropLastWhile.prototype['@@transducer/result'] = function(result) { + this.retained = null; + return this.xf['@@transducer/result'](result); +}; +XDropLastWhile.prototype['@@transducer/step'] = function(result, input) { + return this.f(input) ? this.retain(result, input) + : this.flush(result, input); +}; +XDropLastWhile.prototype.flush = function(result, input) { + result = _reduce( + this.xf['@@transducer/step'], + result, + this.retained + ); + this.retained = []; + return this.xf['@@transducer/step'](result, input); +}; +XDropLastWhile.prototype.retain = function(result, input) { + this.retained.push(input); + return result; +}; + +var _xdropLastWhile = _curry2(function _xdropLastWhile(fn, xf) { return new XDropLastWhile(fn, xf); }); +export default _xdropLastWhile; diff --git a/source/internal/_xdropRepeatsWith.js b/source/internal/_xdropRepeatsWith.js new file mode 100644 index 000000000..da3537f61 --- /dev/null +++ b/source/internal/_xdropRepeatsWith.js @@ -0,0 +1,26 @@ +import _curry2 from './_curry2'; +import _xfBase from './_xfBase'; + + +function XDropRepeatsWith(pred, xf) { + this.xf = xf; + this.pred = pred; + this.lastValue = undefined; + this.seenFirstValue = false; +} + +XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init; +XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result; +XDropRepeatsWith.prototype['@@transducer/step'] = function(result, input) { + var sameAsLast = false; + if (!this.seenFirstValue) { + this.seenFirstValue = true; + } else if (this.pred(this.lastValue, input)) { + sameAsLast = true; + } + this.lastValue = input; + return sameAsLast ? result : this.xf['@@transducer/step'](result, input); +}; + +var _xdropRepeatsWith = _curry2(function _xdropRepeatsWith(pred, xf) { return new XDropRepeatsWith(pred, xf); }); +export default _xdropRepeatsWith; diff --git a/source/internal/_xdropWhile.js b/source/internal/_xdropWhile.js new file mode 100644 index 000000000..892906bee --- /dev/null +++ b/source/internal/_xdropWhile.js @@ -0,0 +1,22 @@ +import _curry2 from './_curry2'; +import _xfBase from './_xfBase'; + + +function XDropWhile(f, xf) { + this.xf = xf; + this.f = f; +} +XDropWhile.prototype['@@transducer/init'] = _xfBase.init; +XDropWhile.prototype['@@transducer/result'] = _xfBase.result; +XDropWhile.prototype['@@transducer/step'] = function(result, input) { + if (this.f) { + if (this.f(input)) { + return result; + } + this.f = null; + } + return this.xf['@@transducer/step'](result, input); +}; + +var _xdropWhile = _curry2(function _xdropWhile(f, xf) { return new XDropWhile(f, xf); }); +export default _xdropWhile; diff --git a/src/internal/_xfBase.js b/source/internal/_xfBase.js similarity index 89% rename from src/internal/_xfBase.js rename to source/internal/_xfBase.js index 0f8413109..d946c6185 100644 --- a/src/internal/_xfBase.js +++ b/source/internal/_xfBase.js @@ -1,4 +1,4 @@ -module.exports = { +export default { init: function() { return this.xf['@@transducer/init'](); }, diff --git a/source/internal/_xfilter.js b/source/internal/_xfilter.js new file mode 100644 index 000000000..6ffaecdea --- /dev/null +++ b/source/internal/_xfilter.js @@ -0,0 +1,16 @@ +import _curry2 from './_curry2'; +import _xfBase from './_xfBase'; + + +function XFilter(f, xf) { + this.xf = xf; + this.f = f; +} +XFilter.prototype['@@transducer/init'] = _xfBase.init; +XFilter.prototype['@@transducer/result'] = _xfBase.result; +XFilter.prototype['@@transducer/step'] = function(result, input) { + return this.f(input) ? this.xf['@@transducer/step'](result, input) : result; +}; + +var _xfilter = _curry2(function _xfilter(f, xf) { return new XFilter(f, xf); }); +export default _xfilter; diff --git a/source/internal/_xfind.js b/source/internal/_xfind.js new file mode 100644 index 000000000..6929da398 --- /dev/null +++ b/source/internal/_xfind.js @@ -0,0 +1,27 @@ +import _curry2 from './_curry2'; +import _reduced from './_reduced'; +import _xfBase from './_xfBase'; + + +function XFind(f, xf) { + this.xf = xf; + this.f = f; + this.found = false; +} +XFind.prototype['@@transducer/init'] = _xfBase.init; +XFind.prototype['@@transducer/result'] = function(result) { + if (!this.found) { + result = this.xf['@@transducer/step'](result, void 0); + } + return this.xf['@@transducer/result'](result); +}; +XFind.prototype['@@transducer/step'] = function(result, input) { + if (this.f(input)) { + this.found = true; + result = _reduced(this.xf['@@transducer/step'](result, input)); + } + return result; +}; + +var _xfind = _curry2(function _xfind(f, xf) { return new XFind(f, xf); }); +export default _xfind; diff --git a/source/internal/_xfindIndex.js b/source/internal/_xfindIndex.js new file mode 100644 index 000000000..6e0f2aa54 --- /dev/null +++ b/source/internal/_xfindIndex.js @@ -0,0 +1,29 @@ +import _curry2 from './_curry2'; +import _reduced from './_reduced'; +import _xfBase from './_xfBase'; + + +function XFindIndex(f, xf) { + this.xf = xf; + this.f = f; + this.idx = -1; + this.found = false; +} +XFindIndex.prototype['@@transducer/init'] = _xfBase.init; +XFindIndex.prototype['@@transducer/result'] = function(result) { + if (!this.found) { + result = this.xf['@@transducer/step'](result, -1); + } + return this.xf['@@transducer/result'](result); +}; +XFindIndex.prototype['@@transducer/step'] = function(result, input) { + this.idx += 1; + if (this.f(input)) { + this.found = true; + result = _reduced(this.xf['@@transducer/step'](result, this.idx)); + } + return result; +}; + +var _xfindIndex = _curry2(function _xfindIndex(f, xf) { return new XFindIndex(f, xf); }); +export default _xfindIndex; diff --git a/source/internal/_xfindLast.js b/source/internal/_xfindLast.js new file mode 100644 index 000000000..876a6b4d6 --- /dev/null +++ b/source/internal/_xfindLast.js @@ -0,0 +1,21 @@ +import _curry2 from './_curry2'; +import _xfBase from './_xfBase'; + + +function XFindLast(f, xf) { + this.xf = xf; + this.f = f; +} +XFindLast.prototype['@@transducer/init'] = _xfBase.init; +XFindLast.prototype['@@transducer/result'] = function(result) { + return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.last)); +}; +XFindLast.prototype['@@transducer/step'] = function(result, input) { + if (this.f(input)) { + this.last = input; + } + return result; +}; + +var _xfindLast = _curry2(function _xfindLast(f, xf) { return new XFindLast(f, xf); }); +export default _xfindLast; diff --git a/source/internal/_xfindLastIndex.js b/source/internal/_xfindLastIndex.js new file mode 100644 index 000000000..b6f4e4af6 --- /dev/null +++ b/source/internal/_xfindLastIndex.js @@ -0,0 +1,24 @@ +import _curry2 from './_curry2'; +import _xfBase from './_xfBase'; + + +function XFindLastIndex(f, xf) { + this.xf = xf; + this.f = f; + this.idx = -1; + this.lastIdx = -1; +} +XFindLastIndex.prototype['@@transducer/init'] = _xfBase.init; +XFindLastIndex.prototype['@@transducer/result'] = function(result) { + return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.lastIdx)); +}; +XFindLastIndex.prototype['@@transducer/step'] = function(result, input) { + this.idx += 1; + if (this.f(input)) { + this.lastIdx = this.idx; + } + return result; +}; + +var _xfindLastIndex = _curry2(function _xfindLastIndex(f, xf) { return new XFindLastIndex(f, xf); }); +export default _xfindLastIndex; diff --git a/source/internal/_xmap.js b/source/internal/_xmap.js new file mode 100644 index 000000000..4fbed5051 --- /dev/null +++ b/source/internal/_xmap.js @@ -0,0 +1,16 @@ +import _curry2 from './_curry2'; +import _xfBase from './_xfBase'; + + +function XMap(f, xf) { + this.xf = xf; + this.f = f; +} +XMap.prototype['@@transducer/init'] = _xfBase.init; +XMap.prototype['@@transducer/result'] = _xfBase.result; +XMap.prototype['@@transducer/step'] = function(result, input) { + return this.xf['@@transducer/step'](result, this.f(input)); +}; + +var _xmap = _curry2(function _xmap(f, xf) { return new XMap(f, xf); }); +export default _xmap; diff --git a/source/internal/_xreduceBy.js b/source/internal/_xreduceBy.js new file mode 100644 index 000000000..27f52c6b3 --- /dev/null +++ b/source/internal/_xreduceBy.js @@ -0,0 +1,39 @@ +import _curryN from './_curryN'; +import _has from './_has'; +import _xfBase from './_xfBase'; + + +function XReduceBy(valueFn, valueAcc, keyFn, xf) { + this.valueFn = valueFn; + this.valueAcc = valueAcc; + this.keyFn = keyFn; + this.xf = xf; + this.inputs = {}; +} +XReduceBy.prototype['@@transducer/init'] = _xfBase.init; +XReduceBy.prototype['@@transducer/result'] = function(result) { + var key; + for (key in this.inputs) { + if (_has(key, this.inputs)) { + result = this.xf['@@transducer/step'](result, this.inputs[key]); + if (result['@@transducer/reduced']) { + result = result['@@transducer/value']; + break; + } + } + } + this.inputs = null; + return this.xf['@@transducer/result'](result); +}; +XReduceBy.prototype['@@transducer/step'] = function(result, input) { + var key = this.keyFn(input); + this.inputs[key] = this.inputs[key] || [key, this.valueAcc]; + this.inputs[key][1] = this.valueFn(this.inputs[key][1], input); + return result; +}; + +var _xreduceBy = _curryN(4, [], + function _xreduceBy(valueFn, valueAcc, keyFn, xf) { + return new XReduceBy(valueFn, valueAcc, keyFn, xf); + }); +export default _xreduceBy; diff --git a/source/internal/_xtake.js b/source/internal/_xtake.js new file mode 100644 index 000000000..57f98c200 --- /dev/null +++ b/source/internal/_xtake.js @@ -0,0 +1,20 @@ +import _curry2 from './_curry2'; +import _reduced from './_reduced'; +import _xfBase from './_xfBase'; + + +function XTake(n, xf) { + this.xf = xf; + this.n = n; + this.i = 0; +} +XTake.prototype['@@transducer/init'] = _xfBase.init; +XTake.prototype['@@transducer/result'] = _xfBase.result; +XTake.prototype['@@transducer/step'] = function(result, input) { + this.i += 1; + var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input); + return this.n >= 0 && this.i >= this.n ? _reduced(ret) : ret; +}; + +var _xtake = _curry2(function _xtake(n, xf) { return new XTake(n, xf); }); +export default _xtake; diff --git a/source/internal/_xtakeWhile.js b/source/internal/_xtakeWhile.js new file mode 100644 index 000000000..9915078f9 --- /dev/null +++ b/source/internal/_xtakeWhile.js @@ -0,0 +1,17 @@ +import _curry2 from './_curry2'; +import _reduced from './_reduced'; +import _xfBase from './_xfBase'; + + +function XTakeWhile(f, xf) { + this.xf = xf; + this.f = f; +} +XTakeWhile.prototype['@@transducer/init'] = _xfBase.init; +XTakeWhile.prototype['@@transducer/result'] = _xfBase.result; +XTakeWhile.prototype['@@transducer/step'] = function(result, input) { + return this.f(input) ? this.xf['@@transducer/step'](result, input) : _reduced(result); +}; + +var _xtakeWhile = _curry2(function _xtakeWhile(f, xf) { return new XTakeWhile(f, xf); }); +export default _xtakeWhile; diff --git a/source/internal/_xtap.js b/source/internal/_xtap.js new file mode 100644 index 000000000..d1b5fbefc --- /dev/null +++ b/source/internal/_xtap.js @@ -0,0 +1,17 @@ +import _curry2 from './_curry2'; +import _xfBase from './_xfBase'; + + +function XTap(f, xf) { + this.xf = xf; + this.f = f; +} +XTap.prototype['@@transducer/init'] = _xfBase.init; +XTap.prototype['@@transducer/result'] = _xfBase.result; +XTap.prototype['@@transducer/step'] = function(result, input) { + this.f(input); + return this.xf['@@transducer/step'](result, input); +}; + +var _xtap = _curry2(function _xtap(f, xf) { return new XTap(f, xf); }); +export default _xtap; diff --git a/source/internal/_xwrap.js b/source/internal/_xwrap.js new file mode 100644 index 000000000..b0111865e --- /dev/null +++ b/source/internal/_xwrap.js @@ -0,0 +1,12 @@ +function XWrap(fn) { + this.f = fn; +} +XWrap.prototype['@@transducer/init'] = function() { + throw new Error('init not implemented on XWrap'); +}; +XWrap.prototype['@@transducer/result'] = function(acc) { return acc; }; +XWrap.prototype['@@transducer/step'] = function(acc, x) { + return this.f(acc, x); +}; + +export default function _xwrap(fn) { return new XWrap(fn); } diff --git a/src/intersection.js b/source/intersection.js similarity index 71% rename from src/intersection.js rename to source/intersection.js index a4703e35a..f01fe0ccc 100644 --- a/src/intersection.js +++ b/source/intersection.js @@ -1,8 +1,8 @@ -var _contains = require('./internal/_contains'); -var _curry2 = require('./internal/_curry2'); -var _filter = require('./internal/_filter'); -var flip = require('./flip'); -var uniq = require('./uniq'); +import _contains from './internal/_contains'; +import _curry2 from './internal/_curry2'; +import _filter from './internal/_filter'; +import flip from './flip'; +import uniq from './uniq'; /** @@ -22,7 +22,7 @@ var uniq = require('./uniq'); * * R.intersection([1,2,3,4], [7,6,5,4,3]); //=> [4, 3] */ -module.exports = _curry2(function intersection(list1, list2) { +var intersection = _curry2(function intersection(list1, list2) { var lookupList, filteredList; if (list1.length > list2.length) { lookupList = list1; @@ -33,3 +33,4 @@ module.exports = _curry2(function intersection(list1, list2) { } return uniq(_filter(flip(_contains)(lookupList), filteredList)); }); +export default intersection; diff --git a/src/intersectionWith.js b/source/intersectionWith.js similarity index 87% rename from src/intersectionWith.js rename to source/intersectionWith.js index 686a5bc98..53be5b915 100644 --- a/src/intersectionWith.js +++ b/source/intersectionWith.js @@ -1,6 +1,6 @@ -var _containsWith = require('./internal/_containsWith'); -var _curry3 = require('./internal/_curry3'); -var uniqWith = require('./uniqWith'); +import _containsWith from './internal/_containsWith'; +import _curry3 from './internal/_curry3'; +import uniqWith from './uniqWith'; /** @@ -39,7 +39,7 @@ var uniqWith = require('./uniqWith'); * R.intersectionWith(R.eqBy(R.prop('id')), buffaloSpringfield, csny); * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}] */ -module.exports = _curry3(function intersectionWith(pred, list1, list2) { +var intersectionWith = _curry3(function intersectionWith(pred, list1, list2) { var lookupList, filteredList; if (list1.length > list2.length) { lookupList = list1; @@ -58,3 +58,4 @@ module.exports = _curry3(function intersectionWith(pred, list1, list2) { } return uniqWith(pred, results); }); +export default intersectionWith; diff --git a/src/intersperse.js b/source/intersperse.js similarity index 76% rename from src/intersperse.js rename to source/intersperse.js index 7df5dfb8c..f29a77f66 100644 --- a/src/intersperse.js +++ b/source/intersperse.js @@ -1,5 +1,5 @@ -var _checkForMethod = require('./internal/_checkForMethod'); -var _curry2 = require('./internal/_curry2'); +import _checkForMethod from './internal/_checkForMethod'; +import _curry2 from './internal/_curry2'; /** @@ -19,7 +19,7 @@ var _curry2 = require('./internal/_curry2'); * * R.intersperse('n', ['ba', 'a', 'a']); //=> ['ba', 'n', 'a', 'n', 'a'] */ -module.exports = _curry2(_checkForMethod('intersperse', function intersperse(separator, list) { +var intersperse = _curry2(_checkForMethod('intersperse', function intersperse(separator, list) { var out = []; var idx = 0; var length = list.length; @@ -33,3 +33,4 @@ module.exports = _curry2(_checkForMethod('intersperse', function intersperse(sep } return out; })); +export default intersperse; diff --git a/src/into.js b/source/into.js similarity index 85% rename from src/into.js rename to source/into.js index 3c7cec564..3bddf9ac8 100644 --- a/src/into.js +++ b/source/into.js @@ -1,8 +1,8 @@ -var _clone = require('./internal/_clone'); -var _curry3 = require('./internal/_curry3'); -var _isTransformer = require('./internal/_isTransformer'); -var _reduce = require('./internal/_reduce'); -var _stepCat = require('./internal/_stepCat'); +import _clone from './internal/_clone'; +import _curry3 from './internal/_curry3'; +import _isTransformer from './internal/_isTransformer'; +import _reduce from './internal/_reduce'; +import _stepCat from './internal/_stepCat'; /** @@ -43,8 +43,9 @@ var _stepCat = require('./internal/_stepCat'); * var intoArray = R.into([]); * intoArray(transducer, numbers); //=> [2, 3] */ -module.exports = _curry3(function into(acc, xf, list) { +var into = _curry3(function into(acc, xf, list) { return _isTransformer(acc) ? _reduce(xf(acc), acc['@@transducer/init'](), list) : _reduce(xf(_stepCat(acc)), _clone(acc, [], [], false), list); }); +export default into; diff --git a/src/invert.js b/source/invert.js similarity index 84% rename from src/invert.js rename to source/invert.js index 1e8cc92b9..bd1f1afa0 100644 --- a/src/invert.js +++ b/source/invert.js @@ -1,6 +1,6 @@ -var _curry1 = require('./internal/_curry1'); -var _has = require('./internal/_has'); -var keys = require('./keys'); +import _curry1 from './internal/_curry1'; +import _has from './internal/_has'; +import keys from './keys'; /** @@ -25,7 +25,7 @@ var keys = require('./keys'); * R.invert(raceResultsByFirstName); * //=> { 'alice': ['first', 'third'], 'jake':['second'] } */ -module.exports = _curry1(function invert(obj) { +var invert = _curry1(function invert(obj) { var props = keys(obj); var len = props.length; var idx = 0; @@ -40,3 +40,4 @@ module.exports = _curry1(function invert(obj) { } return out; }); +export default invert; diff --git a/src/invertObj.js b/source/invertObj.js similarity index 86% rename from src/invertObj.js rename to source/invertObj.js index 24a63bd6b..6bfc82de1 100644 --- a/src/invertObj.js +++ b/source/invertObj.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var keys = require('./keys'); +import _curry1 from './internal/_curry1'; +import keys from './keys'; /** @@ -29,7 +29,7 @@ var keys = require('./keys'); * R.invertObj(raceResults); * //=> { 'alice': '0', 'jake':'1' } */ -module.exports = _curry1(function invertObj(obj) { +var invertObj = _curry1(function invertObj(obj) { var props = keys(obj); var len = props.length; var idx = 0; @@ -42,3 +42,4 @@ module.exports = _curry1(function invertObj(obj) { } return out; }); +export default invertObj; diff --git a/src/invoker.js b/source/invoker.js similarity index 85% rename from src/invoker.js rename to source/invoker.js index 829d6557a..be3d29ca7 100644 --- a/src/invoker.js +++ b/source/invoker.js @@ -1,7 +1,7 @@ -var _curry2 = require('./internal/_curry2'); -var _isFunction = require('./internal/_isFunction'); -var curryN = require('./curryN'); -var toString = require('./toString'); +import _curry2 from './internal/_curry2'; +import _isFunction from './internal/_isFunction'; +import curryN from './curryN'; +import toString from './toString'; /** @@ -31,7 +31,7 @@ var toString = require('./toString'); * @symb R.invoker(1, 'method')(a, o) = o['method'](a) * @symb R.invoker(2, 'method')(a, b, o) = o['method'](a, b) */ -module.exports = _curry2(function invoker(arity, method) { +var invoker = _curry2(function invoker(arity, method) { return curryN(arity + 1, function() { var target = arguments[arity]; if (target != null && _isFunction(target[method])) { @@ -40,3 +40,4 @@ module.exports = _curry2(function invoker(arity, method) { throw new TypeError(toString(target) + ' does not have a method named "' + method + '"'); }); }); +export default invoker; diff --git a/src/is.js b/source/is.js similarity index 87% rename from src/is.js rename to source/is.js index 0d9748f8e..e2e2c09ad 100644 --- a/src/is.js +++ b/source/is.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -24,6 +24,7 @@ var _curry2 = require('./internal/_curry2'); * R.is(Object, 's'); //=> false * R.is(Number, {}); //=> false */ -module.exports = _curry2(function is(Ctor, val) { +var is = _curry2(function is(Ctor, val) { return val != null && val.constructor === Ctor || val instanceof Ctor; }); +export default is; diff --git a/src/isEmpty.js b/source/isEmpty.js similarity index 76% rename from src/isEmpty.js rename to source/isEmpty.js index 27fc83262..ae9f75d24 100644 --- a/src/isEmpty.js +++ b/source/isEmpty.js @@ -1,6 +1,6 @@ -var _curry1 = require('./internal/_curry1'); -var empty = require('./empty'); -var equals = require('./equals'); +import _curry1 from './internal/_curry1'; +import empty from './empty'; +import equals from './equals'; /** @@ -24,6 +24,7 @@ var equals = require('./equals'); * R.isEmpty({}); //=> true * R.isEmpty({length: 0}); //=> false */ -module.exports = _curry1(function isEmpty(x) { +var isEmpty = _curry1(function isEmpty(x) { return x != null && equals(x, empty(x)); }); +export default isEmpty; diff --git a/src/isNil.js b/source/isNil.js similarity index 76% rename from src/isNil.js rename to source/isNil.js index 1ce59a54f..e2c9c0203 100644 --- a/src/isNil.js +++ b/source/isNil.js @@ -1,4 +1,4 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; /** @@ -18,4 +18,5 @@ var _curry1 = require('./internal/_curry1'); * R.isNil(0); //=> false * R.isNil([]); //=> false */ -module.exports = _curry1(function isNil(x) { return x == null; }); +var isNil = _curry1(function isNil(x) { return x == null; }); +export default isNil; diff --git a/src/join.js b/source/join.js similarity index 87% rename from src/join.js rename to source/join.js index 2d4dce5f0..0c3666372 100644 --- a/src/join.js +++ b/source/join.js @@ -1,4 +1,4 @@ -var invoker = require('./invoker'); +import invoker from './invoker'; /** @@ -20,4 +20,5 @@ var invoker = require('./invoker'); * spacer(['a', 2, 3.4]); //=> 'a 2 3.4' * R.join('|', [1, 2, 3]); //=> '1|2|3' */ -module.exports = invoker(1, 'join'); +var join = invoker(1, 'join'); +export default join; diff --git a/src/juxt.js b/source/juxt.js similarity index 82% rename from src/juxt.js rename to source/juxt.js index f11e04923..76a0dee04 100644 --- a/src/juxt.js +++ b/source/juxt.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var converge = require('./converge'); +import _curry1 from './internal/_curry1'; +import converge from './converge'; /** @@ -19,6 +19,7 @@ var converge = require('./converge'); * getRange(3, 4, 9, -3); //=> [-3, 9] * @symb R.juxt([f, g, h])(a, b) = [f(a, b), g(a, b), h(a, b)] */ -module.exports = _curry1(function juxt(fns) { +var juxt = _curry1(function juxt(fns) { return converge(function() { return Array.prototype.slice.call(arguments, 0); }, fns); }); +export default juxt; diff --git a/source/keys.js b/source/keys.js new file mode 100644 index 000000000..73c4158e6 --- /dev/null +++ b/source/keys.js @@ -0,0 +1,73 @@ +import _curry1 from './internal/_curry1'; +import _has from './internal/_has'; +import _isArguments from './internal/_isArguments'; + +// cover IE < 9 keys issues +var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString'); +var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', + 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; +// Safari bug +var hasArgsEnumBug = (function() { + 'use strict'; + return arguments.propertyIsEnumerable('length'); +}()); + +var contains = function contains(list, item) { + var idx = 0; + while (idx < list.length) { + if (list[idx] === item) { + return true; + } + idx += 1; + } + return false; +}; + +/** + * Returns a list containing the names of all the enumerable own properties of + * the supplied object. + * Note that the order of the output array is not guaranteed to be consistent + * across different JS platforms. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig {k: v} -> [k] + * @param {Object} obj The object to extract properties from + * @return {Array} An array of the object's own properties. + * @see R.keysIn, R.values + * @example + * + * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c'] + */ +var _keys = typeof Object.keys === 'function' && !hasArgsEnumBug ? + function keys(obj) { + return Object(obj) !== obj ? [] : Object.keys(obj); + } : + function keys(obj) { + if (Object(obj) !== obj) { + return []; + } + var prop, nIdx; + var ks = []; + var checkArgsLength = hasArgsEnumBug && _isArguments(obj); + for (prop in obj) { + if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) { + ks[ks.length] = prop; + } + } + if (hasEnumBug) { + nIdx = nonEnumerableProps.length - 1; + while (nIdx >= 0) { + prop = nonEnumerableProps[nIdx]; + if (_has(prop, obj) && !contains(ks, prop)) { + ks[ks.length] = prop; + } + nIdx -= 1; + } + } + return ks; + }; +var keys = _curry1(_keys); +export default keys; diff --git a/src/keysIn.js b/source/keysIn.js similarity index 87% rename from src/keysIn.js rename to source/keysIn.js index 5e56b3921..6af0e709a 100644 --- a/src/keysIn.js +++ b/source/keysIn.js @@ -1,4 +1,4 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; /** @@ -22,7 +22,7 @@ var _curry1 = require('./internal/_curry1'); * var f = new F(); * R.keysIn(f); //=> ['x', 'y'] */ -module.exports = _curry1(function keysIn(obj) { +var keysIn = _curry1(function keysIn(obj) { var prop; var ks = []; for (prop in obj) { @@ -30,3 +30,4 @@ module.exports = _curry1(function keysIn(obj) { } return ks; }); +export default keysIn; diff --git a/src/last.js b/source/last.js similarity index 86% rename from src/last.js rename to source/last.js index d30d85765..a8c74fd2d 100644 --- a/src/last.js +++ b/source/last.js @@ -1,4 +1,4 @@ -var nth = require('./nth'); +import nth from './nth'; /** @@ -21,4 +21,5 @@ var nth = require('./nth'); * R.last('abc'); //=> 'c' * R.last(''); //=> '' */ -module.exports = nth(-1); +var last = nth(-1); +export default last; diff --git a/src/lastIndexOf.js b/source/lastIndexOf.js similarity index 80% rename from src/lastIndexOf.js rename to source/lastIndexOf.js index 5ca86e0f3..107f9064d 100644 --- a/src/lastIndexOf.js +++ b/source/lastIndexOf.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var _isArray = require('./internal/_isArray'); -var equals = require('./equals'); +import _curry2 from './internal/_curry2'; +import _isArray from './internal/_isArray'; +import equals from './equals'; /** @@ -22,7 +22,7 @@ var equals = require('./equals'); * R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6 * R.lastIndexOf(10, [1,2,3,4]); //=> -1 */ -module.exports = _curry2(function lastIndexOf(target, xs) { +var lastIndexOf = _curry2(function lastIndexOf(target, xs) { if (typeof xs.lastIndexOf === 'function' && !_isArray(xs)) { return xs.lastIndexOf(target); } else { @@ -36,3 +36,4 @@ module.exports = _curry2(function lastIndexOf(target, xs) { return -1; } }); +export default lastIndexOf; diff --git a/src/length.js b/source/length.js similarity index 72% rename from src/length.js rename to source/length.js index e5ef7e5c3..1a7db285e 100644 --- a/src/length.js +++ b/source/length.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var _isNumber = require('./internal/_isNumber'); +import _curry1 from './internal/_curry1'; +import _isNumber from './internal/_isNumber'; /** @@ -17,6 +17,7 @@ var _isNumber = require('./internal/_isNumber'); * R.length([]); //=> 0 * R.length([1, 2, 3]); //=> 3 */ -module.exports = _curry1(function length(list) { +var length = _curry1(function length(list) { return list != null && _isNumber(list.length) ? list.length : NaN; }); +export default length; diff --git a/src/lens.js b/source/lens.js similarity index 87% rename from src/lens.js rename to source/lens.js index 49959812c..de83f8726 100644 --- a/src/lens.js +++ b/source/lens.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var map = require('./map'); +import _curry2 from './internal/_curry2'; +import map from './map'; /** @@ -25,7 +25,7 @@ var map = require('./map'); * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2} */ -module.exports = _curry2(function lens(getter, setter) { +var lens = _curry2(function lens(getter, setter) { return function(toFunctorFn) { return function(target) { return map( @@ -37,3 +37,4 @@ module.exports = _curry2(function lens(getter, setter) { }; }; }); +export default lens; diff --git a/src/lensIndex.js b/source/lensIndex.js similarity index 74% rename from src/lensIndex.js rename to source/lensIndex.js index 9f412e18c..9497e0b92 100644 --- a/src/lensIndex.js +++ b/source/lensIndex.js @@ -1,7 +1,7 @@ -var _curry1 = require('./internal/_curry1'); -var lens = require('./lens'); -var nth = require('./nth'); -var update = require('./update'); +import _curry1 from './internal/_curry1'; +import lens from './lens'; +import nth from './nth'; +import update from './update'; /** @@ -24,6 +24,7 @@ var update = require('./update'); * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c'] * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c'] */ -module.exports = _curry1(function lensIndex(n) { +var lensIndex = _curry1(function lensIndex(n) { return lens(nth(n), update(n)); }); +export default lensIndex; diff --git a/src/lensPath.js b/source/lensPath.js similarity index 78% rename from src/lensPath.js rename to source/lensPath.js index 013e1e324..3690173bd 100644 --- a/src/lensPath.js +++ b/source/lensPath.js @@ -1,7 +1,7 @@ -var _curry1 = require('./internal/_curry1'); -var assocPath = require('./assocPath'); -var lens = require('./lens'); -var path = require('./path'); +import _curry1 from './internal/_curry1'; +import assocPath from './assocPath'; +import lens from './lens'; +import path from './path'; /** @@ -28,6 +28,7 @@ var path = require('./path'); * R.over(xHeadYLens, R.negate, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); * //=> {x: [{y: -2, z: 3}, {y: 4, z: 5}]} */ -module.exports = _curry1(function lensPath(p) { +var lensPath = _curry1(function lensPath(p) { return lens(path(p), assocPath(p)); }); +export default lensPath; diff --git a/src/lensProp.js b/source/lensProp.js similarity index 74% rename from src/lensProp.js rename to source/lensProp.js index 4b854ac67..40ecfc03a 100644 --- a/src/lensProp.js +++ b/source/lensProp.js @@ -1,7 +1,7 @@ -var _curry1 = require('./internal/_curry1'); -var assoc = require('./assoc'); -var lens = require('./lens'); -var prop = require('./prop'); +import _curry1 from './internal/_curry1'; +import assoc from './assoc'; +import lens from './lens'; +import prop from './prop'; /** @@ -24,6 +24,7 @@ var prop = require('./prop'); * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2} */ -module.exports = _curry1(function lensProp(k) { +var lensProp = _curry1(function lensProp(k) { return lens(prop(k), assoc(k)); }); +export default lensProp; diff --git a/src/lift.js b/source/lift.js similarity index 85% rename from src/lift.js rename to source/lift.js index 9b372aadd..9c427644a 100644 --- a/src/lift.js +++ b/source/lift.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var liftN = require('./liftN'); +import _curry1 from './internal/_curry1'; +import liftN from './liftN'; /** @@ -24,6 +24,7 @@ var liftN = require('./liftN'); * * madd5([1,2], [3], [4, 5], [6], [7, 8]); //=> [21, 22, 22, 23, 22, 23, 23, 24] */ -module.exports = _curry1(function lift(fn) { +var lift = _curry1(function lift(fn) { return liftN(fn.length, fn); }); +export default lift; diff --git a/src/liftN.js b/source/liftN.js similarity index 77% rename from src/liftN.js rename to source/liftN.js index dfb6b507a..dd48362bf 100644 --- a/src/liftN.js +++ b/source/liftN.js @@ -1,8 +1,8 @@ -var _curry2 = require('./internal/_curry2'); -var _reduce = require('./internal/_reduce'); -var ap = require('./ap'); -var curryN = require('./curryN'); -var map = require('./map'); +import _curry2 from './internal/_curry2'; +import _reduce from './internal/_reduce'; +import ap from './ap'; +import curryN from './curryN'; +import map from './map'; /** @@ -22,9 +22,10 @@ var map = require('./map'); * var madd3 = R.liftN(3, (...args) => R.sum(args)); * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] */ -module.exports = _curry2(function liftN(arity, fn) { +var liftN = _curry2(function liftN(arity, fn) { var lifted = curryN(arity, fn); return curryN(arity, function() { return _reduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1)); }); }); +export default liftN; diff --git a/src/lt.js b/source/lt.js similarity index 79% rename from src/lt.js rename to source/lt.js index 115793ee8..bd6bf8850 100644 --- a/src/lt.js +++ b/source/lt.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -22,4 +22,5 @@ var _curry2 = require('./internal/_curry2'); * R.lt('a', 'z'); //=> true * R.lt('z', 'a'); //=> false */ -module.exports = _curry2(function lt(a, b) { return a < b; }); +var lt = _curry2(function lt(a, b) { return a < b; }); +export default lt; diff --git a/src/lte.js b/source/lte.js similarity index 79% rename from src/lte.js rename to source/lte.js index f02bd4867..ba4571fe3 100644 --- a/src/lte.js +++ b/source/lte.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -22,4 +22,5 @@ var _curry2 = require('./internal/_curry2'); * R.lte('a', 'z'); //=> true * R.lte('z', 'a'); //=> false */ -module.exports = _curry2(function lte(a, b) { return a <= b; }); +var lte = _curry2(function lte(a, b) { return a <= b; }); +export default lte; diff --git a/src/map.js b/source/map.js similarity index 80% rename from src/map.js rename to source/map.js index 29442bd34..a8b372846 100644 --- a/src/map.js +++ b/source/map.js @@ -1,10 +1,10 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _map = require('./internal/_map'); -var _reduce = require('./internal/_reduce'); -var _xmap = require('./internal/_xmap'); -var curryN = require('./curryN'); -var keys = require('./keys'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _map from './internal/_map'; +import _reduce from './internal/_reduce'; +import _xmap from './internal/_xmap'; +import curryN from './curryN'; +import keys from './keys'; /** @@ -42,7 +42,7 @@ var keys = require('./keys'); * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) } * @symb R.map(f, functor_o) = functor_o.map(f) */ -module.exports = _curry2(_dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) { +var map = _curry2(_dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) { switch (Object.prototype.toString.call(functor)) { case '[object Function]': return curryN(functor.length, function() { @@ -57,3 +57,4 @@ module.exports = _curry2(_dispatchable(['fantasy-land/map', 'map'], _xmap, funct return _map(fn, functor); } })); +export default map; diff --git a/src/mapAccum.js b/source/mapAccum.js similarity index 91% rename from src/mapAccum.js rename to source/mapAccum.js index f962bbbe9..3a02c19ff 100644 --- a/src/mapAccum.js +++ b/source/mapAccum.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -35,7 +35,7 @@ var _curry3 = require('./internal/_curry3'); * ] * ] */ -module.exports = _curry3(function mapAccum(fn, acc, list) { +var mapAccum = _curry3(function mapAccum(fn, acc, list) { var idx = 0; var len = list.length; var result = []; @@ -47,3 +47,4 @@ module.exports = _curry3(function mapAccum(fn, acc, list) { } return [tuple[0], result]; }); +export default mapAccum; diff --git a/src/mapAccumRight.js b/source/mapAccumRight.js similarity index 91% rename from src/mapAccumRight.js rename to source/mapAccumRight.js index 2bf9685ea..ecb6d8419 100644 --- a/src/mapAccumRight.js +++ b/source/mapAccumRight.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -38,7 +38,7 @@ var _curry3 = require('./internal/_curry3'); * f(b, f(c, f(d, a)[0])[0])[0], * ] */ -module.exports = _curry3(function mapAccumRight(fn, acc, list) { +var mapAccumRight = _curry3(function mapAccumRight(fn, acc, list) { var idx = list.length - 1; var result = []; var tuple = [acc]; @@ -49,3 +49,4 @@ module.exports = _curry3(function mapAccumRight(fn, acc, list) { } return [result, tuple[0]]; }); +export default mapAccumRight; diff --git a/src/mapObjIndexed.js b/source/mapObjIndexed.js similarity index 78% rename from src/mapObjIndexed.js rename to source/mapObjIndexed.js index 76118bb1d..2c2d4f089 100644 --- a/src/mapObjIndexed.js +++ b/source/mapObjIndexed.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var _reduce = require('./internal/_reduce'); -var keys = require('./keys'); +import _curry2 from './internal/_curry2'; +import _reduce from './internal/_reduce'; +import keys from './keys'; /** @@ -24,9 +24,10 @@ var keys = require('./keys'); * * R.mapObjIndexed(prependKeyAndDouble, values); //=> { x: 'x2', y: 'y4', z: 'z6' } */ -module.exports = _curry2(function mapObjIndexed(fn, obj) { +var mapObjIndexed = _curry2(function mapObjIndexed(fn, obj) { return _reduce(function(acc, key) { acc[key] = fn(obj[key], key, obj); return acc; }, {}, keys(obj)); }); +export default mapObjIndexed; diff --git a/src/match.js b/source/match.js similarity index 88% rename from src/match.js rename to source/match.js index bedf6d898..b9de4e744 100644 --- a/src/match.js +++ b/source/match.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -22,6 +22,7 @@ var _curry2 = require('./internal/_curry2'); * R.match(/a/, 'b'); //=> [] * R.match(/a/, null); //=> TypeError: null does not have a method named "match" */ -module.exports = _curry2(function match(rx, str) { +var match = _curry2(function match(rx, str) { return str.match(rx) || []; }); +export default match; diff --git a/src/mathMod.js b/source/mathMod.js similarity index 87% rename from src/mathMod.js rename to source/mathMod.js index d85b7e344..ef9d0c9a9 100644 --- a/src/mathMod.js +++ b/source/mathMod.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var _isInteger = require('./internal/_isInteger'); +import _curry2 from './internal/_curry2'; +import _isInteger from './internal/_isInteger'; /** @@ -35,8 +35,9 @@ var _isInteger = require('./internal/_isInteger'); * seventeenMod(4); //=> 1 * seventeenMod(10); //=> 7 */ -module.exports = _curry2(function mathMod(m, p) { +var mathMod = _curry2(function mathMod(m, p) { if (!_isInteger(m)) { return NaN; } if (!_isInteger(p) || p < 1) { return NaN; } return ((m % p) + p) % p; }); +export default mathMod; diff --git a/src/max.js b/source/max.js similarity index 70% rename from src/max.js rename to source/max.js index da3bb1431..5793179d0 100644 --- a/src/max.js +++ b/source/max.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -18,4 +18,5 @@ var _curry2 = require('./internal/_curry2'); * R.max(789, 123); //=> 789 * R.max('a', 'b'); //=> 'b' */ -module.exports = _curry2(function max(a, b) { return b > a ? b : a; }); +var max = _curry2(function max(a, b) { return b > a ? b : a; }); +export default max; diff --git a/src/maxBy.js b/source/maxBy.js similarity index 84% rename from src/maxBy.js rename to source/maxBy.js index 871854fc8..bb5672fdc 100644 --- a/src/maxBy.js +++ b/source/maxBy.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -25,6 +25,7 @@ var _curry3 = require('./internal/_curry3'); * R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5 * R.reduce(R.maxBy(square), 0, []); //=> 0 */ -module.exports = _curry3(function maxBy(f, a, b) { +var maxBy = _curry3(function maxBy(f, a, b) { return f(b) > f(a) ? b : a; }); +export default maxBy; diff --git a/src/mean.js b/source/mean.js similarity index 71% rename from src/mean.js rename to source/mean.js index b15f9a8e1..116b9ce78 100644 --- a/src/mean.js +++ b/source/mean.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var sum = require('./sum'); +import _curry1 from './internal/_curry1'; +import sum from './sum'; /** @@ -18,6 +18,7 @@ var sum = require('./sum'); * R.mean([2, 7, 9]); //=> 6 * R.mean([]); //=> NaN */ -module.exports = _curry1(function mean(list) { +var mean = _curry1(function mean(list) { return sum(list) / list.length; }); +export default mean; diff --git a/src/median.js b/source/median.js similarity index 81% rename from src/median.js rename to source/median.js index 3a1426025..d18fc456b 100644 --- a/src/median.js +++ b/source/median.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var mean = require('./mean'); +import _curry1 from './internal/_curry1'; +import mean from './mean'; /** @@ -19,7 +19,7 @@ var mean = require('./mean'); * R.median([7, 2, 10, 9]); //=> 8 * R.median([]); //=> NaN */ -module.exports = _curry1(function median(list) { +var median = _curry1(function median(list) { var len = list.length; if (len === 0) { return NaN; @@ -30,3 +30,4 @@ module.exports = _curry1(function median(list) { return a < b ? -1 : a > b ? 1 : 0; }).slice(idx, idx + width)); }); +export default median; diff --git a/src/memoize.js b/source/memoize.js similarity index 86% rename from src/memoize.js rename to source/memoize.js index 0d45f360a..d6627c619 100644 --- a/src/memoize.js +++ b/source/memoize.js @@ -1,5 +1,5 @@ -var memoizeWith = require('./memoizeWith'); -var toString = require('./toString'); +import memoizeWith from './memoizeWith'; +import toString from './toString'; /** @@ -29,6 +29,7 @@ var toString = require('./toString'); * factorial(5); //=> 120 * count; //=> 1 */ -module.exports = memoizeWith(function() { +var memoize = memoizeWith(function() { return toString(arguments); }); +export default memoize; diff --git a/src/memoizeWith.js b/source/memoizeWith.js similarity index 85% rename from src/memoizeWith.js rename to source/memoizeWith.js index 91205bd31..22262efc5 100644 --- a/src/memoizeWith.js +++ b/source/memoizeWith.js @@ -1,6 +1,6 @@ -var _arity = require('./internal/_arity'); -var _curry2 = require('./internal/_curry2'); -var _has = require('./internal/_has'); +import _arity from './internal/_arity'; +import _curry2 from './internal/_curry2'; +import _has from './internal/_has'; /** @@ -32,7 +32,7 @@ var _has = require('./internal/_has'); * factorial(5); //=> 120 * count; //=> 1 */ -module.exports = _curry2(function memoizeWith(mFn, fn) { +var memoizeWith = _curry2(function memoizeWith(mFn, fn) { var cache = {}; return _arity(fn.length, function() { var key = mFn.apply(this, arguments); @@ -42,3 +42,4 @@ module.exports = _curry2(function memoizeWith(mFn, fn) { return cache[key]; }); }); +export default memoizeWith; diff --git a/src/merge.js b/source/merge.js similarity index 83% rename from src/merge.js rename to source/merge.js index b43967307..6d6ec1ee0 100644 --- a/src/merge.js +++ b/source/merge.js @@ -1,5 +1,5 @@ -var _assign = require('./internal/_assign'); -var _curry2 = require('./internal/_curry2'); +import _assign from './internal/_assign'; +import _curry2 from './internal/_curry2'; /** @@ -25,6 +25,7 @@ var _curry2 = require('./internal/_curry2'); * resetToDefault({x: 5, y: 2}); //=> {x: 0, y: 2} * @symb R.merge({ x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: 5, z: 3 } */ -module.exports = _curry2(function merge(l, r) { +var merge = _curry2(function merge(l, r) { return _assign({}, l, r); }); +export default merge; diff --git a/src/mergeAll.js b/source/mergeAll.js similarity index 77% rename from src/mergeAll.js rename to source/mergeAll.js index 6f156bd7b..5374a800a 100644 --- a/src/mergeAll.js +++ b/source/mergeAll.js @@ -1,5 +1,5 @@ -var _assign = require('./internal/_assign'); -var _curry1 = require('./internal/_curry1'); +import _assign from './internal/_assign'; +import _curry1 from './internal/_curry1'; /** @@ -19,6 +19,7 @@ var _curry1 = require('./internal/_curry1'); * R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2} * @symb R.mergeAll([{ x: 1 }, { y: 2 }, { z: 3 }]) = { x: 1, y: 2, z: 3 } */ -module.exports = _curry1(function mergeAll(list) { +var mergeAll = _curry1(function mergeAll(list) { return _assign.apply(null, [{}].concat(list)); }); +export default mergeAll; diff --git a/src/mergeDeepLeft.js b/source/mergeDeepLeft.js similarity index 82% rename from src/mergeDeepLeft.js rename to source/mergeDeepLeft.js index a4c598067..efc8dce4a 100644 --- a/src/mergeDeepLeft.js +++ b/source/mergeDeepLeft.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var mergeDeepWithKey = require('./mergeDeepWithKey'); +import _curry2 from './internal/_curry2'; +import mergeDeepWithKey from './mergeDeepWithKey'; /** @@ -23,8 +23,9 @@ var mergeDeepWithKey = require('./mergeDeepWithKey'); * { age: 40, contact: { email: 'baa@example.com' }}); * //=> { name: 'fred', age: 10, contact: { email: 'moo@example.com' }} */ -module.exports = _curry2(function mergeDeepLeft(lObj, rObj) { +var mergeDeepLeft = _curry2(function mergeDeepLeft(lObj, rObj) { return mergeDeepWithKey(function(k, lVal, rVal) { return lVal; }, lObj, rObj); }); +export default mergeDeepLeft; diff --git a/src/mergeDeepRight.js b/source/mergeDeepRight.js similarity index 82% rename from src/mergeDeepRight.js rename to source/mergeDeepRight.js index e38035518..29af0fb12 100644 --- a/src/mergeDeepRight.js +++ b/source/mergeDeepRight.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var mergeDeepWithKey = require('./mergeDeepWithKey'); +import _curry2 from './internal/_curry2'; +import mergeDeepWithKey from './mergeDeepWithKey'; /** @@ -23,8 +23,9 @@ var mergeDeepWithKey = require('./mergeDeepWithKey'); * { age: 40, contact: { email: 'baa@example.com' }}); * //=> { name: 'fred', age: 40, contact: { email: 'baa@example.com' }} */ -module.exports = _curry2(function mergeDeepRight(lObj, rObj) { +var mergeDeepRight = _curry2(function mergeDeepRight(lObj, rObj) { return mergeDeepWithKey(function(k, lVal, rVal) { return rVal; }, lObj, rObj); }); +export default mergeDeepRight; diff --git a/src/mergeDeepWith.js b/source/mergeDeepWith.js similarity index 84% rename from src/mergeDeepWith.js rename to source/mergeDeepWith.js index 09fc3a2b3..426940a39 100644 --- a/src/mergeDeepWith.js +++ b/source/mergeDeepWith.js @@ -1,5 +1,5 @@ -var _curry3 = require('./internal/_curry3'); -var mergeDeepWithKey = require('./mergeDeepWithKey'); +import _curry3 from './internal/_curry3'; +import mergeDeepWithKey from './mergeDeepWithKey'; /** @@ -29,8 +29,9 @@ var mergeDeepWithKey = require('./mergeDeepWithKey'); * { b: true, c: { values: [15, 35] }}); * //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }} */ -module.exports = _curry3(function mergeDeepWith(fn, lObj, rObj) { +var mergeDeepWith = _curry3(function mergeDeepWith(fn, lObj, rObj) { return mergeDeepWithKey(function(k, lVal, rVal) { return fn(lVal, rVal); }, lObj, rObj); }); +export default mergeDeepWith; diff --git a/src/mergeDeepWithKey.js b/source/mergeDeepWithKey.js similarity index 84% rename from src/mergeDeepWithKey.js rename to source/mergeDeepWithKey.js index 4bedaab69..c105d215e 100644 --- a/src/mergeDeepWithKey.js +++ b/source/mergeDeepWithKey.js @@ -1,6 +1,6 @@ -var _curry3 = require('./internal/_curry3'); -var _isObject = require('./internal/_isObject'); -var mergeWithKey = require('./mergeWithKey'); +import _curry3 from './internal/_curry3'; +import _isObject from './internal/_isObject'; +import mergeWithKey from './mergeWithKey'; /** @@ -31,7 +31,7 @@ var mergeWithKey = require('./mergeWithKey'); * { b: true, c: { thing: 'bar', values: [15, 35] }}); * //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }} */ -module.exports = _curry3(function mergeDeepWithKey(fn, lObj, rObj) { +var mergeDeepWithKey = _curry3(function mergeDeepWithKey(fn, lObj, rObj) { return mergeWithKey(function(k, lVal, rVal) { if (_isObject(lVal) && _isObject(rVal)) { return mergeDeepWithKey(fn, lVal, rVal); @@ -40,3 +40,4 @@ module.exports = _curry3(function mergeDeepWithKey(fn, lObj, rObj) { } }, lObj, rObj); }); +export default mergeDeepWithKey; diff --git a/src/mergeWith.js b/source/mergeWith.js similarity index 83% rename from src/mergeWith.js rename to source/mergeWith.js index 4dc2b35f9..5b4a756bc 100644 --- a/src/mergeWith.js +++ b/source/mergeWith.js @@ -1,5 +1,5 @@ -var _curry3 = require('./internal/_curry3'); -var mergeWithKey = require('./mergeWithKey'); +import _curry3 from './internal/_curry3'; +import mergeWithKey from './mergeWithKey'; /** @@ -25,8 +25,9 @@ var mergeWithKey = require('./mergeWithKey'); * { b: true, values: [15, 35] }); * //=> { a: true, b: true, values: [10, 20, 15, 35] } */ -module.exports = _curry3(function mergeWith(fn, l, r) { +var mergeWith = _curry3(function mergeWith(fn, l, r) { return mergeWithKey(function(_, _l, _r) { return fn(_l, _r); }, l, r); }); +export default mergeWith; diff --git a/src/mergeWithKey.js b/source/mergeWithKey.js similarity index 88% rename from src/mergeWithKey.js rename to source/mergeWithKey.js index ebca73bb7..1cb7332ea 100644 --- a/src/mergeWithKey.js +++ b/source/mergeWithKey.js @@ -1,5 +1,5 @@ -var _curry3 = require('./internal/_curry3'); -var _has = require('./internal/_has'); +import _curry3 from './internal/_curry3'; +import _has from './internal/_has'; /** @@ -27,7 +27,7 @@ var _has = require('./internal/_has'); * //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] } * @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 } */ -module.exports = _curry3(function mergeWithKey(fn, l, r) { +var mergeWithKey = _curry3(function mergeWithKey(fn, l, r) { var result = {}; var k; @@ -45,3 +45,4 @@ module.exports = _curry3(function mergeWithKey(fn, l, r) { return result; }); +export default mergeWithKey; diff --git a/src/min.js b/source/min.js similarity index 70% rename from src/min.js rename to source/min.js index a39eb201f..3d0b59985 100644 --- a/src/min.js +++ b/source/min.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -18,4 +18,5 @@ var _curry2 = require('./internal/_curry2'); * R.min(789, 123); //=> 123 * R.min('a', 'b'); //=> 'a' */ -module.exports = _curry2(function min(a, b) { return b < a ? b : a; }); +var min = _curry2(function min(a, b) { return b < a ? b : a; }); +export default min; diff --git a/src/minBy.js b/source/minBy.js similarity index 85% rename from src/minBy.js rename to source/minBy.js index f45a3baed..ed314177a 100644 --- a/src/minBy.js +++ b/source/minBy.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -25,6 +25,7 @@ var _curry3 = require('./internal/_curry3'); * R.reduce(R.minBy(square), Infinity, [3, -5, 4, 1, -2]); //=> 1 * R.reduce(R.minBy(square), Infinity, []); //=> Infinity */ -module.exports = _curry3(function minBy(f, a, b) { +var minBy = _curry3(function minBy(f, a, b) { return f(b) < f(a) ? b : a; }); +export default minBy; diff --git a/src/modulo.js b/source/modulo.js similarity index 84% rename from src/modulo.js rename to source/modulo.js index 9a3b58b91..3e0a91322 100644 --- a/src/modulo.js +++ b/source/modulo.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -26,4 +26,5 @@ var _curry2 = require('./internal/_curry2'); * isOdd(42); //=> 0 * isOdd(21); //=> 1 */ -module.exports = _curry2(function modulo(a, b) { return a % b; }); +var modulo = _curry2(function modulo(a, b) { return a % b; }); +export default modulo; diff --git a/src/multiply.js b/source/multiply.js similarity index 78% rename from src/multiply.js rename to source/multiply.js index 919a1be9e..13458378a 100644 --- a/src/multiply.js +++ b/source/multiply.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -21,4 +21,5 @@ var _curry2 = require('./internal/_curry2'); * triple(4); //=> 12 * R.multiply(2, 5); //=> 10 */ -module.exports = _curry2(function multiply(a, b) { return a * b; }); +var multiply = _curry2(function multiply(a, b) { return a * b; }); +export default multiply; diff --git a/src/nAry.js b/source/nAry.js similarity index 95% rename from src/nAry.js rename to source/nAry.js index a7dce50c9..f67aed2db 100644 --- a/src/nAry.js +++ b/source/nAry.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -31,7 +31,7 @@ var _curry2 = require('./internal/_curry2'); * @symb R.nAry(1, f)(a, b) = f(a) * @symb R.nAry(2, f)(a, b) = f(a, b) */ -module.exports = _curry2(function nAry(n, fn) { +var nAry = _curry2(function nAry(n, fn) { switch (n) { case 0: return function() {return fn.call(this);}; case 1: return function(a0) {return fn.call(this, a0);}; @@ -47,3 +47,4 @@ module.exports = _curry2(function nAry(n, fn) { default: throw new Error('First argument to nAry must be a non-negative integer no greater than ten'); } }); +export default nAry; diff --git a/src/negate.js b/source/negate.js similarity index 63% rename from src/negate.js rename to source/negate.js index 9f3a6f269..05c66b80e 100644 --- a/src/negate.js +++ b/source/negate.js @@ -1,4 +1,4 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; /** @@ -15,4 +15,5 @@ var _curry1 = require('./internal/_curry1'); * * R.negate(42); //=> -42 */ -module.exports = _curry1(function negate(n) { return -n; }); +var negate = _curry1(function negate(n) { return -n; }); +export default negate; diff --git a/src/none.js b/source/none.js similarity index 69% rename from src/none.js rename to source/none.js index 605d3f161..4f3402bfa 100644 --- a/src/none.js +++ b/source/none.js @@ -1,8 +1,8 @@ -var _complement = require('./internal/_complement'); -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xany = require('./internal/_xany'); -var any = require('./any'); +import _complement from './internal/_complement'; +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xany from './internal/_xany'; +import any from './any'; /** @@ -28,4 +28,5 @@ var any = require('./any'); * R.none(isEven, [1, 3, 5, 7, 9, 11]); //=> true * R.none(isOdd, [1, 3, 5, 7, 8, 11]); //=> false */ -module.exports = _curry2(_complement(_dispatchable(['any'], _xany, any))); +var none = _curry2(_complement(_dispatchable(['any'], _xany, any))); +export default none; diff --git a/src/not.js b/source/not.js similarity index 83% rename from src/not.js rename to source/not.js index a47b80e71..8a28de557 100644 --- a/src/not.js +++ b/source/not.js @@ -1,4 +1,4 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; /** @@ -20,6 +20,7 @@ var _curry1 = require('./internal/_curry1'); * R.not(0); //=> true * R.not(1); //=> false */ -module.exports = _curry1(function not(a) { +var not = _curry1(function not(a) { return !a; }); +export default not; diff --git a/src/nth.js b/source/nth.js similarity index 83% rename from src/nth.js rename to source/nth.js index c862f2b54..7e1da2fa9 100644 --- a/src/nth.js +++ b/source/nth.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var _isString = require('./internal/_isString'); +import _curry2 from './internal/_curry2'; +import _isString from './internal/_isString'; /** @@ -28,7 +28,8 @@ var _isString = require('./internal/_isString'); * @symb R.nth(0, [a, b, c]) = a * @symb R.nth(1, [a, b, c]) = b */ -module.exports = _curry2(function nth(offset, list) { +var nth = _curry2(function nth(offset, list) { var idx = offset < 0 ? list.length + offset : offset; return _isString(list) ? list.charAt(idx) : list[idx]; }); +export default nth; diff --git a/src/nthArg.js b/source/nthArg.js similarity index 76% rename from src/nthArg.js rename to source/nthArg.js index 6cf6785f4..d850f745c 100644 --- a/src/nthArg.js +++ b/source/nthArg.js @@ -1,6 +1,6 @@ -var _curry1 = require('./internal/_curry1'); -var curryN = require('./curryN'); -var nth = require('./nth'); +import _curry1 from './internal/_curry1'; +import curryN from './curryN'; +import nth from './nth'; /** @@ -21,9 +21,10 @@ var nth = require('./nth'); * @symb R.nthArg(0)(a, b, c) = a * @symb R.nthArg(1)(a, b, c) = b */ -module.exports = _curry1(function nthArg(n) { +var nthArg = _curry1(function nthArg(n) { var arity = n < 0 ? 1 : n + 1; return curryN(arity, function() { return nth(n, arguments); }); }); +export default nthArg; diff --git a/src/o.js b/source/o.js similarity index 89% rename from src/o.js rename to source/o.js index bf3c69e29..aac98844a 100644 --- a/src/o.js +++ b/source/o.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -26,6 +26,7 @@ var _curry3 = require('./internal/_curry3'); * * @symb R.o(f, g, x) = f(g(x)) */ -module.exports = _curry3(function o(f, g, x) { +var o = _curry3(function o(f, g, x) { return f(g(x)); }); +export default o; diff --git a/src/objOf.js b/source/objOf.js similarity index 83% rename from src/objOf.js rename to source/objOf.js index 2081423c9..a7fcf8b31 100644 --- a/src/objOf.js +++ b/source/objOf.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -21,8 +21,9 @@ var _curry2 = require('./internal/_curry2'); * ); * matchPhrases(['foo', 'bar', 'baz']); //=> {must: [{match_phrase: 'foo'}, {match_phrase: 'bar'}, {match_phrase: 'baz'}]} */ -module.exports = _curry2(function objOf(key, val) { +var objOf = _curry2(function objOf(key, val) { var obj = {}; obj[key] = val; return obj; }); +export default objOf; diff --git a/src/of.js b/source/of.js similarity index 79% rename from src/of.js rename to source/of.js index 5927fb954..2707e1299 100644 --- a/src/of.js +++ b/source/of.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var _of = require('./internal/_of'); +import _curry1 from './internal/_curry1'; +import _of from './internal/_of'; /** @@ -20,4 +20,5 @@ var _of = require('./internal/_of'); * R.of(null); //=> [null] * R.of([42]); //=> [[42]] */ -module.exports = _curry1(_of); +var of = _curry1(_of); +export default of; diff --git a/src/omit.js b/source/omit.js similarity index 87% rename from src/omit.js rename to source/omit.js index 6bd7cff3b..1dafc65de 100644 --- a/src/omit.js +++ b/source/omit.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** * Returns a partial copy of an object omitting the keys specified. @@ -16,7 +16,7 @@ var _curry2 = require('./internal/_curry2'); * * R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3} */ -module.exports = _curry2(function omit(names, obj) { +var omit = _curry2(function omit(names, obj) { var result = {}; var index = {}; var idx = 0; @@ -34,3 +34,4 @@ module.exports = _curry2(function omit(names, obj) { } return result; }); +export default omit; diff --git a/src/once.js b/source/once.js similarity index 85% rename from src/once.js rename to source/once.js index 57b19d15b..a49da8dee 100644 --- a/src/once.js +++ b/source/once.js @@ -1,5 +1,5 @@ -var _arity = require('./internal/_arity'); -var _curry1 = require('./internal/_curry1'); +import _arity from './internal/_arity'; +import _curry1 from './internal/_curry1'; /** @@ -21,7 +21,7 @@ var _curry1 = require('./internal/_curry1'); * addOneOnce(10); //=> 11 * addOneOnce(addOneOnce(50)); //=> 11 */ -module.exports = _curry1(function once(fn) { +var once = _curry1(function once(fn) { var called = false; var result; return _arity(fn.length, function() { @@ -33,3 +33,4 @@ module.exports = _curry1(function once(fn) { return result; }); }); +export default once; diff --git a/src/or.js b/source/or.js similarity index 84% rename from src/or.js rename to source/or.js index 62e2b6990..798ac08b4 100644 --- a/src/or.js +++ b/source/or.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -21,6 +21,7 @@ var _curry2 = require('./internal/_curry2'); * R.or(false, true); //=> true * R.or(false, false); //=> false */ -module.exports = _curry2(function or(a, b) { +var or = _curry2(function or(a, b) { return a || b; }); +export default or; diff --git a/source/over.js b/source/over.js new file mode 100644 index 000000000..8eb579ad9 --- /dev/null +++ b/source/over.js @@ -0,0 +1,38 @@ +import _curry3 from './internal/_curry3'; + +// `Identity` is a functor that holds a single value, where `map` simply +// transforms the held value with the provided function. +var Identity = function(x) { + return {value: x, map: function(f) { return Identity(f(x)); }}; +}; + + +/** + * Returns the result of "setting" the portion of the given data structure + * focused by the given lens to the result of applying the given function to + * the focused value. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig Lens s a -> (a -> a) -> s -> s + * @param {Lens} lens + * @param {*} v + * @param {*} x + * @return {*} + * @see R.prop, R.lensIndex, R.lensProp + * @example + * + * var headLens = R.lensIndex(0); + * + * R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); //=> ['FOO', 'bar', 'baz'] + */ +var over = _curry3(function over(lens, f, x) { + // The value returned by the getter function is first transformed with `f`, + // then set as the value of an `Identity`. This is then mapped over with the + // setter function of the lens. + return lens(function(y) { return Identity(f(y)); })(x).value; +}); +export default over; diff --git a/src/pair.js b/source/pair.js similarity index 70% rename from src/pair.js rename to source/pair.js index 1fdefd3dc..230155d89 100644 --- a/src/pair.js +++ b/source/pair.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -17,4 +17,5 @@ var _curry2 = require('./internal/_curry2'); * * R.pair('foo', 'bar'); //=> ['foo', 'bar'] */ -module.exports = _curry2(function pair(fst, snd) { return [fst, snd]; }); +var pair = _curry2(function pair(fst, snd) { return [fst, snd]; }); +export default pair; diff --git a/src/partial.js b/source/partial.js similarity index 83% rename from src/partial.js rename to source/partial.js index 108dbaa0f..71b2a7c94 100644 --- a/src/partial.js +++ b/source/partial.js @@ -1,5 +1,5 @@ -var _concat = require('./internal/_concat'); -var _createPartialApplicator = require('./internal/_createPartialApplicator'); +import _concat from './internal/_concat'; +import _createPartialApplicator from './internal/_createPartialApplicator'; /** @@ -30,4 +30,5 @@ var _createPartialApplicator = require('./internal/_createPartialApplicator'); * sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!' * @symb R.partial(f, [a, b])(c, d) = f(a, b, c, d) */ -module.exports = _createPartialApplicator(_concat); +var partial = _createPartialApplicator(_concat); +export default partial; diff --git a/src/partialRight.js b/source/partialRight.js similarity index 77% rename from src/partialRight.js rename to source/partialRight.js index bade2ef82..8ad42ce42 100644 --- a/src/partialRight.js +++ b/source/partialRight.js @@ -1,6 +1,6 @@ -var _concat = require('./internal/_concat'); -var _createPartialApplicator = require('./internal/_createPartialApplicator'); -var flip = require('./flip'); +import _concat from './internal/_concat'; +import _createPartialApplicator from './internal/_createPartialApplicator'; +import flip from './flip'; /** @@ -27,4 +27,5 @@ var flip = require('./flip'); * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!' * @symb R.partialRight(f, [a, b])(c, d) = f(c, d, a, b) */ -module.exports = _createPartialApplicator(flip(_concat)); +var partialRight = _createPartialApplicator(flip(_concat)); +export default partialRight; diff --git a/src/partition.js b/source/partition.js similarity index 87% rename from src/partition.js rename to source/partition.js index f99530560..8a0931ce3 100644 --- a/src/partition.js +++ b/source/partition.js @@ -1,6 +1,6 @@ -var filter = require('./filter'); -var juxt = require('./juxt'); -var reject = require('./reject'); +import filter from './filter'; +import juxt from './juxt'; +import reject from './reject'; /** @@ -27,4 +27,5 @@ var reject = require('./reject'); * R.partition(R.contains('s'), { a: 'sss', b: 'ttt', foo: 'bars' }); * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ] */ -module.exports = juxt([filter, reject]); +var partition = juxt([filter, reject]); +export default partition; diff --git a/src/path.js b/source/path.js similarity index 85% rename from src/path.js rename to source/path.js index 2ff73012f..cf8af3e0b 100644 --- a/src/path.js +++ b/source/path.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -19,7 +19,7 @@ var _curry2 = require('./internal/_curry2'); * R.path(['a', 'b'], {a: {b: 2}}); //=> 2 * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined */ -module.exports = _curry2(function path(paths, obj) { +var path = _curry2(function path(paths, obj) { var val = obj; var idx = 0; while (idx < paths.length) { @@ -31,3 +31,4 @@ module.exports = _curry2(function path(paths, obj) { } return val; }); +export default path; diff --git a/src/pathEq.js b/source/pathEq.js similarity index 84% rename from src/pathEq.js rename to source/pathEq.js index 264566edd..b19224b90 100644 --- a/src/pathEq.js +++ b/source/pathEq.js @@ -1,6 +1,6 @@ -var _curry3 = require('./internal/_curry3'); -var equals = require('./equals'); -var path = require('./path'); +import _curry3 from './internal/_curry3'; +import equals from './equals'; +import path from './path'; /** @@ -27,6 +27,7 @@ var path = require('./path'); * var isFamous = R.pathEq(['address', 'zipCode'], 90210); * R.filter(isFamous, users); //=> [ user1 ] */ -module.exports = _curry3(function pathEq(_path, val, obj) { +var pathEq = _curry3(function pathEq(_path, val, obj) { return equals(path(_path, obj), val); }); +export default pathEq; diff --git a/src/pathOr.js b/source/pathOr.js similarity index 79% rename from src/pathOr.js rename to source/pathOr.js index a87f8a72c..c4b2128fb 100644 --- a/src/pathOr.js +++ b/source/pathOr.js @@ -1,6 +1,6 @@ -var _curry3 = require('./internal/_curry3'); -var defaultTo = require('./defaultTo'); -var path = require('./path'); +import _curry3 from './internal/_curry3'; +import defaultTo from './defaultTo'; +import path from './path'; /** @@ -22,6 +22,7 @@ var path = require('./path'); * R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2 * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A" */ -module.exports = _curry3(function pathOr(d, p, obj) { +var pathOr = _curry3(function pathOr(d, p, obj) { return defaultTo(d, path(p, obj)); }); +export default pathOr; diff --git a/src/pathSatisfies.js b/source/pathSatisfies.js similarity index 76% rename from src/pathSatisfies.js rename to source/pathSatisfies.js index 01788ab4b..0f719c728 100644 --- a/src/pathSatisfies.js +++ b/source/pathSatisfies.js @@ -1,5 +1,5 @@ -var _curry3 = require('./internal/_curry3'); -var path = require('./path'); +import _curry3 from './internal/_curry3'; +import path from './path'; /** @@ -21,6 +21,7 @@ var path = require('./path'); * * R.pathSatisfies(y => y > 0, ['x', 'y'], {x: {y: 2}}); //=> true */ -module.exports = _curry3(function pathSatisfies(pred, propPath, obj) { +var pathSatisfies = _curry3(function pathSatisfies(pred, propPath, obj) { return propPath.length > 0 && pred(path(propPath, obj)); }); +export default pathSatisfies; diff --git a/src/pick.js b/source/pick.js similarity index 87% rename from src/pick.js rename to source/pick.js index 09c6d68df..5ebbb3013 100644 --- a/src/pick.js +++ b/source/pick.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -19,7 +19,7 @@ var _curry2 = require('./internal/_curry2'); * 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} */ -module.exports = _curry2(function pick(names, obj) { +var pick = _curry2(function pick(names, obj) { var result = {}; var idx = 0; while (idx < names.length) { @@ -30,3 +30,4 @@ module.exports = _curry2(function pick(names, obj) { } return result; }); +export default pick; diff --git a/src/pickAll.js b/source/pickAll.js similarity index 87% rename from src/pickAll.js rename to source/pickAll.js index f4344c797..41fdf9dc1 100644 --- a/src/pickAll.js +++ b/source/pickAll.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -19,7 +19,7 @@ var _curry2 = require('./internal/_curry2'); * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined} */ -module.exports = _curry2(function pickAll(names, obj) { +var pickAll = _curry2(function pickAll(names, obj) { var result = {}; var idx = 0; var len = names.length; @@ -30,3 +30,4 @@ module.exports = _curry2(function pickAll(names, obj) { } return result; }); +export default pickAll; diff --git a/src/pickBy.js b/source/pickBy.js similarity index 87% rename from src/pickBy.js rename to source/pickBy.js index a6a96f592..ededbeff6 100644 --- a/src/pickBy.js +++ b/source/pickBy.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -21,7 +21,7 @@ var _curry2 = require('./internal/_curry2'); * var isUpperCase = (val, key) => key.toUpperCase() === key; * R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4} */ -module.exports = _curry2(function pickBy(test, obj) { +var pickBy = _curry2(function pickBy(test, obj) { var result = {}; for (var prop in obj) { if (test(obj[prop], prop, obj)) { @@ -30,3 +30,4 @@ module.exports = _curry2(function pickBy(test, obj) { } return result; }); +export default pickBy; diff --git a/src/pipe.js b/source/pipe.js similarity index 81% rename from src/pipe.js rename to source/pipe.js index 96ce35ce3..d39adeaed 100644 --- a/src/pipe.js +++ b/source/pipe.js @@ -1,7 +1,7 @@ -var _arity = require('./internal/_arity'); -var _pipe = require('./internal/_pipe'); -var reduce = require('./reduce'); -var tail = require('./tail'); +import _arity from './internal/_arity'; +import _pipe from './internal/_pipe'; +import reduce from './reduce'; +import tail from './tail'; /** @@ -27,10 +27,10 @@ var tail = require('./tail'); * f(3, 4); // -(3^4) + 1 * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b))) */ -module.exports = function pipe() { +export default function pipe() { if (arguments.length === 0) { throw new Error('pipe requires at least one argument'); } return _arity(arguments[0].length, reduce(_pipe, arguments[0], tail(arguments))); -}; +} diff --git a/src/pipeK.js b/source/pipeK.js similarity index 91% rename from src/pipeK.js rename to source/pipeK.js index 6d0f41a1c..9d32cb28b 100644 --- a/src/pipeK.js +++ b/source/pipeK.js @@ -1,5 +1,5 @@ -var composeK = require('./composeK'); -var reverse = require('./reverse'); +import composeK from './composeK'; +import reverse from './reverse'; /** * Returns the left-to-right Kleisli composition of the provided functions, @@ -35,9 +35,9 @@ var reverse = require('./reverse'); * //=> Nothing() * @symb R.pipeK(f, g, h)(a) = R.chain(h, R.chain(g, f(a))) */ -module.exports = function pipeK() { +export default function pipeK() { if (arguments.length === 0) { throw new Error('pipeK requires at least one argument'); } return composeK.apply(this, reverse(arguments)); -}; +} diff --git a/src/pipeP.js b/source/pipeP.js similarity index 79% rename from src/pipeP.js rename to source/pipeP.js index 1d3563b56..04156cff2 100644 --- a/src/pipeP.js +++ b/source/pipeP.js @@ -1,7 +1,7 @@ -var _arity = require('./internal/_arity'); -var _pipeP = require('./internal/_pipeP'); -var reduce = require('./reduce'); -var tail = require('./tail'); +import _arity from './internal/_arity'; +import _pipeP from './internal/_pipeP'; +import reduce from './reduce'; +import tail from './tail'; /** @@ -22,10 +22,10 @@ var tail = require('./tail'); * // followersForUser :: String -> Promise [User] * var followersForUser = R.pipeP(db.getUserById, db.getFollowers); */ -module.exports = function pipeP() { +export default function pipeP() { if (arguments.length === 0) { throw new Error('pipeP requires at least one argument'); } return _arity(arguments[0].length, reduce(_pipeP, arguments[0], tail(arguments))); -}; +} diff --git a/src/pluck.js b/source/pluck.js similarity index 85% rename from src/pluck.js rename to source/pluck.js index e295a9578..443a3fc63 100644 --- a/src/pluck.js +++ b/source/pluck.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var map = require('./map'); -var prop = require('./prop'); +import _curry2 from './internal/_curry2'; +import map from './map'; +import prop from './prop'; /** @@ -28,6 +28,7 @@ var prop = require('./prop'); * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5] * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5] */ -module.exports = _curry2(function pluck(p, list) { +var pluck = _curry2(function pluck(p, list) { return map(prop(p), list); }); +export default pluck; diff --git a/src/prepend.js b/source/prepend.js similarity index 76% rename from src/prepend.js rename to source/prepend.js index 82c025eb7..6dd3510ed 100644 --- a/src/prepend.js +++ b/source/prepend.js @@ -1,5 +1,5 @@ -var _concat = require('./internal/_concat'); -var _curry2 = require('./internal/_curry2'); +import _concat from './internal/_concat'; +import _curry2 from './internal/_curry2'; /** @@ -19,6 +19,7 @@ var _curry2 = require('./internal/_curry2'); * * R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum'] */ -module.exports = _curry2(function prepend(el, list) { +var prepend = _curry2(function prepend(el, list) { return _concat([el], list); }); +export default prepend; diff --git a/src/product.js b/source/product.js similarity index 72% rename from src/product.js rename to source/product.js index 69f30f29b..67c1d4ba7 100644 --- a/src/product.js +++ b/source/product.js @@ -1,5 +1,5 @@ -var multiply = require('./multiply'); -var reduce = require('./reduce'); +import multiply from './multiply'; +import reduce from './reduce'; /** @@ -17,4 +17,5 @@ var reduce = require('./reduce'); * * R.product([2,4,6,8,100,1]); //=> 38400 */ -module.exports = reduce(multiply, 1); +var product = reduce(multiply, 1); +export default product; diff --git a/src/project.js b/source/project.js similarity index 71% rename from src/project.js rename to source/project.js index 63b5c3a2c..aa482d410 100644 --- a/src/project.js +++ b/source/project.js @@ -1,7 +1,7 @@ -var _map = require('./internal/_map'); -var identity = require('./identity'); -var pickAll = require('./pickAll'); -var useWith = require('./useWith'); +import _map from './internal/_map'; +import identity from './identity'; +import pickAll from './pickAll'; +import useWith from './useWith'; /** @@ -23,4 +23,5 @@ var useWith = require('./useWith'); * var kids = [abby, fred]; * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}] */ -module.exports = useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity +var project = useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity +export default project; diff --git a/src/prop.js b/source/prop.js similarity index 73% rename from src/prop.js rename to source/prop.js index 390ba58f6..24898f47d 100644 --- a/src/prop.js +++ b/source/prop.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var path = require('./path'); +import _curry2 from './internal/_curry2'; +import path from './path'; /** @@ -20,4 +20,6 @@ var path = require('./path'); * R.prop('x', {x: 100}); //=> 100 * R.prop('x', {}); //=> undefined */ -module.exports = _curry2(function prop(p, obj) { return path([p], obj); }); + +var prop = _curry2(function prop(p, obj) { return path([p], obj); }); +export default prop; diff --git a/src/propEq.js b/source/propEq.js similarity index 85% rename from src/propEq.js rename to source/propEq.js index 03aacfe72..a1b4f4fd7 100644 --- a/src/propEq.js +++ b/source/propEq.js @@ -1,5 +1,5 @@ -var _curry3 = require('./internal/_curry3'); -var equals = require('./equals'); +import _curry3 from './internal/_curry3'; +import equals from './equals'; /** @@ -27,6 +27,7 @@ var equals = require('./equals'); * var hasBrownHair = R.propEq('hair', 'brown'); * R.filter(hasBrownHair, kids); //=> [fred, rusty] */ -module.exports = _curry3(function propEq(name, val, obj) { +var propEq = _curry3(function propEq(name, val, obj) { return equals(val, obj[name]); }); +export default propEq; diff --git a/src/propIs.js b/source/propIs.js similarity index 79% rename from src/propIs.js rename to source/propIs.js index 0e515a912..46f31ae55 100644 --- a/src/propIs.js +++ b/source/propIs.js @@ -1,5 +1,5 @@ -var _curry3 = require('./internal/_curry3'); -var is = require('./is'); +import _curry3 from './internal/_curry3'; +import is from './is'; /** @@ -22,6 +22,7 @@ var is = require('./is'); * R.propIs(Number, 'x', {x: 'foo'}); //=> false * R.propIs(Number, 'x', {}); //=> false */ -module.exports = _curry3(function propIs(type, name, obj) { +var propIs = _curry3(function propIs(type, name, obj) { return is(type, obj[name]); }); +export default propIs; diff --git a/src/propOr.js b/source/propOr.js similarity index 85% rename from src/propOr.js rename to source/propOr.js index b91c5dc54..0828c1177 100644 --- a/src/propOr.js +++ b/source/propOr.js @@ -1,5 +1,5 @@ -var _curry3 = require('./internal/_curry3'); -var _has = require('./internal/_has'); +import _curry3 from './internal/_curry3'; +import _has from './internal/_has'; /** @@ -28,6 +28,7 @@ var _has = require('./internal/_has'); * favorite(alice); //=> undefined * favoriteWithDefault(alice); //=> 'Ramda' */ -module.exports = _curry3(function propOr(val, p, obj) { +var propOr = _curry3(function propOr(val, p, obj) { return (obj != null && _has(p, obj)) ? obj[p] : val; }); +export default propOr; diff --git a/src/propSatisfies.js b/source/propSatisfies.js similarity index 79% rename from src/propSatisfies.js rename to source/propSatisfies.js index 5fe7b0a50..3a8a37911 100644 --- a/src/propSatisfies.js +++ b/source/propSatisfies.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -20,6 +20,7 @@ var _curry3 = require('./internal/_curry3'); * * R.propSatisfies(x => x > 0, 'x', {x: 1, y: 2}); //=> true */ -module.exports = _curry3(function propSatisfies(pred, name, obj) { +var propSatisfies = _curry3(function propSatisfies(pred, name, obj) { return pred(obj[name]); }); +export default propSatisfies; diff --git a/src/props.js b/source/props.js similarity index 88% rename from src/props.js rename to source/props.js index ed588c69d..7e12f133c 100644 --- a/src/props.js +++ b/source/props.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -21,7 +21,7 @@ var _curry2 = require('./internal/_curry2'); * var fullName = R.compose(R.join(' '), R.props(['first', 'last'])); * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth' */ -module.exports = _curry2(function props(ps, obj) { +var props = _curry2(function props(ps, obj) { var len = ps.length; var out = []; var idx = 0; @@ -33,3 +33,4 @@ module.exports = _curry2(function props(ps, obj) { return out; }); +export default props; diff --git a/src/range.js b/source/range.js similarity index 81% rename from src/range.js rename to source/range.js index 23430595a..9160b2a0e 100644 --- a/src/range.js +++ b/source/range.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var _isNumber = require('./internal/_isNumber'); +import _curry2 from './internal/_curry2'; +import _isNumber from './internal/_isNumber'; /** @@ -18,7 +18,7 @@ var _isNumber = require('./internal/_isNumber'); * R.range(1, 5); //=> [1, 2, 3, 4] * R.range(50, 53); //=> [50, 51, 52] */ -module.exports = _curry2(function range(from, to) { +var range = _curry2(function range(from, to) { if (!(_isNumber(from) && _isNumber(to))) { throw new TypeError('Both arguments to range must be numbers'); } @@ -30,3 +30,4 @@ module.exports = _curry2(function range(from, to) { } return result; }); +export default range; diff --git a/src/reduce.js b/source/reduce.js similarity index 93% rename from src/reduce.js rename to source/reduce.js index 3f23253e8..94795cc01 100644 --- a/src/reduce.js +++ b/source/reduce.js @@ -1,5 +1,5 @@ -var _curry3 = require('./internal/_curry3'); -var _reduce = require('./internal/_reduce'); +import _curry3 from './internal/_curry3'; +import _reduce from './internal/_reduce'; /** @@ -48,4 +48,5 @@ var _reduce = require('./internal/_reduce'); * * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d) */ -module.exports = _curry3(_reduce); +var reduce = _curry3(_reduce); +export default reduce; diff --git a/src/reduceBy.js b/source/reduceBy.js similarity index 86% rename from src/reduceBy.js rename to source/reduceBy.js index 0e54dde45..4d5ccb388 100644 --- a/src/reduceBy.js +++ b/source/reduceBy.js @@ -1,8 +1,8 @@ -var _curryN = require('./internal/_curryN'); -var _dispatchable = require('./internal/_dispatchable'); -var _has = require('./internal/_has'); -var _reduce = require('./internal/_reduce'); -var _xreduceBy = require('./internal/_xreduceBy'); +import _curryN from './internal/_curryN'; +import _dispatchable from './internal/_dispatchable'; +import _has from './internal/_has'; +import _reduce from './internal/_reduce'; +import _xreduceBy from './internal/_xreduceBy'; /** @@ -49,7 +49,7 @@ var _xreduceBy = require('./internal/_xreduceBy'); * // 'F': ['Bart'] * // } */ -module.exports = _curryN(4, [], _dispatchable([], _xreduceBy, +var reduceBy = _curryN(4, [], _dispatchable([], _xreduceBy, function reduceBy(valueFn, valueAcc, keyFn, list) { return _reduce(function(acc, elt) { var key = keyFn(elt); @@ -57,3 +57,4 @@ module.exports = _curryN(4, [], _dispatchable([], _xreduceBy, return acc; }, {}, list); })); +export default reduceBy; diff --git a/src/reduceRight.js b/source/reduceRight.js similarity index 93% rename from src/reduceRight.js rename to source/reduceRight.js index 2feb9e37d..cf0ff4048 100644 --- a/src/reduceRight.js +++ b/source/reduceRight.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -43,7 +43,7 @@ var _curry3 = require('./internal/_curry3'); * * @symb R.reduceRight(f, a, [b, c, d]) = f(b, f(c, f(d, a))) */ -module.exports = _curry3(function reduceRight(fn, acc, list) { +var reduceRight = _curry3(function reduceRight(fn, acc, list) { var idx = list.length - 1; while (idx >= 0) { acc = fn(list[idx], acc); @@ -51,3 +51,4 @@ module.exports = _curry3(function reduceRight(fn, acc, list) { } return acc; }); +export default reduceRight; diff --git a/src/reduceWhile.js b/source/reduceWhile.js similarity index 83% rename from src/reduceWhile.js rename to source/reduceWhile.js index 4e018983f..767795323 100644 --- a/src/reduceWhile.js +++ b/source/reduceWhile.js @@ -1,6 +1,6 @@ -var _curryN = require('./internal/_curryN'); -var _reduce = require('./internal/_reduce'); -var _reduced = require('./internal/_reduced'); +import _curryN from './internal/_curryN'; +import _reduce from './internal/_reduce'; +import _reduced from './internal/_reduced'; /** @@ -32,8 +32,9 @@ var _reduced = require('./internal/_reduced'); * var ys = [2, 4, 6] * R.reduceWhile(isOdd, R.add, 111, ys); //=> 111 */ -module.exports = _curryN(4, [], function _reduceWhile(pred, fn, a, list) { +var reduceWhile = _curryN(4, [], function _reduceWhile(pred, fn, a, list) { return _reduce(function(acc, x) { return pred(acc, x) ? fn(acc, x) : _reduced(acc); }, a, list); }); +export default reduceWhile; diff --git a/src/reduced.js b/source/reduced.js similarity index 83% rename from src/reduced.js rename to source/reduced.js index a0db65a05..e2ea077c4 100644 --- a/src/reduced.js +++ b/source/reduced.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var _reduced = require('./internal/_reduced'); +import _curry1 from './internal/_curry1'; +import _reduced from './internal/_reduced'; /** * Returns a value wrapped to indicate that it is the final value of the reduce @@ -25,5 +25,5 @@ var _reduced = require('./internal/_reduced'); * [], * [1, 2, 3, 4, 5]) // [1, 2, 3] */ - -module.exports = _curry1(_reduced); +var reduced = _curry1(_reduced); +export default reduced; diff --git a/src/reject.js b/source/reject.js similarity index 77% rename from src/reject.js rename to source/reject.js index 2410dffcc..fc004a468 100644 --- a/src/reject.js +++ b/source/reject.js @@ -1,6 +1,6 @@ -var _complement = require('./internal/_complement'); -var _curry2 = require('./internal/_curry2'); -var filter = require('./filter'); +import _complement from './internal/_complement'; +import _curry2 from './internal/_curry2'; +import filter from './filter'; /** @@ -27,6 +27,7 @@ var filter = require('./filter'); * * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} */ -module.exports = _curry2(function reject(pred, filterable) { +var reject = _curry2(function reject(pred, filterable) { return filter(_complement(pred), filterable); }); +export default reject; diff --git a/src/remove.js b/source/remove.js similarity index 86% rename from src/remove.js rename to source/remove.js index 815682dc6..a8be9120a 100644 --- a/src/remove.js +++ b/source/remove.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -20,8 +20,9 @@ var _curry3 = require('./internal/_curry3'); * * R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8] */ -module.exports = _curry3(function remove(start, count, list) { +var remove = _curry3(function remove(start, count, list) { var result = Array.prototype.slice.call(list, 0); result.splice(start, count); return result; }); +export default remove; diff --git a/src/repeat.js b/source/repeat.js similarity index 80% rename from src/repeat.js rename to source/repeat.js index d33d5609d..98a122ebd 100644 --- a/src/repeat.js +++ b/source/repeat.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var always = require('./always'); -var times = require('./times'); +import _curry2 from './internal/_curry2'; +import always from './always'; +import times from './times'; /** @@ -26,6 +26,7 @@ var times = require('./times'); * @symb R.repeat(a, 1) = [a] * @symb R.repeat(a, 2) = [a, a] */ -module.exports = _curry2(function repeat(value, n) { +var repeat = _curry2(function repeat(value, n) { return times(always(value), n); }); +export default repeat; diff --git a/src/replace.js b/source/replace.js similarity index 85% rename from src/replace.js rename to source/replace.js index 1cfdfd301..d695c13cb 100644 --- a/src/replace.js +++ b/source/replace.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -21,6 +21,7 @@ var _curry3 = require('./internal/_curry3'); * // Use the "g" (global) flag to replace all occurrences: * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar' */ -module.exports = _curry3(function replace(regex, replacement, str) { +var replace = _curry3(function replace(regex, replacement, str) { return str.replace(regex, replacement); }); +export default replace; diff --git a/src/reverse.js b/source/reverse.js similarity index 82% rename from src/reverse.js rename to source/reverse.js index f3105cebb..ae191fed6 100644 --- a/src/reverse.js +++ b/source/reverse.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var _isString = require('./internal/_isString'); +import _curry1 from './internal/_curry1'; +import _isString from './internal/_isString'; /** @@ -26,7 +26,8 @@ var _isString = require('./internal/_isString'); * R.reverse('a'); //=> 'a' * R.reverse(''); //=> '' */ -module.exports = _curry1(function reverse(list) { +var reverse = _curry1(function reverse(list) { return _isString(list) ? list.split('').reverse().join('') : Array.prototype.slice.call(list, 0).reverse(); }); +export default reverse; diff --git a/src/scan.js b/source/scan.js similarity index 88% rename from src/scan.js rename to source/scan.js index 7c1d18e37..7746d6fbc 100644 --- a/src/scan.js +++ b/source/scan.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -22,7 +22,7 @@ var _curry3 = require('./internal/_curry3'); * var factorials = R.scan(R.multiply, 1, numbers); //=> [1, 1, 2, 6, 24] * @symb R.scan(f, a, [b, c]) = [a, f(a, b), f(f(a, b), c)] */ -module.exports = _curry3(function scan(fn, acc, list) { +var scan = _curry3(function scan(fn, acc, list) { var idx = 0; var len = list.length; var result = [acc]; @@ -33,3 +33,4 @@ module.exports = _curry3(function scan(fn, acc, list) { } return result; }); +export default scan; diff --git a/src/sequence.js b/source/sequence.js similarity index 80% rename from src/sequence.js rename to source/sequence.js index 2f9cfcac4..bc25f6946 100644 --- a/src/sequence.js +++ b/source/sequence.js @@ -1,8 +1,8 @@ -var _curry2 = require('./internal/_curry2'); -var ap = require('./ap'); -var map = require('./map'); -var prepend = require('./prepend'); -var reduceRight = require('./reduceRight'); +import _curry2 from './internal/_curry2'; +import ap from './ap'; +import map from './map'; +import prepend from './prepend'; +import reduceRight from './reduceRight'; /** @@ -29,10 +29,11 @@ var reduceRight = require('./reduceRight'); * R.sequence(R.of, Just([1, 2, 3])); //=> [Just(1), Just(2), Just(3)] * R.sequence(R.of, Nothing()); //=> [Nothing()] */ -module.exports = _curry2(function sequence(of, traversable) { +var sequence = _curry2(function sequence(of, traversable) { return typeof traversable.sequence === 'function' ? traversable.sequence(of) : reduceRight(function(x, acc) { return ap(map(prepend, x), acc); }, of([]), traversable); }); +export default sequence; diff --git a/src/set.js b/source/set.js similarity index 78% rename from src/set.js rename to source/set.js index a83efe91b..e47a5f44e 100644 --- a/src/set.js +++ b/source/set.js @@ -1,6 +1,6 @@ -var _curry3 = require('./internal/_curry3'); -var always = require('./always'); -var over = require('./over'); +import _curry3 from './internal/_curry3'; +import always from './always'; +import over from './over'; /** @@ -25,6 +25,7 @@ var over = require('./over'); * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} * R.set(xLens, 8, {x: 1, y: 2}); //=> {x: 8, y: 2} */ -module.exports = _curry3(function set(lens, v, x) { +var set = _curry3(function set(lens, v, x) { return over(lens, always(v), x); }); +export default set; diff --git a/src/slice.js b/source/slice.js similarity index 81% rename from src/slice.js rename to source/slice.js index 16f85b464..9ae766564 100644 --- a/src/slice.js +++ b/source/slice.js @@ -1,5 +1,5 @@ -var _checkForMethod = require('./internal/_checkForMethod'); -var _curry3 = require('./internal/_curry3'); +import _checkForMethod from './internal/_checkForMethod'; +import _curry3 from './internal/_curry3'; /** @@ -26,6 +26,7 @@ var _curry3 = require('./internal/_curry3'); * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] * R.slice(0, 3, 'ramda'); //=> 'ram' */ -module.exports = _curry3(_checkForMethod('slice', function slice(fromIndex, toIndex, list) { +var slice = _curry3(_checkForMethod('slice', function slice(fromIndex, toIndex, list) { return Array.prototype.slice.call(list, fromIndex, toIndex); })); +export default slice; diff --git a/src/sort.js b/source/sort.js similarity index 87% rename from src/sort.js rename to source/sort.js index 561e121db..789fd7c86 100644 --- a/src/sort.js +++ b/source/sort.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -21,6 +21,7 @@ var _curry2 = require('./internal/_curry2'); * var diff = function(a, b) { return a - b; }; * R.sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7] */ -module.exports = _curry2(function sort(comparator, list) { +var sort = _curry2(function sort(comparator, list) { return Array.prototype.slice.call(list, 0).sort(comparator); }); +export default sort; diff --git a/src/sortBy.js b/source/sortBy.js similarity index 90% rename from src/sortBy.js rename to source/sortBy.js index 7351e3b4a..1cf25cbca 100644 --- a/src/sortBy.js +++ b/source/sortBy.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -33,10 +33,11 @@ var _curry2 = require('./internal/_curry2'); * var people = [clara, bob, alice]; * sortByNameCaseInsensitive(people); //=> [alice, bob, clara] */ -module.exports = _curry2(function sortBy(fn, list) { +var sortBy = _curry2(function sortBy(fn, list) { return Array.prototype.slice.call(list, 0).sort(function(a, b) { var aa = fn(a); var bb = fn(b); return aa < bb ? -1 : aa > bb ? 1 : 0; }); }); +export default sortBy; diff --git a/src/sortWith.js b/source/sortWith.js similarity index 89% rename from src/sortWith.js rename to source/sortWith.js index 21bd6f39e..cedfa4a00 100644 --- a/src/sortWith.js +++ b/source/sortWith.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -33,7 +33,7 @@ var _curry2 = require('./internal/_curry2'); * ]); * ageNameSort(people); //=> [alice, clara, bob] */ -module.exports = _curry2(function sortWith(fns, list) { +var sortWith = _curry2(function sortWith(fns, list) { return Array.prototype.slice.call(list, 0).sort(function(a, b) { var result = 0; var i = 0; @@ -44,3 +44,4 @@ module.exports = _curry2(function sortWith(fns, list) { return result; }); }); +export default sortWith; diff --git a/src/split.js b/source/split.js similarity index 87% rename from src/split.js rename to source/split.js index 70c431817..52aa0be17 100644 --- a/src/split.js +++ b/source/split.js @@ -1,4 +1,4 @@ -var invoker = require('./invoker'); +import invoker from './invoker'; /** @@ -21,4 +21,5 @@ var invoker = require('./invoker'); * * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd'] */ -module.exports = invoker(1, 'split'); +var split = invoker(1, 'split'); +export default split; diff --git a/src/splitAt.js b/source/splitAt.js similarity index 77% rename from src/splitAt.js rename to source/splitAt.js index 9176e18d4..dd1d023fc 100644 --- a/src/splitAt.js +++ b/source/splitAt.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var length = require('./length'); -var slice = require('./slice'); +import _curry2 from './internal/_curry2'; +import length from './length'; +import slice from './slice'; /** @@ -21,6 +21,7 @@ var slice = require('./slice'); * R.splitAt(5, 'hello world'); //=> ['hello', ' world'] * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r'] */ -module.exports = _curry2(function splitAt(index, array) { +var splitAt = _curry2(function splitAt(index, array) { return [slice(0, index, array), slice(index, length(array), array)]; }); +export default splitAt; diff --git a/src/splitEvery.js b/source/splitEvery.js similarity index 81% rename from src/splitEvery.js rename to source/splitEvery.js index 0f0d8f9b7..75aae8caf 100644 --- a/src/splitEvery.js +++ b/source/splitEvery.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var slice = require('./slice'); +import _curry2 from './internal/_curry2'; +import slice from './slice'; /** @@ -19,7 +19,7 @@ var slice = require('./slice'); * R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); //=> [[1, 2, 3], [4, 5, 6], [7]] * R.splitEvery(3, 'foobarbaz'); //=> ['foo', 'bar', 'baz'] */ -module.exports = _curry2(function splitEvery(n, list) { +var splitEvery = _curry2(function splitEvery(n, list) { if (n <= 0) { throw new Error('First argument to splitEvery must be a positive integer'); } @@ -30,3 +30,4 @@ module.exports = _curry2(function splitEvery(n, list) { } return result; }); +export default splitEvery; diff --git a/src/splitWhen.js b/source/splitWhen.js similarity index 88% rename from src/splitWhen.js rename to source/splitWhen.js index 425525163..262ee8476 100644 --- a/src/splitWhen.js +++ b/source/splitWhen.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -20,7 +20,7 @@ var _curry2 = require('./internal/_curry2'); * * R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]); //=> [[1], [2, 3, 1, 2, 3]] */ -module.exports = _curry2(function splitWhen(pred, list) { +var splitWhen = _curry2(function splitWhen(pred, list) { var idx = 0; var len = list.length; var prefix = []; @@ -32,3 +32,4 @@ module.exports = _curry2(function splitWhen(pred, list) { return [prefix, Array.prototype.slice.call(list, idx)]; }); +export default splitWhen; diff --git a/src/startsWith.js b/source/startsWith.js similarity index 75% rename from src/startsWith.js rename to source/startsWith.js index 59a065d5b..6f12264d2 100644 --- a/src/startsWith.js +++ b/source/startsWith.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var equals = require('./equals'); -var take = require('./take'); +import _curry2 from './internal/_curry2'; +import equals from './equals'; +import take from './take'; /** * Checks if a list starts with the provided values @@ -21,6 +21,7 @@ var take = require('./take'); * R.startsWith(['a'], ['a', 'b', 'c']) //=> true * R.startsWith(['b'], ['a', 'b', 'c']) //=> false */ -module.exports = _curry2(function(prefix, list) { +var startsWith = _curry2(function(prefix, list) { return equals(take(prefix.length, list), prefix); }); +export default startsWith; diff --git a/src/subtract.js b/source/subtract.js similarity index 83% rename from src/subtract.js rename to source/subtract.js index 8ee120161..4605965fb 100644 --- a/src/subtract.js +++ b/source/subtract.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -24,6 +24,7 @@ var _curry2 = require('./internal/_curry2'); * complementaryAngle(30); //=> 60 * complementaryAngle(72); //=> 18 */ -module.exports = _curry2(function subtract(a, b) { +var subtract = _curry2(function subtract(a, b) { return Number(a) - Number(b); }); +export default subtract; diff --git a/src/sum.js b/source/sum.js similarity index 75% rename from src/sum.js rename to source/sum.js index 309d8e632..e2e663b58 100644 --- a/src/sum.js +++ b/source/sum.js @@ -1,5 +1,5 @@ -var add = require('./add'); -var reduce = require('./reduce'); +import add from './add'; +import reduce from './reduce'; /** @@ -17,4 +17,5 @@ var reduce = require('./reduce'); * * R.sum([2,4,6,8,100,1]); //=> 121 */ -module.exports = reduce(add, 0); +var sum = reduce(add, 0); +export default sum; diff --git a/src/symmetricDifference.js b/source/symmetricDifference.js similarity index 74% rename from src/symmetricDifference.js rename to source/symmetricDifference.js index 28ba2177b..2ee4278e1 100644 --- a/src/symmetricDifference.js +++ b/source/symmetricDifference.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var concat = require('./concat'); -var difference = require('./difference'); +import _curry2 from './internal/_curry2'; +import concat from './concat'; +import difference from './difference'; /** @@ -21,6 +21,7 @@ var difference = require('./difference'); * R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); //=> [1,2,7,6,5] * R.symmetricDifference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5,1,2] */ -module.exports = _curry2(function symmetricDifference(list1, list2) { +var symmetricDifference = _curry2(function symmetricDifference(list1, list2) { return concat(difference(list1, list2), difference(list2, list1)); }); +export default symmetricDifference; diff --git a/src/symmetricDifferenceWith.js b/source/symmetricDifferenceWith.js similarity index 79% rename from src/symmetricDifferenceWith.js rename to source/symmetricDifferenceWith.js index 077898af1..8916b066b 100644 --- a/src/symmetricDifferenceWith.js +++ b/source/symmetricDifferenceWith.js @@ -1,6 +1,6 @@ -var _curry3 = require('./internal/_curry3'); -var concat = require('./concat'); -var differenceWith = require('./differenceWith'); +import _curry3 from './internal/_curry3'; +import concat from './concat'; +import differenceWith from './differenceWith'; /** @@ -25,6 +25,7 @@ var differenceWith = require('./differenceWith'); * var l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}]; * R.symmetricDifferenceWith(eqA, l1, l2); //=> [{a: 1}, {a: 2}, {a: 5}, {a: 6}] */ -module.exports = _curry3(function symmetricDifferenceWith(pred, list1, list2) { +var symmetricDifferenceWith = _curry3(function symmetricDifferenceWith(pred, list1, list2) { return concat(differenceWith(pred, list1, list2), differenceWith(pred, list2, list1)); }); +export default symmetricDifferenceWith; diff --git a/src/tail.js b/source/tail.js similarity index 75% rename from src/tail.js rename to source/tail.js index d43b05c14..0b9f8e303 100644 --- a/src/tail.js +++ b/source/tail.js @@ -1,6 +1,6 @@ -var _checkForMethod = require('./internal/_checkForMethod'); -var _curry1 = require('./internal/_curry1'); -var slice = require('./slice'); +import _checkForMethod from './internal/_checkForMethod'; +import _curry1 from './internal/_curry1'; +import slice from './slice'; /** @@ -30,4 +30,5 @@ var slice = require('./slice'); * R.tail('a'); //=> '' * R.tail(''); //=> '' */ -module.exports = _curry1(_checkForMethod('tail', slice(1, Infinity))); +var tail = _curry1(_checkForMethod('tail', slice(1, Infinity))); +export default tail; diff --git a/src/take.js b/source/take.js similarity index 83% rename from src/take.js rename to source/take.js index 38427f3fb..c15e892ee 100644 --- a/src/take.js +++ b/source/take.js @@ -1,7 +1,7 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xtake = require('./internal/_xtake'); -var slice = require('./slice'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xtake from './internal/_xtake'; +import slice from './slice'; /** @@ -47,6 +47,7 @@ var slice = require('./slice'); * @symb R.take(1, [a, b]) = [a] * @symb R.take(2, [a, b]) = [a, b] */ -module.exports = _curry2(_dispatchable(['take'], _xtake, function take(n, xs) { +var take = _curry2(_dispatchable(['take'], _xtake, function take(n, xs) { return slice(0, n < 0 ? Infinity : n, xs); })); +export default take; diff --git a/src/takeLast.js b/source/takeLast.js similarity index 84% rename from src/takeLast.js rename to source/takeLast.js index ebf403fa6..67d9fc96a 100644 --- a/src/takeLast.js +++ b/source/takeLast.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var drop = require('./drop'); +import _curry2 from './internal/_curry2'; +import drop from './drop'; /** @@ -24,6 +24,7 @@ var drop = require('./drop'); * R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] * R.takeLast(3, 'ramda'); //=> 'mda' */ -module.exports = _curry2(function takeLast(n, xs) { +var takeLast = _curry2(function takeLast(n, xs) { return drop(n >= 0 ? xs.length - n : 0, xs); }); +export default takeLast; diff --git a/src/takeLastWhile.js b/source/takeLastWhile.js similarity index 85% rename from src/takeLastWhile.js rename to source/takeLastWhile.js index e2c7bc23e..6827fd3e8 100644 --- a/src/takeLastWhile.js +++ b/source/takeLastWhile.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var slice = require('./slice'); +import _curry2 from './internal/_curry2'; +import slice from './slice'; /** @@ -27,10 +27,11 @@ var slice = require('./slice'); * * R.takeLastWhile(x => x !== 'R' , 'Ramda'); //=> 'amda' */ -module.exports = _curry2(function takeLastWhile(fn, xs) { +var takeLastWhile = _curry2(function takeLastWhile(fn, xs) { var idx = xs.length - 1; while (idx >= 0 && fn(xs[idx])) { idx -= 1; } return slice(idx + 1, Infinity, xs); }); +export default takeLastWhile; diff --git a/src/takeWhile.js b/source/takeWhile.js similarity index 79% rename from src/takeWhile.js rename to source/takeWhile.js index ad7ac7b26..36068fbc4 100644 --- a/src/takeWhile.js +++ b/source/takeWhile.js @@ -1,7 +1,7 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xtakeWhile = require('./internal/_xtakeWhile'); -var slice = require('./slice'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xtakeWhile from './internal/_xtakeWhile'; +import slice from './slice'; /** @@ -33,7 +33,7 @@ var slice = require('./slice'); * * R.takeWhile(x => x !== 'd' , 'Ramda'); //=> 'Ram' */ -module.exports = _curry2(_dispatchable(['takeWhile'], _xtakeWhile, function takeWhile(fn, xs) { +var takeWhile = _curry2(_dispatchable(['takeWhile'], _xtakeWhile, function takeWhile(fn, xs) { var idx = 0; var len = xs.length; while (idx < len && fn(xs[idx])) { @@ -41,3 +41,4 @@ module.exports = _curry2(_dispatchable(['takeWhile'], _xtakeWhile, function take } return slice(0, idx, xs); })); +export default takeWhile; diff --git a/src/tap.js b/source/tap.js similarity index 72% rename from src/tap.js rename to source/tap.js index f0f6f6c2e..cb7381205 100644 --- a/src/tap.js +++ b/source/tap.js @@ -1,6 +1,6 @@ -var _curry2 = require('./internal/_curry2'); -var _dispatchable = require('./internal/_dispatchable'); -var _xtap = require('./internal/_xtap'); +import _curry2 from './internal/_curry2'; +import _dispatchable from './internal/_dispatchable'; +import _xtap from './internal/_xtap'; /** @@ -23,7 +23,8 @@ var _xtap = require('./internal/_xtap'); * // logs 'x is 100' * @symb R.tap(f, a) = a */ -module.exports = _curry2(_dispatchable([], _xtap, function tap(fn, x) { +var tap = _curry2(_dispatchable([], _xtap, function tap(fn, x) { fn(x); return x; })); +export default tap; diff --git a/src/test.js b/source/test.js similarity index 69% rename from src/test.js rename to source/test.js index ae78540cc..7045c66f7 100644 --- a/src/test.js +++ b/source/test.js @@ -1,7 +1,7 @@ -var _cloneRegExp = require('./internal/_cloneRegExp'); -var _curry2 = require('./internal/_curry2'); -var _isRegExp = require('./internal/_isRegExp'); -var toString = require('./toString'); +import _cloneRegExp from './internal/_cloneRegExp'; +import _curry2 from './internal/_curry2'; +import _isRegExp from './internal/_isRegExp'; +import toString from './toString'; /** @@ -21,9 +21,10 @@ var toString = require('./toString'); * R.test(/^x/, 'xyz'); //=> true * R.test(/^y/, 'xyz'); //=> false */ -module.exports = _curry2(function test(pattern, str) { +var test = _curry2(function test(pattern, str) { if (!_isRegExp(pattern)) { throw new TypeError('‘test’ requires a value of type RegExp as its first argument; received ' + toString(pattern)); } return _cloneRegExp(pattern).test(str); }); +export default test; diff --git a/src/times.js b/source/times.js similarity index 90% rename from src/times.js rename to source/times.js index 49af25469..1a682eea8 100644 --- a/src/times.js +++ b/source/times.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -24,7 +24,7 @@ var _curry2 = require('./internal/_curry2'); * @symb R.times(f, 1) = [f(0)] * @symb R.times(f, 2) = [f(0), f(1)] */ -module.exports = _curry2(function times(fn, n) { +var times = _curry2(function times(fn, n) { var len = Number(n); var idx = 0; var list; @@ -39,3 +39,4 @@ module.exports = _curry2(function times(fn, n) { } return list; }); +export default times; diff --git a/src/toLower.js b/source/toLower.js similarity index 75% rename from src/toLower.js rename to source/toLower.js index eede0fee0..70ddefbef 100644 --- a/src/toLower.js +++ b/source/toLower.js @@ -1,4 +1,4 @@ -var invoker = require('./invoker'); +import invoker from './invoker'; /** @@ -16,4 +16,5 @@ var invoker = require('./invoker'); * * R.toLower('XYZ'); //=> 'xyz' */ -module.exports = invoker(0, 'toLowerCase'); +var toLower = invoker(0, 'toLowerCase'); +export default toLower; diff --git a/src/toPairs.js b/source/toPairs.js similarity index 82% rename from src/toPairs.js rename to source/toPairs.js index 033228d48..3d06e608d 100644 --- a/src/toPairs.js +++ b/source/toPairs.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var _has = require('./internal/_has'); +import _curry1 from './internal/_curry1'; +import _has from './internal/_has'; /** @@ -20,7 +20,7 @@ var _has = require('./internal/_has'); * * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]] */ -module.exports = _curry1(function toPairs(obj) { +var toPairs = _curry1(function toPairs(obj) { var pairs = []; for (var prop in obj) { if (_has(prop, obj)) { @@ -29,3 +29,4 @@ module.exports = _curry1(function toPairs(obj) { } return pairs; }); +export default toPairs; diff --git a/src/toPairsIn.js b/source/toPairsIn.js similarity index 86% rename from src/toPairsIn.js rename to source/toPairsIn.js index 3f1b2eb2f..5923253a8 100644 --- a/src/toPairsIn.js +++ b/source/toPairsIn.js @@ -1,4 +1,4 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; /** @@ -22,10 +22,11 @@ var _curry1 = require('./internal/_curry1'); * var f = new F(); * R.toPairsIn(f); //=> [['x','X'], ['y','Y']] */ -module.exports = _curry1(function toPairsIn(obj) { +var toPairsIn = _curry1(function toPairsIn(obj) { var pairs = []; for (var prop in obj) { pairs[pairs.length] = [prop, obj[prop]]; } return pairs; }); +export default toPairsIn; diff --git a/src/toString.js b/source/toString.js similarity index 86% rename from src/toString.js rename to source/toString.js index e9aa9043d..b907ab570 100644 --- a/src/toString.js +++ b/source/toString.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var _toString = require('./internal/_toString'); +import _curry1 from './internal/_curry1'; +import _toString from './internal/_toString'; /** @@ -38,4 +38,5 @@ var _toString = require('./internal/_toString'); * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}' * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")' */ -module.exports = _curry1(function toString(val) { return _toString(val, []); }); +var toString = _curry1(function toString(val) { return _toString(val, []); }); +export default toString; diff --git a/src/toUpper.js b/source/toUpper.js similarity index 75% rename from src/toUpper.js rename to source/toUpper.js index a72f4f258..2476564d9 100644 --- a/src/toUpper.js +++ b/source/toUpper.js @@ -1,4 +1,4 @@ -var invoker = require('./invoker'); +import invoker from './invoker'; /** @@ -16,4 +16,5 @@ var invoker = require('./invoker'); * * R.toUpper('abc'); //=> 'ABC' */ -module.exports = invoker(0, 'toUpperCase'); +var toUpper = invoker(0, 'toUpperCase'); +export default toUpper; diff --git a/src/transduce.js b/source/transduce.js similarity index 92% rename from src/transduce.js rename to source/transduce.js index b1ee30044..967308da3 100644 --- a/src/transduce.js +++ b/source/transduce.js @@ -1,6 +1,6 @@ -var _reduce = require('./internal/_reduce'); -var _xwrap = require('./internal/_xwrap'); -var curryN = require('./curryN'); +import _reduce from './internal/_reduce'; +import _xwrap from './internal/_xwrap'; +import curryN from './curryN'; /** @@ -50,6 +50,7 @@ var curryN = require('./curryN'); * var firstOddTransducer = R.compose(R.filter(isOdd), R.take(1)); * R.transduce(firstOddTransducer, R.flip(R.append), [], R.range(0, 100)); //=> [1] */ -module.exports = curryN(4, function transduce(xf, fn, acc, list) { +var transduce = curryN(4, function transduce(xf, fn, acc, list) { return _reduce(xf(typeof fn === 'function' ? _xwrap(fn) : fn), acc, list); }); +export default transduce; diff --git a/src/transpose.js b/source/transpose.js similarity index 90% rename from src/transpose.js rename to source/transpose.js index ca2ad6e65..ae5fa9017 100644 --- a/src/transpose.js +++ b/source/transpose.js @@ -1,4 +1,4 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; /** @@ -25,7 +25,7 @@ var _curry1 = require('./internal/_curry1'); * @symb R.transpose([[a, b], [c, d]]) = [[a, c], [b, d]] * @symb R.transpose([[a, b], [c]]) = [[a, c], [b]] */ -module.exports = _curry1(function transpose(outerlist) { +var transpose = _curry1(function transpose(outerlist) { var i = 0; var result = []; while (i < outerlist.length) { @@ -42,3 +42,4 @@ module.exports = _curry1(function transpose(outerlist) { } return result; }); +export default transpose; diff --git a/src/traverse.js b/source/traverse.js similarity index 85% rename from src/traverse.js rename to source/traverse.js index d25d83e31..433aa254c 100644 --- a/src/traverse.js +++ b/source/traverse.js @@ -1,6 +1,6 @@ -var _curry3 = require('./internal/_curry3'); -var map = require('./map'); -var sequence = require('./sequence'); +import _curry3 from './internal/_curry3'; +import map from './map'; +import sequence from './sequence'; /** @@ -29,8 +29,9 @@ var sequence = require('./sequence'); * R.traverse(Maybe.of, safeDiv(10), [2, 4, 5]); //=> Just([5, 2.5, 2]) * R.traverse(Maybe.of, safeDiv(10), [2, 0, 5]); //=> Nothing */ -module.exports = _curry3(function traverse(of, f, traversable) { +var traverse = _curry3(function traverse(of, f, traversable) { return typeof traversable['fantasy-land/traverse'] === 'function' ? traversable['fantasy-land/traverse'](f, of) : sequence(of, map(f, traversable)); }); +export default traverse; diff --git a/src/trim.js b/source/trim.js similarity index 51% rename from src/trim.js rename to source/trim.js index fb9e5f346..f74b27838 100644 --- a/src/trim.js +++ b/source/trim.js @@ -1,6 +1,11 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; +var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + + '\u2029\uFEFF'; +var zeroWidth = '\u200b'; +var hasProtoTrim = (typeof String.prototype.trim === 'function'); /** * Removes (strips) whitespace from both ends of the string. * @@ -16,21 +21,14 @@ var _curry1 = require('./internal/_curry1'); * R.trim(' xyz '); //=> 'xyz' * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z'] */ -module.exports = (function() { - var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + - '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + - '\u2029\uFEFF'; - var zeroWidth = '\u200b'; - var hasProtoTrim = (typeof String.prototype.trim === 'function'); - if (!hasProtoTrim || (ws.trim() || !zeroWidth.trim())) { - return _curry1(function trim(str) { +var _trim = !hasProtoTrim || (ws.trim() || !zeroWidth.trim()) ? + function trim(str) { var beginRx = new RegExp('^[' + ws + '][' + ws + ']*'); var endRx = new RegExp('[' + ws + '][' + ws + ']*$'); return str.replace(beginRx, '').replace(endRx, ''); - }); - } else { - return _curry1(function trim(str) { + } : + function trim(str) { return str.trim(); - }); - } -}()); + }; +var trim = _curry1(_trim); +export default trim; diff --git a/src/tryCatch.js b/source/tryCatch.js similarity index 84% rename from src/tryCatch.js rename to source/tryCatch.js index 799603ca2..80d79b86e 100644 --- a/src/tryCatch.js +++ b/source/tryCatch.js @@ -1,6 +1,6 @@ -var _arity = require('./internal/_arity'); -var _concat = require('./internal/_concat'); -var _curry2 = require('./internal/_curry2'); +import _arity from './internal/_arity'; +import _concat from './internal/_concat'; +import _curry2 from './internal/_curry2'; /** @@ -24,7 +24,7 @@ var _curry2 = require('./internal/_curry2'); * R.tryCatch(R.prop('x'), R.F)({x: true}); //=> true * R.tryCatch(R.prop('x'), R.F)(null); //=> false */ -module.exports = _curry2(function _tryCatch(tryer, catcher) { +var tryCatch = _curry2(function _tryCatch(tryer, catcher) { return _arity(tryer.length, function() { try { return tryer.apply(this, arguments); @@ -33,3 +33,4 @@ module.exports = _curry2(function _tryCatch(tryer, catcher) { } }); }); +export default tryCatch; diff --git a/src/type.js b/source/type.js similarity index 89% rename from src/type.js rename to source/type.js index 74c3b16f5..278eeacd5 100644 --- a/src/type.js +++ b/source/type.js @@ -1,4 +1,4 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; /** @@ -26,8 +26,9 @@ var _curry1 = require('./internal/_curry1'); * R.type(() => {}); //=> "Function" * R.type(undefined); //=> "Undefined" */ -module.exports = _curry1(function type(val) { +var type = _curry1(function type(val) { return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1); }); +export default type; diff --git a/src/unapply.js b/source/unapply.js similarity index 87% rename from src/unapply.js rename to source/unapply.js index b988cbc6e..d114f0a23 100644 --- a/src/unapply.js +++ b/source/unapply.js @@ -1,4 +1,4 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; /** @@ -25,8 +25,9 @@ var _curry1 = require('./internal/_curry1'); * R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]' * @symb R.unapply(f)(a, b) = f([a, b]) */ -module.exports = _curry1(function unapply(fn) { +var unapply = _curry1(function unapply(fn) { return function() { return fn(Array.prototype.slice.call(arguments, 0)); }; }); +export default unapply; diff --git a/src/unary.js b/source/unary.js similarity index 87% rename from src/unary.js rename to source/unary.js index b21c6d001..0eaa22040 100644 --- a/src/unary.js +++ b/source/unary.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var nAry = require('./nAry'); +import _curry1 from './internal/_curry1'; +import nAry from './nAry'; /** @@ -30,6 +30,7 @@ var nAry = require('./nAry'); * takesOneArg(1, 2); //=> [1, undefined] * @symb R.unary(f)(a, b, c) = f(a) */ -module.exports = _curry1(function unary(fn) { +var unary = _curry1(function unary(fn) { return nAry(1, fn); }); +export default unary; diff --git a/src/uncurryN.js b/source/uncurryN.js similarity index 86% rename from src/uncurryN.js rename to source/uncurryN.js index 8611e4f20..fe7d4807f 100644 --- a/src/uncurryN.js +++ b/source/uncurryN.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var curryN = require('./curryN'); +import _curry2 from './internal/_curry2'; +import curryN from './curryN'; /** @@ -21,7 +21,7 @@ var curryN = require('./curryN'); * var uncurriedAddFour = R.uncurryN(4, addFour); * uncurriedAddFour(1, 2, 3, 4); //=> 10 */ -module.exports = _curry2(function uncurryN(depth, fn) { +var uncurryN = _curry2(function uncurryN(depth, fn) { return curryN(depth, function() { var currentDepth = 1; var value = fn; @@ -36,3 +36,4 @@ module.exports = _curry2(function uncurryN(depth, fn) { return value; }); }); +export default uncurryN; diff --git a/src/unfold.js b/source/unfold.js similarity index 91% rename from src/unfold.js rename to source/unfold.js index d3af149f0..3128c5c26 100644 --- a/src/unfold.js +++ b/source/unfold.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -26,7 +26,7 @@ var _curry2 = require('./internal/_curry2'); * R.unfold(f, 10); //=> [-10, -20, -30, -40, -50] * @symb R.unfold(f, x) = [f(x)[0], f(f(x)[1])[0], f(f(f(x)[1])[1])[0], ...] */ -module.exports = _curry2(function unfold(fn, seed) { +var unfold = _curry2(function unfold(fn, seed) { var pair = fn(seed); var result = []; while (pair && pair.length) { @@ -35,3 +35,4 @@ module.exports = _curry2(function unfold(fn, seed) { } return result; }); +export default unfold; diff --git a/src/union.js b/source/union.js similarity index 67% rename from src/union.js rename to source/union.js index 669298f8c..c047fd51d 100644 --- a/src/union.js +++ b/source/union.js @@ -1,7 +1,7 @@ -var _concat = require('./internal/_concat'); -var _curry2 = require('./internal/_curry2'); -var compose = require('./compose'); -var uniq = require('./uniq'); +import _concat from './internal/_concat'; +import _curry2 from './internal/_curry2'; +import compose from './compose'; +import uniq from './uniq'; /** @@ -21,4 +21,5 @@ var uniq = require('./uniq'); * * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4] */ -module.exports = _curry2(compose(uniq, _concat)); +var union = _curry2(compose(uniq, _concat)); +export default union; diff --git a/src/unionWith.js b/source/unionWith.js similarity index 79% rename from src/unionWith.js rename to source/unionWith.js index b78fa5617..000800723 100644 --- a/src/unionWith.js +++ b/source/unionWith.js @@ -1,6 +1,6 @@ -var _concat = require('./internal/_concat'); -var _curry3 = require('./internal/_curry3'); -var uniqWith = require('./uniqWith'); +import _concat from './internal/_concat'; +import _curry3 from './internal/_curry3'; +import uniqWith from './uniqWith'; /** @@ -25,6 +25,7 @@ var uniqWith = require('./uniqWith'); * var l2 = [{a: 1}, {a: 4}]; * R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}] */ -module.exports = _curry3(function unionWith(pred, list1, list2) { +var unionWith = _curry3(function unionWith(pred, list1, list2) { return uniqWith(pred, _concat(list1, list2)); }); +export default unionWith; diff --git a/src/uniq.js b/source/uniq.js similarity index 80% rename from src/uniq.js rename to source/uniq.js index 1501a8641..6a25211a5 100644 --- a/src/uniq.js +++ b/source/uniq.js @@ -1,5 +1,5 @@ -var identity = require('./identity'); -var uniqBy = require('./uniqBy'); +import identity from './identity'; +import uniqBy from './uniqBy'; /** @@ -19,4 +19,5 @@ var uniqBy = require('./uniqBy'); * R.uniq([1, '1']); //=> [1, '1'] * R.uniq([[42], [42]]); //=> [[42]] */ -module.exports = uniqBy(identity); +var uniq = uniqBy(identity); +export default uniq; diff --git a/src/uniqBy.js b/source/uniqBy.js similarity index 86% rename from src/uniqBy.js rename to source/uniqBy.js index 1ada181a4..a66ec6fc9 100644 --- a/src/uniqBy.js +++ b/source/uniqBy.js @@ -1,5 +1,5 @@ -var _Set = require('./internal/_Set'); -var _curry2 = require('./internal/_curry2'); +import _Set from './internal/_Set'; +import _curry2 from './internal/_curry2'; /** @@ -20,7 +20,7 @@ var _curry2 = require('./internal/_curry2'); * * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10] */ -module.exports = _curry2(function uniqBy(fn, list) { +var uniqBy = _curry2(function uniqBy(fn, list) { var set = new _Set(); var result = []; var idx = 0; @@ -36,3 +36,4 @@ module.exports = _curry2(function uniqBy(fn, list) { } return result; }); +export default uniqBy; diff --git a/src/uniqWith.js b/source/uniqWith.js similarity index 85% rename from src/uniqWith.js rename to source/uniqWith.js index 1df904b23..a14dcd25d 100644 --- a/src/uniqWith.js +++ b/source/uniqWith.js @@ -1,5 +1,5 @@ -var _containsWith = require('./internal/_containsWith'); -var _curry2 = require('./internal/_curry2'); +import _containsWith from './internal/_containsWith'; +import _curry2 from './internal/_curry2'; /** @@ -24,7 +24,7 @@ var _curry2 = require('./internal/_curry2'); * R.uniqWith(strEq)([1, '1', 1]); //=> [1] * R.uniqWith(strEq)(['1', 1, 1]); //=> ['1'] */ -module.exports = _curry2(function uniqWith(pred, list) { +var uniqWith = _curry2(function uniqWith(pred, list) { var idx = 0; var len = list.length; var result = []; @@ -38,3 +38,4 @@ module.exports = _curry2(function uniqWith(pred, list) { } return result; }); +export default uniqWith; diff --git a/src/unless.js b/source/unless.js similarity index 88% rename from src/unless.js rename to source/unless.js index 0676611fc..da249fdb5 100644 --- a/src/unless.js +++ b/source/unless.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -25,6 +25,7 @@ var _curry3 = require('./internal/_curry3'); * safeInc(null); //=> null * safeInc(1); //=> 2 */ -module.exports = _curry3(function unless(pred, whenFalseFn, x) { +var unless = _curry3(function unless(pred, whenFalseFn, x) { return pred(x) ? x : whenFalseFn(x); }); +export default unless; diff --git a/src/unnest.js b/source/unnest.js similarity index 77% rename from src/unnest.js rename to source/unnest.js index 6562d0a60..9e391d39e 100644 --- a/src/unnest.js +++ b/source/unnest.js @@ -1,5 +1,5 @@ -var _identity = require('./internal/_identity'); -var chain = require('./chain'); +import _identity from './internal/_identity'; +import chain from './chain'; /** @@ -19,4 +19,5 @@ var chain = require('./chain'); * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]] * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6] */ -module.exports = chain(_identity); +var unnest = chain(_identity); +export default unnest; diff --git a/src/until.js b/source/until.js similarity index 86% rename from src/until.js rename to source/until.js index 8c09c9351..2aa28d6ab 100644 --- a/src/until.js +++ b/source/until.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -20,10 +20,11 @@ var _curry3 = require('./internal/_curry3'); * * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128 */ -module.exports = _curry3(function until(pred, fn, init) { +var until = _curry3(function until(pred, fn, init) { var val = init; while (!pred(val)) { val = fn(val); } return val; }); +export default until; diff --git a/src/update.js b/source/update.js similarity index 81% rename from src/update.js rename to source/update.js index 467826565..a651ef4fc 100644 --- a/src/update.js +++ b/source/update.js @@ -1,6 +1,6 @@ -var _curry3 = require('./internal/_curry3'); -var adjust = require('./adjust'); -var always = require('./always'); +import _curry3 from './internal/_curry3'; +import adjust from './adjust'; +import always from './always'; /** @@ -25,6 +25,7 @@ var always = require('./always'); * @symb R.update(0, a, [b, c]) = [a, c] * @symb R.update(1, a, [b, c]) = [b, a] */ -module.exports = _curry3(function update(idx, x, list) { +var update = _curry3(function update(idx, x, list) { return adjust(always(x), idx, list); }); +export default update; diff --git a/src/useWith.js b/source/useWith.js similarity index 91% rename from src/useWith.js rename to source/useWith.js index 0be22423e..d429bbf2a 100644 --- a/src/useWith.js +++ b/source/useWith.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var curryN = require('./curryN'); +import _curry2 from './internal/_curry2'; +import curryN from './curryN'; /** @@ -31,7 +31,7 @@ var curryN = require('./curryN'); * R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32 * @symb R.useWith(f, [g, h])(a, b) = f(g(a), h(b)) */ -module.exports = _curry2(function useWith(fn, transformers) { +var useWith = _curry2(function useWith(fn, transformers) { return curryN(transformers.length, function() { var args = []; var idx = 0; @@ -42,3 +42,4 @@ module.exports = _curry2(function useWith(fn, transformers) { return fn.apply(this, args.concat(Array.prototype.slice.call(arguments, transformers.length))); }); }); +export default useWith; diff --git a/src/values.js b/source/values.js similarity index 83% rename from src/values.js rename to source/values.js index 519f7e69a..b9a99c3ce 100644 --- a/src/values.js +++ b/source/values.js @@ -1,5 +1,5 @@ -var _curry1 = require('./internal/_curry1'); -var keys = require('./keys'); +import _curry1 from './internal/_curry1'; +import keys from './keys'; /** @@ -19,7 +19,7 @@ var keys = require('./keys'); * * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3] */ -module.exports = _curry1(function values(obj) { +var values = _curry1(function values(obj) { var props = keys(obj); var len = props.length; var vals = []; @@ -30,3 +30,4 @@ module.exports = _curry1(function values(obj) { } return vals; }); +export default values; diff --git a/src/valuesIn.js b/source/valuesIn.js similarity index 86% rename from src/valuesIn.js rename to source/valuesIn.js index 6a0abe97c..e4bc738df 100644 --- a/src/valuesIn.js +++ b/source/valuesIn.js @@ -1,4 +1,4 @@ -var _curry1 = require('./internal/_curry1'); +import _curry1 from './internal/_curry1'; /** @@ -22,7 +22,7 @@ var _curry1 = require('./internal/_curry1'); * var f = new F(); * R.valuesIn(f); //=> ['X', 'Y'] */ -module.exports = _curry1(function valuesIn(obj) { +var valuesIn = _curry1(function valuesIn(obj) { var prop; var vs = []; for (prop in obj) { @@ -30,3 +30,4 @@ module.exports = _curry1(function valuesIn(obj) { } return vs; }); +export default valuesIn; diff --git a/src/view.js b/source/view.js similarity index 53% rename from src/view.js rename to source/view.js index fc020e90f..5969a6569 100644 --- a/src/view.js +++ b/source/view.js @@ -1,6 +1,11 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; +// `Const` is a functor that effectively ignores the function given to `map`. +var Const = function(x) { + return {value: x, 'fantasy-land/map': function() { return this; }}; +}; + /** * Returns a "view" of the given data structure, determined by the given lens. * The lens's focus determines which portion of the data structure is visible. @@ -22,15 +27,9 @@ var _curry2 = require('./internal/_curry2'); * R.view(xLens, {x: 1, y: 2}); //=> 1 * R.view(xLens, {x: 4, y: 2}); //=> 4 */ -module.exports = (function() { - // `Const` is a functor that effectively ignores the function given to `map`. - var Const = function(x) { - return {value: x, 'fantasy-land/map': function() { return this; }}; - }; - - return _curry2(function view(lens, x) { - // Using `Const` effectively ignores the setter function of the `lens`, - // leaving the value returned by the getter function unmodified. - return lens(Const)(x).value; - }); -}()); +var view = _curry2(function view(lens, x) { + // Using `Const` effectively ignores the setter function of the `lens`, + // leaving the value returned by the getter function unmodified. + return lens(Const)(x).value; +}); +export default view; diff --git a/src/when.js b/source/when.js similarity index 90% rename from src/when.js rename to source/when.js index 2b53f2c60..d515907da 100644 --- a/src/when.js +++ b/source/when.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -29,6 +29,7 @@ var _curry3 = require('./internal/_curry3'); * truncate('12345'); //=> '12345' * truncate('0123456789ABC'); //=> '0123456789…' */ -module.exports = _curry3(function when(pred, whenTrueFn, x) { +var when = _curry3(function when(pred, whenTrueFn, x) { return pred(x) ? whenTrueFn(x) : x; }); +export default when; diff --git a/src/where.js b/source/where.js similarity index 90% rename from src/where.js rename to source/where.js index b66360e5f..1add324f2 100644 --- a/src/where.js +++ b/source/where.js @@ -1,5 +1,5 @@ -var _curry2 = require('./internal/_curry2'); -var _has = require('./internal/_has'); +import _curry2 from './internal/_curry2'; +import _has from './internal/_has'; /** @@ -37,7 +37,7 @@ var _has = require('./internal/_has'); * pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false * pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false */ -module.exports = _curry2(function where(spec, testObj) { +var where = _curry2(function where(spec, testObj) { for (var prop in spec) { if (_has(prop, spec) && !spec[prop](testObj[prop])) { return false; @@ -45,3 +45,4 @@ module.exports = _curry2(function where(spec, testObj) { } return true; }); +export default where; diff --git a/src/whereEq.js b/source/whereEq.js similarity index 81% rename from src/whereEq.js rename to source/whereEq.js index 7bd234c5e..a3f5d75db 100644 --- a/src/whereEq.js +++ b/source/whereEq.js @@ -1,7 +1,7 @@ -var _curry2 = require('./internal/_curry2'); -var equals = require('./equals'); -var map = require('./map'); -var where = require('./where'); +import _curry2 from './internal/_curry2'; +import equals from './equals'; +import map from './map'; +import where from './where'; /** @@ -32,6 +32,7 @@ var where = require('./where'); * pred({a: 1, b: 2, c: 3}); //=> true * pred({a: 1, b: 1}); //=> false */ -module.exports = _curry2(function whereEq(spec, testObj) { +var whereEq = _curry2(function whereEq(spec, testObj) { return where(map(equals, spec), testObj); }); +export default whereEq; diff --git a/src/without.js b/source/without.js similarity index 74% rename from src/without.js rename to source/without.js index d7f9d1e50..8a9597e6a 100644 --- a/src/without.js +++ b/source/without.js @@ -1,7 +1,7 @@ -var _contains = require('./internal/_contains'); -var _curry2 = require('./internal/_curry2'); -var flip = require('./flip'); -var reject = require('./reject'); +import _contains from './internal/_contains'; +import _curry2 from './internal/_curry2'; +import flip from './flip'; +import reject from './reject'; /** @@ -23,6 +23,7 @@ var reject = require('./reject'); * * R.without([1, 2], [1, 2, 1, 3, 4]); //=> [3, 4] */ -module.exports = _curry2(function(xs, list) { +var without = _curry2(function(xs, list) { return reject(flip(_contains)(xs), list); }); +export default without; diff --git a/src/xprod.js b/source/xprod.js similarity index 83% rename from src/xprod.js rename to source/xprod.js index 569a8345b..948606e86 100644 --- a/src/xprod.js +++ b/source/xprod.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -19,7 +19,7 @@ var _curry2 = require('./internal/_curry2'); * R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] * @symb R.xprod([a, b], [c, d]) = [[a, c], [a, d], [b, c], [b, d]] */ -module.exports = _curry2(function xprod(a, b) { // = xprodWith(prepend); (takes about 3 times as long...) +var xprod = _curry2(function xprod(a, b) { // = xprodWith(prepend); (takes about 3 times as long...) var idx = 0; var ilen = a.length; var j; @@ -35,3 +35,4 @@ module.exports = _curry2(function xprod(a, b) { // = xprodWith(prepend); (takes } return result; }); +export default xprod; diff --git a/src/zip.js b/source/zip.js similarity index 89% rename from src/zip.js rename to source/zip.js index 299c1ef6b..07b1bda50 100644 --- a/src/zip.js +++ b/source/zip.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -20,7 +20,7 @@ var _curry2 = require('./internal/_curry2'); * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']] * @symb R.zip([a, b, c], [d, e, f]) = [[a, d], [b, e], [c, f]] */ -module.exports = _curry2(function zip(a, b) { +var zip = _curry2(function zip(a, b) { var rv = []; var idx = 0; var len = Math.min(a.length, b.length); @@ -30,3 +30,4 @@ module.exports = _curry2(function zip(a, b) { } return rv; }); +export default zip; diff --git a/src/zipObj.js b/source/zipObj.js similarity index 87% rename from src/zipObj.js rename to source/zipObj.js index 7a69811fb..240e496dd 100644 --- a/src/zipObj.js +++ b/source/zipObj.js @@ -1,4 +1,4 @@ -var _curry2 = require('./internal/_curry2'); +import _curry2 from './internal/_curry2'; /** @@ -18,7 +18,7 @@ var _curry2 = require('./internal/_curry2'); * * R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3} */ -module.exports = _curry2(function zipObj(keys, values) { +var zipObj = _curry2(function zipObj(keys, values) { var idx = 0; var len = Math.min(keys.length, values.length); var out = {}; @@ -28,3 +28,4 @@ module.exports = _curry2(function zipObj(keys, values) { } return out; }); +export default zipObj; diff --git a/src/zipWith.js b/source/zipWith.js similarity index 89% rename from src/zipWith.js rename to source/zipWith.js index 2f0aa4d8f..b78eabb87 100644 --- a/src/zipWith.js +++ b/source/zipWith.js @@ -1,4 +1,4 @@ -var _curry3 = require('./internal/_curry3'); +import _curry3 from './internal/_curry3'; /** @@ -25,7 +25,7 @@ var _curry3 = require('./internal/_curry3'); * //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')] * @symb R.zipWith(fn, [a, b, c], [d, e, f]) = [fn(a, d), fn(b, e), fn(c, f)] */ -module.exports = _curry3(function zipWith(fn, a, b) { +var zipWith = _curry3(function zipWith(fn, a, b) { var rv = []; var idx = 0; var len = Math.min(a.length, b.length); @@ -35,3 +35,4 @@ module.exports = _curry3(function zipWith(fn, a, b) { } return rv; }); +export default zipWith; diff --git a/src/internal/_Set.js b/src/internal/_Set.js deleted file mode 100644 index 98966c65b..000000000 --- a/src/internal/_Set.js +++ /dev/null @@ -1,171 +0,0 @@ -var _contains = require('./_contains'); - - -// A simple Set type that honours R.equals semantics -module.exports = (function() { - function _Set() { - /* globals Set */ - this._nativeSet = typeof Set === 'function' ? new Set() : null; - this._items = {}; - } - - // until we figure out why jsdoc chokes on this - // @param item The item to add to the Set - // @returns {boolean} true if the item did not exist prior, otherwise false - // - _Set.prototype.add = function(item) { - return !hasOrAdd(item, true, this); - }; - - // - // @param item The item to check for existence in the Set - // @returns {boolean} true if the item exists in the Set, otherwise false - // - _Set.prototype.has = function(item) { - return hasOrAdd(item, false, this); - }; - - // - // Combines the logic for checking whether an item is a member of the set and - // for adding a new item to the set. - // - // @param item The item to check or add to the Set instance. - // @param shouldAdd If true, the item will be added to the set if it doesn't - // already exist. - // @param set The set instance to check or add to. - // @return {boolean} true if the item already existed, otherwise false. - // - function hasOrAdd(item, shouldAdd, set) { - var type = typeof item; - var prevSize, newSize; - switch (type) { - case 'string': - case 'number': - // distinguish between +0 and -0 - if (item === 0 && 1 / item === -Infinity) { - if (set._items['-0']) { - return true; - } else { - if (shouldAdd) { - set._items['-0'] = true; - } - return false; - } - } - // these types can all utilise the native Set - if (set._nativeSet !== null) { - if (shouldAdd) { - prevSize = set._nativeSet.size; - set._nativeSet.add(item); - newSize = set._nativeSet.size; - return newSize === prevSize; - } else { - return set._nativeSet.has(item); - } - } else { - if (!(type in set._items)) { - if (shouldAdd) { - set._items[type] = {}; - set._items[type][item] = true; - } - return false; - } else if (item in set._items[type]) { - return true; - } else { - if (shouldAdd) { - set._items[type][item] = true; - } - return false; - } - } - - case 'boolean': - // set._items['boolean'] holds a two element array - // representing [ falseExists, trueExists ] - if (type in set._items) { - var bIdx = item ? 1 : 0; - if (set._items[type][bIdx]) { - return true; - } else { - if (shouldAdd) { - set._items[type][bIdx] = true; - } - return false; - } - } else { - if (shouldAdd) { - set._items[type] = item ? [false, true] : [true, false]; - } - return false; - } - - case 'function': - // compare functions for reference equality - if (set._nativeSet !== null) { - if (shouldAdd) { - prevSize = set._nativeSet.size; - set._nativeSet.add(item); - newSize = set._nativeSet.size; - return newSize === prevSize; - } else { - return set._nativeSet.has(item); - } - } else { - if (!(type in set._items)) { - if (shouldAdd) { - set._items[type] = [item]; - } - return false; - } - if (!_contains(item, set._items[type])) { - if (shouldAdd) { - set._items[type].push(item); - } - return false; - } - return true; - } - - case 'undefined': - if (set._items[type]) { - return true; - } else { - if (shouldAdd) { - set._items[type] = true; - } - return false; - } - - case 'object': - if (item === null) { - if (!set._items['null']) { - if (shouldAdd) { - set._items['null'] = true; - } - return false; - } - return true; - } - /* falls through */ - default: - // reduce the search size of heterogeneous sets by creating buckets - // for each type. - type = Object.prototype.toString.call(item); - if (!(type in set._items)) { - if (shouldAdd) { - set._items[type] = [item]; - } - return false; - } - // scan through all previously applied items - if (!_contains(item, set._items[type])) { - if (shouldAdd) { - set._items[type].push(item); - } - return false; - } - return true; - } - } - return _Set; -}()); diff --git a/src/internal/_contains.js b/src/internal/_contains.js deleted file mode 100644 index 9478d9bf0..000000000 --- a/src/internal/_contains.js +++ /dev/null @@ -1,6 +0,0 @@ -var _indexOf = require('./_indexOf'); - - -module.exports = function _contains(a, list) { - return _indexOf(list, a, 0) >= 0; -}; diff --git a/src/internal/_dropLast.js b/src/internal/_dropLast.js deleted file mode 100644 index f8634f497..000000000 --- a/src/internal/_dropLast.js +++ /dev/null @@ -1,5 +0,0 @@ -var take = require('../take'); - -module.exports = function dropLast(n, xs) { - return take(n < xs.length ? xs.length - n : 0, xs); -}; diff --git a/src/internal/_equals.js b/src/internal/_equals.js deleted file mode 100644 index 84401f0f3..000000000 --- a/src/internal/_equals.js +++ /dev/null @@ -1,161 +0,0 @@ -var _arrayFromIterator = require('./_arrayFromIterator'); -var _containsWith = require('./_containsWith'); -var _functionName = require('./_functionName'); -var _has = require('./_has'); -var identical = require('../identical'); -var keys = require('../keys'); -var type = require('../type'); - -module.exports = (function() { - /** - * private _uniqContentEquals function. - * That function is checking equality of 2 iterator contents with 2 assumptions - * - iterators lengths are the same - * - iterators values are unique - * - * false-positive result will be returned for comparision of, e.g. - * - [1,2,3] and [1,2,3,4] - * - [1,1,1] and [1,2,3] - * */ - - function _uniqContentEquals(aIterator, bIterator, stackA, stackB) { - var a = _arrayFromIterator(aIterator); - var b = _arrayFromIterator(bIterator); - - function eq(_a, _b) { - return _equals(_a, _b, stackA.slice(), stackB.slice()); - } - - // if *a* array contains any element that is not included in *b* - return !_containsWith(function(b, aItem) { - return !_containsWith(eq, aItem, b); - }, b, a); - } - - function _equals(a, b, stackA, stackB) { - if (identical(a, b)) { - return true; - } - - var typeA = type(a); - - if (typeA !== type(b)) { - return false; - } - - if (a == null || b == null) { - return false; - } - - if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') { - return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && - typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a); - } - - if (typeof a.equals === 'function' || typeof b.equals === 'function') { - return typeof a.equals === 'function' && a.equals(b) && - typeof b.equals === 'function' && b.equals(a); - } - - switch (typeA) { - case 'Arguments': - case 'Array': - case 'Object': - if (typeof a.constructor === 'function' && - _functionName(a.constructor) === 'Promise') { - return a === b; - } - break; - case 'Boolean': - case 'Number': - case 'String': - if (!(typeof a === typeof b && identical(a.valueOf(), b.valueOf()))) { - return false; - } - break; - case 'Date': - if (!identical(a.valueOf(), b.valueOf())) { - return false; - } - break; - case 'Error': - return a.name === b.name && a.message === b.message; - case 'RegExp': - if (!(a.source === b.source && - a.global === b.global && - a.ignoreCase === b.ignoreCase && - a.multiline === b.multiline && - a.sticky === b.sticky && - a.unicode === b.unicode)) { - return false; - } - break; - } - - var idx = stackA.length - 1; - while (idx >= 0) { - if (stackA[idx] === a) { - return stackB[idx] === b; - } - idx -= 1; - } - - switch (typeA) { - case 'Map': - if (a.size !== b.size) { - return false; - } - - return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b])); - case 'Set': - if (a.size !== b.size) { - return false; - } - - return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b])); - case 'Arguments': - case 'Array': - case 'Object': - case 'Boolean': - case 'Number': - case 'String': - case 'Date': - case 'Error': - case 'RegExp': - case 'Int8Array': - case 'Uint8Array': - case 'Uint8ClampedArray': - case 'Int16Array': - case 'Uint16Array': - case 'Int32Array': - case 'Uint32Array': - case 'Float32Array': - case 'Float64Array': - case 'ArrayBuffer': - break; - default: - // Values of other types are only equal if identical. - return false; - } - - var keysA = keys(a); - if (keysA.length !== keys(b).length) { - return false; - } - - var extendedStackA = stackA.concat([a]); - var extendedStackB = stackB.concat([b]); - - idx = keysA.length - 1; - while (idx >= 0) { - var key = keysA[idx]; - if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) { - return false; - } - idx -= 1; - } - return true; - } - - return _equals; -}()); diff --git a/src/internal/_flatCat.js b/src/internal/_flatCat.js deleted file mode 100644 index 63cb47496..000000000 --- a/src/internal/_flatCat.js +++ /dev/null @@ -1,32 +0,0 @@ -var _forceReduced = require('./_forceReduced'); -var _isArrayLike = require('./_isArrayLike'); -var _reduce = require('./_reduce'); -var _xfBase = require('./_xfBase'); - -module.exports = (function() { - var preservingReduced = function(xf) { - return { - '@@transducer/init': _xfBase.init, - '@@transducer/result': function(result) { - return xf['@@transducer/result'](result); - }, - '@@transducer/step': function(result, input) { - var ret = xf['@@transducer/step'](result, input); - return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret; - } - }; - }; - - return function _xcat(xf) { - var rxf = preservingReduced(xf); - return { - '@@transducer/init': _xfBase.init, - '@@transducer/result': function(result) { - return rxf['@@transducer/result'](result); - }, - '@@transducer/step': function(result, input) { - return !_isArrayLike(input) ? _reduce(rxf, result, [input]) : _reduce(rxf, result, input); - } - }; - }; -}()); diff --git a/src/internal/_identity.js b/src/internal/_identity.js deleted file mode 100644 index 6bb23f4ce..000000000 --- a/src/internal/_identity.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = function _identity(x) { return x; }; diff --git a/src/internal/_of.js b/src/internal/_of.js deleted file mode 100644 index 073116d9f..000000000 --- a/src/internal/_of.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = function _of(x) { return [x]; }; diff --git a/src/internal/_reduce.js b/src/internal/_reduce.js deleted file mode 100644 index a7461adb1..000000000 --- a/src/internal/_reduce.js +++ /dev/null @@ -1,61 +0,0 @@ -var _isArrayLike = require('./_isArrayLike'); -var _xwrap = require('./_xwrap'); -var bind = require('../bind'); - - -module.exports = (function() { - function _arrayReduce(xf, acc, list) { - var idx = 0; - var len = list.length; - while (idx < len) { - acc = xf['@@transducer/step'](acc, list[idx]); - if (acc && acc['@@transducer/reduced']) { - acc = acc['@@transducer/value']; - break; - } - idx += 1; - } - return xf['@@transducer/result'](acc); - } - - function _iterableReduce(xf, acc, iter) { - var step = iter.next(); - while (!step.done) { - acc = xf['@@transducer/step'](acc, step.value); - if (acc && acc['@@transducer/reduced']) { - acc = acc['@@transducer/value']; - break; - } - step = iter.next(); - } - return xf['@@transducer/result'](acc); - } - - function _methodReduce(xf, acc, obj, methodName) { - return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc)); - } - - var symIterator = (typeof Symbol !== 'undefined') ? Symbol.iterator : '@@iterator'; - return function _reduce(fn, acc, list) { - if (typeof fn === 'function') { - fn = _xwrap(fn); - } - if (_isArrayLike(list)) { - return _arrayReduce(fn, acc, list); - } - if (typeof list['fantasy-land/reduce'] === 'function') { - return _methodReduce(fn, acc, list, 'fantasy-land/reduce'); - } - if (list[symIterator] != null) { - return _iterableReduce(fn, acc, list[symIterator]()); - } - if (typeof list.next === 'function') { - return _iterableReduce(fn, acc, list); - } - if (typeof list.reduce === 'function') { - return _methodReduce(fn, acc, list, 'reduce'); - } - - throw new TypeError('reduce: list must be array or iterable'); - }; -}()); diff --git a/src/internal/_stepCat.js b/src/internal/_stepCat.js deleted file mode 100644 index 8a8da9c43..000000000 --- a/src/internal/_stepCat.js +++ /dev/null @@ -1,48 +0,0 @@ -var _assign = require('./_assign'); -var _identity = require('./_identity'); -var _isArrayLike = require('./_isArrayLike'); -var _isTransformer = require('./_isTransformer'); -var objOf = require('../objOf'); - - -module.exports = (function() { - var _stepCatArray = { - '@@transducer/init': Array, - '@@transducer/step': function(xs, x) { - xs.push(x); - return xs; - }, - '@@transducer/result': _identity - }; - var _stepCatString = { - '@@transducer/init': String, - '@@transducer/step': function(a, b) { return a + b; }, - '@@transducer/result': _identity - }; - var _stepCatObject = { - '@@transducer/init': Object, - '@@transducer/step': function(result, input) { - return _assign( - result, - _isArrayLike(input) ? objOf(input[0], input[1]) : input - ); - }, - '@@transducer/result': _identity - }; - - return function _stepCat(obj) { - if (_isTransformer(obj)) { - return obj; - } - if (_isArrayLike(obj)) { - return _stepCatArray; - } - if (typeof obj === 'string') { - return _stepCatString; - } - if (typeof obj === 'object') { - return _stepCatObject; - } - throw new Error('Cannot create transformer for ' + obj); - }; -}()); diff --git a/src/internal/_toISOString.js b/src/internal/_toISOString.js deleted file mode 100644 index 25126a143..000000000 --- a/src/internal/_toISOString.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Polyfill from . - */ -module.exports = (function() { - var pad = function pad(n) { return (n < 10 ? '0' : '') + n; }; - - return typeof Date.prototype.toISOString === 'function' ? - function _toISOString(d) { - return d.toISOString(); - } : - function _toISOString(d) { - return ( - d.getUTCFullYear() + '-' + - pad(d.getUTCMonth() + 1) + '-' + - pad(d.getUTCDate()) + 'T' + - pad(d.getUTCHours()) + ':' + - pad(d.getUTCMinutes()) + ':' + - pad(d.getUTCSeconds()) + '.' + - (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z' - ); - }; -}()); diff --git a/src/internal/_xall.js b/src/internal/_xall.js deleted file mode 100644 index ab827decd..000000000 --- a/src/internal/_xall.js +++ /dev/null @@ -1,28 +0,0 @@ -var _curry2 = require('./_curry2'); -var _reduced = require('./_reduced'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XAll(f, xf) { - this.xf = xf; - this.f = f; - this.all = true; - } - XAll.prototype['@@transducer/init'] = _xfBase.init; - XAll.prototype['@@transducer/result'] = function(result) { - if (this.all) { - result = this.xf['@@transducer/step'](result, true); - } - return this.xf['@@transducer/result'](result); - }; - XAll.prototype['@@transducer/step'] = function(result, input) { - if (!this.f(input)) { - this.all = false; - result = _reduced(this.xf['@@transducer/step'](result, false)); - } - return result; - }; - - return _curry2(function _xall(f, xf) { return new XAll(f, xf); }); -}()); diff --git a/src/internal/_xany.js b/src/internal/_xany.js deleted file mode 100644 index 94711872c..000000000 --- a/src/internal/_xany.js +++ /dev/null @@ -1,28 +0,0 @@ -var _curry2 = require('./_curry2'); -var _reduced = require('./_reduced'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XAny(f, xf) { - this.xf = xf; - this.f = f; - this.any = false; - } - XAny.prototype['@@transducer/init'] = _xfBase.init; - XAny.prototype['@@transducer/result'] = function(result) { - if (!this.any) { - result = this.xf['@@transducer/step'](result, false); - } - return this.xf['@@transducer/result'](result); - }; - XAny.prototype['@@transducer/step'] = function(result, input) { - if (this.f(input)) { - this.any = true; - result = _reduced(this.xf['@@transducer/step'](result, true)); - } - return result; - }; - - return _curry2(function _xany(f, xf) { return new XAny(f, xf); }); -}()); diff --git a/src/internal/_xaperture.js b/src/internal/_xaperture.js deleted file mode 100644 index 32f156044..000000000 --- a/src/internal/_xaperture.js +++ /dev/null @@ -1,36 +0,0 @@ -var _concat = require('./_concat'); -var _curry2 = require('./_curry2'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XAperture(n, xf) { - this.xf = xf; - this.pos = 0; - this.full = false; - this.acc = new Array(n); - } - XAperture.prototype['@@transducer/init'] = _xfBase.init; - XAperture.prototype['@@transducer/result'] = function(result) { - this.acc = null; - return this.xf['@@transducer/result'](result); - }; - XAperture.prototype['@@transducer/step'] = function(result, input) { - this.store(input); - return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result; - }; - XAperture.prototype.store = function(input) { - this.acc[this.pos] = input; - this.pos += 1; - if (this.pos === this.acc.length) { - this.pos = 0; - this.full = true; - } - }; - XAperture.prototype.getCopy = function() { - return _concat(Array.prototype.slice.call(this.acc, this.pos), - Array.prototype.slice.call(this.acc, 0, this.pos)); - }; - - return _curry2(function _xaperture(n, xf) { return new XAperture(n, xf); }); -}()); diff --git a/src/internal/_xchain.js b/src/internal/_xchain.js deleted file mode 100644 index e2f21b5cb..000000000 --- a/src/internal/_xchain.js +++ /dev/null @@ -1,8 +0,0 @@ -var _curry2 = require('./_curry2'); -var _flatCat = require('./_flatCat'); -var map = require('../map'); - - -module.exports = _curry2(function _xchain(f, xf) { - return map(f, _flatCat(xf)); -}); diff --git a/src/internal/_xdrop.js b/src/internal/_xdrop.js deleted file mode 100644 index 8dad359ee..000000000 --- a/src/internal/_xdrop.js +++ /dev/null @@ -1,21 +0,0 @@ -var _curry2 = require('./_curry2'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XDrop(n, xf) { - this.xf = xf; - this.n = n; - } - XDrop.prototype['@@transducer/init'] = _xfBase.init; - XDrop.prototype['@@transducer/result'] = _xfBase.result; - XDrop.prototype['@@transducer/step'] = function(result, input) { - if (this.n > 0) { - this.n -= 1; - return result; - } - return this.xf['@@transducer/step'](result, input); - }; - - return _curry2(function _xdrop(n, xf) { return new XDrop(n, xf); }); -}()); diff --git a/src/internal/_xdropLast.js b/src/internal/_xdropLast.js deleted file mode 100644 index cee40ed5b..000000000 --- a/src/internal/_xdropLast.js +++ /dev/null @@ -1,34 +0,0 @@ -var _curry2 = require('./_curry2'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XDropLast(n, xf) { - this.xf = xf; - this.pos = 0; - this.full = false; - this.acc = new Array(n); - } - XDropLast.prototype['@@transducer/init'] = _xfBase.init; - XDropLast.prototype['@@transducer/result'] = function(result) { - this.acc = null; - return this.xf['@@transducer/result'](result); - }; - XDropLast.prototype['@@transducer/step'] = function(result, input) { - if (this.full) { - result = this.xf['@@transducer/step'](result, this.acc[this.pos]); - } - this.store(input); - return result; - }; - XDropLast.prototype.store = function(input) { - this.acc[this.pos] = input; - this.pos += 1; - if (this.pos === this.acc.length) { - this.pos = 0; - this.full = true; - } - }; - - return _curry2(function _xdropLast(n, xf) { return new XDropLast(n, xf); }); -}()); diff --git a/src/internal/_xdropLastWhile.js b/src/internal/_xdropLastWhile.js deleted file mode 100644 index 7cf089010..000000000 --- a/src/internal/_xdropLastWhile.js +++ /dev/null @@ -1,35 +0,0 @@ -var _curry2 = require('./_curry2'); -var _reduce = require('./_reduce'); -var _xfBase = require('./_xfBase'); - -module.exports = (function() { - function XDropLastWhile(fn, xf) { - this.f = fn; - this.retained = []; - this.xf = xf; - } - XDropLastWhile.prototype['@@transducer/init'] = _xfBase.init; - XDropLastWhile.prototype['@@transducer/result'] = function(result) { - this.retained = null; - return this.xf['@@transducer/result'](result); - }; - XDropLastWhile.prototype['@@transducer/step'] = function(result, input) { - return this.f(input) ? this.retain(result, input) - : this.flush(result, input); - }; - XDropLastWhile.prototype.flush = function(result, input) { - result = _reduce( - this.xf['@@transducer/step'], - result, - this.retained - ); - this.retained = []; - return this.xf['@@transducer/step'](result, input); - }; - XDropLastWhile.prototype.retain = function(result, input) { - this.retained.push(input); - return result; - }; - - return _curry2(function _xdropLastWhile(fn, xf) { return new XDropLastWhile(fn, xf); }); -}()); diff --git a/src/internal/_xdropRepeatsWith.js b/src/internal/_xdropRepeatsWith.js deleted file mode 100644 index 58240c113..000000000 --- a/src/internal/_xdropRepeatsWith.js +++ /dev/null @@ -1,27 +0,0 @@ -var _curry2 = require('./_curry2'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XDropRepeatsWith(pred, xf) { - this.xf = xf; - this.pred = pred; - this.lastValue = undefined; - this.seenFirstValue = false; - } - - XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init; - XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result; - XDropRepeatsWith.prototype['@@transducer/step'] = function(result, input) { - var sameAsLast = false; - if (!this.seenFirstValue) { - this.seenFirstValue = true; - } else if (this.pred(this.lastValue, input)) { - sameAsLast = true; - } - this.lastValue = input; - return sameAsLast ? result : this.xf['@@transducer/step'](result, input); - }; - - return _curry2(function _xdropRepeatsWith(pred, xf) { return new XDropRepeatsWith(pred, xf); }); -}()); diff --git a/src/internal/_xdropWhile.js b/src/internal/_xdropWhile.js deleted file mode 100644 index 529a97379..000000000 --- a/src/internal/_xdropWhile.js +++ /dev/null @@ -1,23 +0,0 @@ -var _curry2 = require('./_curry2'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XDropWhile(f, xf) { - this.xf = xf; - this.f = f; - } - XDropWhile.prototype['@@transducer/init'] = _xfBase.init; - XDropWhile.prototype['@@transducer/result'] = _xfBase.result; - XDropWhile.prototype['@@transducer/step'] = function(result, input) { - if (this.f) { - if (this.f(input)) { - return result; - } - this.f = null; - } - return this.xf['@@transducer/step'](result, input); - }; - - return _curry2(function _xdropWhile(f, xf) { return new XDropWhile(f, xf); }); -}()); diff --git a/src/internal/_xfilter.js b/src/internal/_xfilter.js deleted file mode 100644 index ed04700a5..000000000 --- a/src/internal/_xfilter.js +++ /dev/null @@ -1,17 +0,0 @@ -var _curry2 = require('./_curry2'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XFilter(f, xf) { - this.xf = xf; - this.f = f; - } - XFilter.prototype['@@transducer/init'] = _xfBase.init; - XFilter.prototype['@@transducer/result'] = _xfBase.result; - XFilter.prototype['@@transducer/step'] = function(result, input) { - return this.f(input) ? this.xf['@@transducer/step'](result, input) : result; - }; - - return _curry2(function _xfilter(f, xf) { return new XFilter(f, xf); }); -}()); diff --git a/src/internal/_xfind.js b/src/internal/_xfind.js deleted file mode 100644 index d14850e94..000000000 --- a/src/internal/_xfind.js +++ /dev/null @@ -1,28 +0,0 @@ -var _curry2 = require('./_curry2'); -var _reduced = require('./_reduced'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XFind(f, xf) { - this.xf = xf; - this.f = f; - this.found = false; - } - XFind.prototype['@@transducer/init'] = _xfBase.init; - XFind.prototype['@@transducer/result'] = function(result) { - if (!this.found) { - result = this.xf['@@transducer/step'](result, void 0); - } - return this.xf['@@transducer/result'](result); - }; - XFind.prototype['@@transducer/step'] = function(result, input) { - if (this.f(input)) { - this.found = true; - result = _reduced(this.xf['@@transducer/step'](result, input)); - } - return result; - }; - - return _curry2(function _xfind(f, xf) { return new XFind(f, xf); }); -}()); diff --git a/src/internal/_xfindIndex.js b/src/internal/_xfindIndex.js deleted file mode 100644 index 3c204e56e..000000000 --- a/src/internal/_xfindIndex.js +++ /dev/null @@ -1,30 +0,0 @@ -var _curry2 = require('./_curry2'); -var _reduced = require('./_reduced'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XFindIndex(f, xf) { - this.xf = xf; - this.f = f; - this.idx = -1; - this.found = false; - } - XFindIndex.prototype['@@transducer/init'] = _xfBase.init; - XFindIndex.prototype['@@transducer/result'] = function(result) { - if (!this.found) { - result = this.xf['@@transducer/step'](result, -1); - } - return this.xf['@@transducer/result'](result); - }; - XFindIndex.prototype['@@transducer/step'] = function(result, input) { - this.idx += 1; - if (this.f(input)) { - this.found = true; - result = _reduced(this.xf['@@transducer/step'](result, this.idx)); - } - return result; - }; - - return _curry2(function _xfindIndex(f, xf) { return new XFindIndex(f, xf); }); -}()); diff --git a/src/internal/_xfindLast.js b/src/internal/_xfindLast.js deleted file mode 100644 index 5ab31c10a..000000000 --- a/src/internal/_xfindLast.js +++ /dev/null @@ -1,22 +0,0 @@ -var _curry2 = require('./_curry2'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XFindLast(f, xf) { - this.xf = xf; - this.f = f; - } - XFindLast.prototype['@@transducer/init'] = _xfBase.init; - XFindLast.prototype['@@transducer/result'] = function(result) { - return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.last)); - }; - XFindLast.prototype['@@transducer/step'] = function(result, input) { - if (this.f(input)) { - this.last = input; - } - return result; - }; - - return _curry2(function _xfindLast(f, xf) { return new XFindLast(f, xf); }); -}()); diff --git a/src/internal/_xfindLastIndex.js b/src/internal/_xfindLastIndex.js deleted file mode 100644 index a1e10aeb3..000000000 --- a/src/internal/_xfindLastIndex.js +++ /dev/null @@ -1,25 +0,0 @@ -var _curry2 = require('./_curry2'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XFindLastIndex(f, xf) { - this.xf = xf; - this.f = f; - this.idx = -1; - this.lastIdx = -1; - } - XFindLastIndex.prototype['@@transducer/init'] = _xfBase.init; - XFindLastIndex.prototype['@@transducer/result'] = function(result) { - return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.lastIdx)); - }; - XFindLastIndex.prototype['@@transducer/step'] = function(result, input) { - this.idx += 1; - if (this.f(input)) { - this.lastIdx = this.idx; - } - return result; - }; - - return _curry2(function _xfindLastIndex(f, xf) { return new XFindLastIndex(f, xf); }); -}()); diff --git a/src/internal/_xmap.js b/src/internal/_xmap.js deleted file mode 100644 index 3d276a65a..000000000 --- a/src/internal/_xmap.js +++ /dev/null @@ -1,17 +0,0 @@ -var _curry2 = require('./_curry2'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XMap(f, xf) { - this.xf = xf; - this.f = f; - } - XMap.prototype['@@transducer/init'] = _xfBase.init; - XMap.prototype['@@transducer/result'] = _xfBase.result; - XMap.prototype['@@transducer/step'] = function(result, input) { - return this.xf['@@transducer/step'](result, this.f(input)); - }; - - return _curry2(function _xmap(f, xf) { return new XMap(f, xf); }); -}()); diff --git a/src/internal/_xreduceBy.js b/src/internal/_xreduceBy.js deleted file mode 100644 index 667ded43b..000000000 --- a/src/internal/_xreduceBy.js +++ /dev/null @@ -1,40 +0,0 @@ -var _curryN = require('./_curryN'); -var _has = require('./_has'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XReduceBy(valueFn, valueAcc, keyFn, xf) { - this.valueFn = valueFn; - this.valueAcc = valueAcc; - this.keyFn = keyFn; - this.xf = xf; - this.inputs = {}; - } - XReduceBy.prototype['@@transducer/init'] = _xfBase.init; - XReduceBy.prototype['@@transducer/result'] = function(result) { - var key; - for (key in this.inputs) { - if (_has(key, this.inputs)) { - result = this.xf['@@transducer/step'](result, this.inputs[key]); - if (result['@@transducer/reduced']) { - result = result['@@transducer/value']; - break; - } - } - } - this.inputs = null; - return this.xf['@@transducer/result'](result); - }; - XReduceBy.prototype['@@transducer/step'] = function(result, input) { - var key = this.keyFn(input); - this.inputs[key] = this.inputs[key] || [key, this.valueAcc]; - this.inputs[key][1] = this.valueFn(this.inputs[key][1], input); - return result; - }; - - return _curryN(4, [], - function _xreduceBy(valueFn, valueAcc, keyFn, xf) { - return new XReduceBy(valueFn, valueAcc, keyFn, xf); - }); -}()); diff --git a/src/internal/_xtake.js b/src/internal/_xtake.js deleted file mode 100644 index 1d5911709..000000000 --- a/src/internal/_xtake.js +++ /dev/null @@ -1,20 +0,0 @@ -var _curry2 = require('./_curry2'); -var _reduced = require('./_reduced'); -var _xfBase = require('./_xfBase'); - -module.exports = (function() { - function XTake(n, xf) { - this.xf = xf; - this.n = n; - this.i = 0; - } - XTake.prototype['@@transducer/init'] = _xfBase.init; - XTake.prototype['@@transducer/result'] = _xfBase.result; - XTake.prototype['@@transducer/step'] = function(result, input) { - this.i += 1; - var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input); - return this.n >= 0 && this.i >= this.n ? _reduced(ret) : ret; - }; - - return _curry2(function _xtake(n, xf) { return new XTake(n, xf); }); -}()); diff --git a/src/internal/_xtakeWhile.js b/src/internal/_xtakeWhile.js deleted file mode 100644 index 7e1b513c5..000000000 --- a/src/internal/_xtakeWhile.js +++ /dev/null @@ -1,18 +0,0 @@ -var _curry2 = require('./_curry2'); -var _reduced = require('./_reduced'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XTakeWhile(f, xf) { - this.xf = xf; - this.f = f; - } - XTakeWhile.prototype['@@transducer/init'] = _xfBase.init; - XTakeWhile.prototype['@@transducer/result'] = _xfBase.result; - XTakeWhile.prototype['@@transducer/step'] = function(result, input) { - return this.f(input) ? this.xf['@@transducer/step'](result, input) : _reduced(result); - }; - - return _curry2(function _xtakeWhile(f, xf) { return new XTakeWhile(f, xf); }); -}()); diff --git a/src/internal/_xtap.js b/src/internal/_xtap.js deleted file mode 100644 index 347904e37..000000000 --- a/src/internal/_xtap.js +++ /dev/null @@ -1,18 +0,0 @@ -var _curry2 = require('./_curry2'); -var _xfBase = require('./_xfBase'); - - -module.exports = (function() { - function XTap(f, xf) { - this.xf = xf; - this.f = f; - } - XTap.prototype['@@transducer/init'] = _xfBase.init; - XTap.prototype['@@transducer/result'] = _xfBase.result; - XTap.prototype['@@transducer/step'] = function(result, input) { - this.f(input); - return this.xf['@@transducer/step'](result, input); - }; - - return _curry2(function _xtap(f, xf) { return new XTap(f, xf); }); -}()); diff --git a/src/internal/_xwrap.js b/src/internal/_xwrap.js deleted file mode 100644 index c96f9ece4..000000000 --- a/src/internal/_xwrap.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = (function() { - function XWrap(fn) { - this.f = fn; - } - XWrap.prototype['@@transducer/init'] = function() { - throw new Error('init not implemented on XWrap'); - }; - XWrap.prototype['@@transducer/result'] = function(acc) { return acc; }; - XWrap.prototype['@@transducer/step'] = function(acc, x) { - return this.f(acc, x); - }; - - return function _xwrap(fn) { return new XWrap(fn); }; -}()); diff --git a/src/keys.js b/src/keys.js deleted file mode 100644 index 55b03936b..000000000 --- a/src/keys.js +++ /dev/null @@ -1,74 +0,0 @@ -var _curry1 = require('./internal/_curry1'); -var _has = require('./internal/_has'); -var _isArguments = require('./internal/_isArguments'); - - -/** - * Returns a list containing the names of all the enumerable own properties of - * the supplied object. - * Note that the order of the output array is not guaranteed to be consistent - * across different JS platforms. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig {k: v} -> [k] - * @param {Object} obj The object to extract properties from - * @return {Array} An array of the object's own properties. - * @see R.keysIn, R.values - * @example - * - * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c'] - */ -module.exports = (function() { - // cover IE < 9 keys issues - var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString'); - var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', - 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; - // Safari bug - var hasArgsEnumBug = (function() { - 'use strict'; - return arguments.propertyIsEnumerable('length'); - }()); - - var contains = function contains(list, item) { - var idx = 0; - while (idx < list.length) { - if (list[idx] === item) { - return true; - } - idx += 1; - } - return false; - }; - - return typeof Object.keys === 'function' && !hasArgsEnumBug ? - _curry1(function keys(obj) { - return Object(obj) !== obj ? [] : Object.keys(obj); - }) : - _curry1(function keys(obj) { - if (Object(obj) !== obj) { - return []; - } - var prop, nIdx; - var ks = []; - var checkArgsLength = hasArgsEnumBug && _isArguments(obj); - for (prop in obj) { - if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) { - ks[ks.length] = prop; - } - } - if (hasEnumBug) { - nIdx = nonEnumerableProps.length - 1; - while (nIdx >= 0) { - prop = nonEnumerableProps[nIdx]; - if (_has(prop, obj) && !contains(ks, prop)) { - ks[ks.length] = prop; - } - nIdx -= 1; - } - } - return ks; - }); -}()); diff --git a/src/over.js b/src/over.js deleted file mode 100644 index 9c9bda823..000000000 --- a/src/over.js +++ /dev/null @@ -1,39 +0,0 @@ -var _curry3 = require('./internal/_curry3'); - - -/** - * Returns the result of "setting" the portion of the given data structure - * focused by the given lens to the result of applying the given function to - * the focused value. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig Lens s a -> (a -> a) -> s -> s - * @param {Lens} lens - * @param {*} v - * @param {*} x - * @return {*} - * @see R.prop, R.lensIndex, R.lensProp - * @example - * - * var headLens = R.lensIndex(0); - * - * R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); //=> ['FOO', 'bar', 'baz'] - */ -module.exports = (function() { - // `Identity` is a functor that holds a single value, where `map` simply - // transforms the held value with the provided function. - var Identity = function(x) { - return {value: x, map: function(f) { return Identity(f(x)); }}; - }; - - return _curry3(function over(lens, f, x) { - // The value returned by the getter function is first transformed with `f`, - // then set as the value of an `Identity`. This is then mapped over with the - // setter function of the lens. - return lens(function(y) { return Identity(f(y)); })(x).value; - }); -}()); diff --git a/test/assocPath.js b/test/assocPath.js index b3f10b423..a7152977e 100644 --- a/test/assocPath.js +++ b/test/assocPath.js @@ -2,7 +2,6 @@ var assert = require('assert'); var R = require('..'); var eq = require('./shared/eq'); -var assocPath = require('../src/assocPath'); describe('assocPath', function() { @@ -19,7 +18,7 @@ describe('assocPath', function() { it('is the equivalent of clone and setPath if the property is not on the original', function() { var obj1 = {a: 1, b: {c: 2, d: 3}, e: 4, f: 5}; - var obj2 = assocPath(['x', 0, 'y'], 42, obj1); + var obj2 = R.assocPath(['x', 0, 'y'], 42, obj1); eq(obj2, {a: 1, b: {c: 2, d: 3}, e: 4, f: 5, x: [{y: 42}]}); // Note: reference equality below! assert.strictEqual(obj2.a, obj1.a); @@ -42,11 +41,11 @@ describe('assocPath', function() { }); it('replaces `undefined` with a new object', function() { - eq(assocPath(['foo', 'bar', 'baz'], 42, {foo: undefined}), {foo: {bar: {baz: 42}}}); + eq(R.assocPath(['foo', 'bar', 'baz'], 42, {foo: undefined}), {foo: {bar: {baz: 42}}}); }); it('replaces `null` with a new object', function() { - eq(assocPath(['foo', 'bar', 'baz'], 42, {foo: null}), {foo: {bar: {baz: 42}}}); + eq(R.assocPath(['foo', 'bar', 'baz'], 42, {foo: null}), {foo: {bar: {baz: 42}}}); }); }); diff --git a/test/index.js b/test/index.js index a8ab096e9..e71189d2d 100644 --- a/test/index.js +++ b/test/index.js @@ -6,20 +6,21 @@ var path = require('path'); function sourceMethods(dir) { var isJsFile = function(file) { return file.match(/\.js$/); }; + var isIndex = R.equals('index.js'); var removeJsEnding = function(file) { return file.replace('.js', ''); }; - return fs.readdirSync(dir).filter(isJsFile).map(removeJsEnding); + return fs.readdirSync(dir).filter(R.both(R.complement(isIndex), isJsFile)).map(removeJsEnding); } /** * Convention is - * * Actual API—all `./src/*.js` files are top level API methods - * * Exported API—object in `./index.js` to be exported + * * Actual API—all `./es/*.js` files are top level API methods + * * Exported API—object in `./es/index.js` to be exported * * Actual and exported APIs should be the same * * Two cases, when exported and actual APIs might differ - * 1. newly added API `./src/method.js` is forgotten to be added into './index.js' - * 2. API method is deprecated and actual source file from `./src/` removed, - * while continues to exist in `./index.js` + * 1. newly added API `./es/method.js` is forgotten to be added into './es/index.js' + * 2. API method is deprecated and actual source file from `./es/` removed, + * while continues to exist in `./es/index.js` * * 1st case is detected in first assertion, and detailed in second one * @@ -27,8 +28,10 @@ function sourceMethods(dir) { * if you would attempt to require non existing file */ describe('API surface', function() { - var exported = Object.keys(R); - var actual = sourceMethods(path.join(__dirname, '..', 'src')); + var exported = Object.keys(R).filter(function(key) { + return key !== '__esModule'; + }); + var actual = sourceMethods(path.dirname(require.resolve('..'))); it('both APIs are in sync', function() { eq(actual.length, exported.length); diff --git a/test/shared/Id.js b/test/shared/Id.js index 2718882c7..1ee006986 100644 --- a/test/shared/Id.js +++ b/test/shared/Id.js @@ -1,23 +1,20 @@ -var concat = require('../../src/concat'); -var equals = require('../../src/equals'); -var map = require('../../src/map'); -var toString = require('../../src/toString'); +var R = require('../..'); // Id :: a -> Id a module.exports = function Id(value) { return { '@@type': 'ramda/Id', - 'fantasy-land/equals': function(other) { return other != null && other['@@type'] === this['@@type'] && equals(other.value, value); }, - 'fantasy-land/concat': function(id) { return Id(concat(value, id.value)); }, + 'fantasy-land/equals': function(other) { return other != null && other['@@type'] === this['@@type'] && R.equals(other.value, value); }, + 'fantasy-land/concat': function(id) { return Id(R.concat(value, id.value)); }, 'fantasy-land/map': function(f) { return Id(f(value)); }, 'fantasy-land/ap': function(id) { return Id(id.value(value)); }, 'fantasy-land/chain': function(f) { return f(value); }, 'fantasy-land/reduce': function(f, x) { return f(x, value); }, - 'fantasy-land/traverse': function(f, of) { return map(Id, f(value)); }, - sequence: function(of) { return map(Id, this.value); }, + 'fantasy-land/traverse': function(f, of) { return R.map(Id, f(value)); }, + sequence: function(of) { return R.map(Id, this.value); }, constructor: {'fantasy-land/of': Id}, - toString: function() { return 'Id(' + toString(value) + ')'; }, + toString: function() { return 'Id(' + R.toString(value) + ')'; }, value: value }; }; diff --git a/test/shared/Maybe.js b/test/shared/Maybe.js index 1c8067c1b..0947bb565 100644 --- a/test/shared/Maybe.js +++ b/test/shared/Maybe.js @@ -1,5 +1,4 @@ -var equals = require('../../src/equals'); -var toString = require('../../src/toString'); +var R = require('../..'); var sentinel = {}; @@ -31,7 +30,7 @@ Maybe.prototype['@@type'] = 'ramda/Maybe'; // Maybe#equals :: Maybe a ~> Maybe a -> Boolean Maybe.prototype['fantasy-land/equals'] = function(other) { return other != null && other['@@type'] === this['@@type'] && - this.isJust ? other.isJust && equals(other.value, this.value) : other.isNothing; + this.isJust ? other.isJust && R.equals(other.value, this.value) : other.isNothing; }; // Maybe#map :: Maybe a ~> (a -> b) -> Maybe b @@ -56,5 +55,5 @@ Maybe.prototype.filter = function(pred) { // Maybe#toString :: Maybe a ~> String Maybe.prototype.toString = function() { - return this.isJust ? 'Just(' + toString(this.value) + ')' : 'Nothing'; + return this.isJust ? 'Just(' + R.toString(this.value) + ')' : 'Nothing'; };