Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "pipep", | ||
"description": "Functional, composable, immutable and curried promise sequences that automatically handle Promise resolution.", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"author": "Declan de Wet <declandewet@me.com>", | ||
@@ -6,0 +6,0 @@ "ava": { |
25
pipep.js
@@ -25,4 +25,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.pipeP = f()}})(function(){var define,module,exports;module={exports:(exports={})}; | ||
// throw error if environment has no Promise support | ||
if (!exists(Promise)) { | ||
throw new Error(s('Use a `Promise` polyfill for environments that do not support native ES2015 Promises.')) | ||
if (typeof Promise === 'undefined' || Promise === null) { | ||
throw new ReferenceError(s('Use a `Promise` polyfill for environments that do not support native ES2015 Promises.')) | ||
} | ||
@@ -32,3 +32,3 @@ | ||
if (!is(Function, Object.assign)) { | ||
throw new Error(s('Use an `Object.assign` polyfill for environments that do not support native ES2015 Object properties.')) | ||
throw new ReferenceError(s('Use an `Object.assign` polyfill for environments that do not support native ES2015 Object properties.')) | ||
} | ||
@@ -43,4 +43,4 @@ | ||
// throw if first handler is missing | ||
if (!exists(initialHandler)) { | ||
throw new SyntaxError(s('expects at least one argument')) | ||
if (initialHandler == null) { | ||
throw new ReferenceError(s('expects at least one argument')) | ||
} | ||
@@ -50,3 +50,3 @@ | ||
if (!is(Function, initialHandler)) { | ||
throw new SyntaxError(s('first handler must be a variadic function that returns a promise or value')) | ||
throw new TypeError(s('first handler must be a variadic function that returns a promise or value')) | ||
} | ||
@@ -71,3 +71,3 @@ | ||
// if next handler is not a function, reject the promise | ||
: Promise.reject(new SyntaxError(s("expected handler '%d' to have type 'function', got '%s': '%s'", i + 2, typeof next, next))) | ||
: Promise.reject(new TypeError(s("expected handler '%d' to have type 'function', got '%s': '%s'", i + 2, typeof next, next))) | ||
}, initialComputation) | ||
@@ -164,15 +164,6 @@ | ||
function is (Ctor, val) { | ||
return exists(val) && val.constructor === Ctor || val instanceof Ctor | ||
return typeof val !== 'undefined' && val !== null && val.constructor === Ctor || val instanceof Ctor | ||
} | ||
/** | ||
* Checks if val is not null or undefined. | ||
* @param {*} val - value to check | ||
* @return {Boolean} - true if val exists | ||
*/ | ||
function exists (val) { | ||
return val != null | ||
} | ||
/** | ||
* Takes a function and curries it to it's own arity | ||
@@ -179,0 +170,0 @@ * @param {Function} fn - function to curry |
@@ -1,1 +0,1 @@ | ||
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.pipeP=n()}}(function(){function n(n,e){n=n||{};var t=n.duplicate;return u(Array,e)?Promise.all(t?i([],e):e):t&&u(Object,e)&&!u(Function,e.then)?Object.assign({},e):e}function e(n){return n.reduce(i,[])}function t(n){return[].slice.apply(n)}function r(n){return n.length}function o(n,e){return n.apply(null,e)}function i(n,e){return n.concat(e)}function u(n,e){return f(e)&&e.constructor===n||e instanceof n}function f(n){return null!=n}function c(n){return s(r(n),n)}function a(n,e){return s(n,e)}function s(n,e,u){return u=u||[],function(){var f=t(arguments),c=i(u,f);return n>r(c)?s(n,e,c):o(e,c.slice(0,n))}}function l(n,e,t){return e.replace(n,t)}function p(){var n=t(arguments),e=n.shift();return n.reduce(v(/(?:%s|%d)/),"[pipeP] "+e)}var d,h;d={exports:h={}};var y=c(o),v=c(l),m=c(n);return d.exports=function(){if(!f(Promise))throw new Error(p("Use a `Promise` polyfill for environments that do not support native ES2015 Promises."));if(!u(Function,Object.assign))throw new Error(p("Use an `Object.assign` polyfill for environments that do not support native ES2015 Object properties."));var n=e(t(arguments)),o=n.shift();if(!f(o))throw new SyntaxError(p("expects at least one argument"));if(!u(Function,o))throw new SyntaxError(p("first handler must be a variadic function that returns a promise or value"));var i=r(o),c=a(i,function(){var e=t(arguments).map(m({duplicate:!0})),r=Promise.all(e).then(y(o)),i=n.reduce(function(n,e,t){return u(Function,e)?n.then(m(null)).then(e):Promise.reject(new SyntaxError(p("expected handler '%d' to have type 'function', got '%s': '%s'",t+2,typeof e,e)))},r);return i.then(m(null))});try{Object.defineProperty(c,"length",{get:function(){return i}})}catch(s){}return c},d.exports}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.pipeP=e()}}(function(){function e(e,n){e=e||{};var t=e.duplicate;return u(Array,n)?Promise.all(t?i([],n):n):t&&u(Object,n)&&!u(Function,n.then)?Object.assign({},n):n}function n(e){return e.reduce(i,[])}function t(e){return[].slice.apply(e)}function r(e){return e.length}function o(e,n){return e.apply(null,n)}function i(e,n){return e.concat(n)}function u(e,n){return"undefined"!=typeof n&&null!==n&&n.constructor===e||n instanceof e}function f(e){return s(r(e),e)}function c(e,n){return s(e,n)}function s(e,n,u){return u=u||[],function(){var f=t(arguments),c=i(u,f);return e>r(c)?s(e,n,c):o(n,c.slice(0,e))}}function a(e,n,t){return n.replace(e,t)}function l(){var e=t(arguments),n=e.shift();return e.reduce(y(/(?:%s|%d)/),"[pipeP] "+n)}var p,d;p={exports:d={}};var h=f(o),y=f(a),m=f(e);return p.exports=function(){if("undefined"==typeof Promise||null===Promise)throw new ReferenceError(l("Use a `Promise` polyfill for environments that do not support native ES2015 Promises."));if(!u(Function,Object.assign))throw new ReferenceError(l("Use an `Object.assign` polyfill for environments that do not support native ES2015 Object properties."));var e=n(t(arguments)),o=e.shift();if(null==o)throw new ReferenceError(l("expects at least one argument"));if(!u(Function,o))throw new TypeError(l("first handler must be a variadic function that returns a promise or value"));var i=r(o),f=c(i,function(){var n=t(arguments).map(m({duplicate:!0})),r=Promise.all(n).then(h(o)),i=e.reduce(function(e,n,t){return u(Function,n)?e.then(m(null)).then(n):Promise.reject(new TypeError(l("expected handler '%d' to have type 'function', got '%s': '%s'",t+2,typeof n,n)))},r);return i.then(m(null))});try{Object.defineProperty(f,"length",{get:function(){return i}})}catch(s){}return f},p.exports}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
12936
204