Comparing version 2.2.0 to 2.2.1
@@ -0,1 +1,4 @@ | ||
# v2.2.1 | ||
- Make `map` and `filter` work properly with `chain` | ||
# v2.2.0 | ||
@@ -2,0 +5,0 @@ - Compile `icepick.min.js` and `icepick.dev.js` down to ES5. |
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).icepick=e()}}(function(){return function e(r,n,t){function o(i,c){if(!n[i]){if(!r[i]){var f="function"==typeof require&&require;if(!c&&f)return f(i,!0);if(u)return u(i,!0);var s=new Error("Cannot find module '"+i+"'");throw s.code="MODULE_NOT_FOUND",s}var a=n[i]={exports:{}};r[i][0].call(a.exports,function(e){var n=r[i][1][e];return o(n||e)},a,a.exports,e,r,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}({1:[function(e,r,n){"use strict";function t(e,r){return(r||[]).reduce(function(e,r){if(e)return e[r]},e)}function o(e,r){return Object.keys(r).reduce(function(e,n){return c.assoc(e,n,r[n])},e)}function u(e,r,n){return null==e||null==r?e:Object.keys(r).reduce(function(e,t){var o=r[t],s=e[t],a=n?n(s,o,t):o;return f(o)&&f(s)?a===s&&Object.isFrozen(a)&&Object.isFrozen(s)?e:Array.isArray(o)?c.assoc(e,t,a):i(e,t,u(s,a,n)):i(e,t,a)},e)}function i(e,r,n){return e[r]===n?e:c.assoc(e,r,n)}var c=n,f=function(e){return null!==e&&(Array.isArray(e)||s(e))},s=function(e){return"object"==typeof e&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype},a=function(e,r){var n,t;if(Array.isArray(e))for(n=e.length;n--;)r(n);else for(n=(t=Object.keys(e)).length;n--;)r(t[n])},l=function(e){for(var r,n={},t=Object.keys(e),o=t.length;o--;)n[r=t[o]]=e[r];return n},p=function(e){return Array.isArray(e)?e.slice():l(e)},v=function(e){return f(e)&&!Object.isFrozen(e)?d(e):e},y=function(e){return"object"==typeof e?Object.freeze(e):e},h=[],d=function(e){if(h.some(function(r){return r===e}))throw new Error("object has a reference cycle");return h.push(e),a(e,function(r){var n=e[r];f(n)&&d(n)}),h.pop(),Object.freeze(e),e};n.freeze=d,n.thaw=function e(r){if(!f(r)||!Object.isFrozen(r))return r;var n=Array.isArray(r)?new Array(r.length):{};return a(r,function(t){n[t]=e(r[t])}),n},n.assoc=function(e,r,n){if(e[r]===n)return y(e);var t=p(e);return t[r]=v(n),y(t)},n.set=n.assoc,n.dissoc=function(e,r){var n=p(e);return delete n[r],y(n)},n.unset=n.dissoc,n.assocIn=function e(r,n,t){var o=n[0];return 1===n.length?c.assoc(r,o,t):c.assoc(r,o,e(r[o]||{},n.slice(1),t))},n.setIn=n.assocIn,n.getIn=t,n.updateIn=function(e,r,n){var o=t(e,r);return c.assocIn(e,r,n(o))},["push","unshift","pop","shift","reverse","sort"].forEach(function(e){n[e]=function(r,n){var t=[].concat(r);return t[e](v(n)),y(t)},n[e].displayName="icepick."+e}),n.splice=function(e){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];var t=[].concat(e),o=r.map(v);return t.splice.apply(t,o),y(t)},n.slice=function(e,r,n){var t=e.slice(r,n);return y(t)},["map","filter"].forEach(function(e){n[e]=function(r,n){var t=n[e](r);return y(t)},n[e].displayName="icepick."+e}),n.extend=n.assign=function(e){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];var t=r.reduce(o,e);return y(t)},n.merge=u;var b={value:function(){return this.val},thru:function(e){return this.val=v(e(this.val)),this}};Object.keys(n).forEach(function(e){b[e]=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return r.unshift(this.val),this.val=n[e].apply(null,r),this}}),n.chain=function(e){var r=Object.create(b);return r.val=e,r}},{}]},{},[1])(1)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).icepick=e()}}(function(){return function e(r,n,t){function o(c,u){if(!n[c]){if(!r[c]){var f="function"==typeof require&&require;if(!u&&f)return f(c,!0);if(i)return i(c,!0);var s=new Error("Cannot find module '"+c+"'");throw s.code="MODULE_NOT_FOUND",s}var a=n[c]={exports:{}};r[c][0].call(a.exports,function(e){var n=r[c][1][e];return o(n||e)},a,a.exports,e,r,n,t)}return n[c].exports}for(var i="function"==typeof require&&require,c=0;c<t.length;c++)o(t[c]);return o}({1:[function(e,r,n){"use strict";function t(e,r){return(r||[]).reduce(function(e,r){if(e)return e[r]},e)}function o(e,r){return Object.keys(r).reduce(function(e,n){return u.assoc(e,n,r[n])},e)}function i(e,r,n){return null==e||null==r?e:Object.keys(r).reduce(function(e,t){var o=r[t],s=e[t],a=n?n(s,o,t):o;return f(o)&&f(s)?a===s&&Object.isFrozen(a)&&Object.isFrozen(s)?e:Array.isArray(o)?u.assoc(e,t,a):c(e,t,i(s,a,n)):c(e,t,a)},e)}function c(e,r,n){return e[r]===n?e:u.assoc(e,r,n)}var u=n,f=function(e){return null!==e&&(Array.isArray(e)||s(e))},s=function(e){return"object"==typeof e&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype},a=function(e,r){var n,t;if(Array.isArray(e))for(n=e.length;n--;)r(n);else for(n=(t=Object.keys(e)).length;n--;)r(t[n])},l=function(e){for(var r,n={},t=Object.keys(e),o=t.length;o--;)n[r=t[o]]=e[r];return n},p=function(e){return Array.isArray(e)?e.slice():l(e)},v=function(e){return f(e)&&!Object.isFrozen(e)?d(e):e},h=function(e){return"object"==typeof e?Object.freeze(e):e},y=[],d=function(e){if(y.some(function(r){return r===e}))throw new Error("object has a reference cycle");return y.push(e),a(e,function(r){var n=e[r];f(n)&&d(n)}),y.pop(),Object.freeze(e),e};n.freeze=d,n.thaw=function e(r){if(!f(r)||!Object.isFrozen(r))return r;var n=Array.isArray(r)?new Array(r.length):{};return a(r,function(t){n[t]=e(r[t])}),n},n.assoc=function(e,r,n){if(e[r]===n)return h(e);var t=p(e);return t[r]=v(n),h(t)},n.set=n.assoc,n.dissoc=function(e,r){var n=p(e);return delete n[r],h(n)},n.unset=n.dissoc,n.assocIn=function e(r,n,t){var o=n[0];return 1===n.length?u.assoc(r,o,t):u.assoc(r,o,e(r[o]||{},n.slice(1),t))},n.setIn=n.assocIn,n.getIn=t,n.updateIn=function(e,r,n){var o=t(e,r);return u.assocIn(e,r,n(o))},["push","unshift","pop","shift","reverse","sort"].forEach(function(e){n[e]=function(r,n){var t=[].concat(r);return t[e](v(n)),h(t)},n[e].displayName="icepick."+e}),n.splice=function(e){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];var t=[].concat(e),o=r.map(v);return t.splice.apply(t,o),h(t)},n.slice=function(e,r,n){var t=e.slice(r,n);return h(t)},["map","filter"].forEach(function(e){n[e]=function(r,n){var t=n[e](r);return h(t)},n[e].displayName="icepick."+e}),n.extend=n.assign=function(e){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];var t=r.reduce(o,e);return h(t)},n.merge=i;var b={value:function(){return this.val},thru:function(e){return this.val=v(e(this.val)),this}};Object.keys(n).forEach(function(e){e.match(/^(map|filter)$/)?b[e]=function(r){return this.val=n[e](r,this.val),this}:b[e]=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return this.val=n[e].apply(n,[this.val].concat(r)),this}}),n.chain=function(e){var r=Object.create(b);return r.val=e,r}},{}]},{},[1])(1)}); |
@@ -325,5 +325,11 @@ /** | ||
Object.keys(exports).forEach((methodName) => { | ||
if (methodName.match(/^(map|filter)$/)) { | ||
chainProto[methodName] = function (fn) { | ||
this.val = exports[methodName](fn, this.val) | ||
return this | ||
} | ||
return | ||
} | ||
chainProto[methodName] = function (...args) { | ||
args.unshift(this.val) | ||
this.val = exports[methodName].apply(null, args) | ||
this.val = exports[methodName](this.val, ...args) | ||
return this | ||
@@ -330,0 +336,0 @@ } |
@@ -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{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).icepick=n()}}(function(){return function n(r,e,t){function u(o,c){if(!e[o]){if(!r[o]){var f="function"==typeof require&&require;if(!c&&f)return f(o,!0);if(i)return i(o,!0);var s=new Error("Cannot find module '"+o+"'");throw s.code="MODULE_NOT_FOUND",s}var a=e[o]={exports:{}};r[o][0].call(a.exports,function(n){var e=r[o][1][n];return u(e||n)},a,a.exports,n,r,e,t)}return e[o].exports}for(var i="function"==typeof require&&require,o=0;o<t.length;o++)u(t[o]);return u}({1:[function(n,r,e){"use strict";function t(n,r){return(r||[]).reduce(function(n,r){if(n)return n[r]},n)}function u(n,r){return Object.keys(r).reduce(function(n,e){return c.assoc(n,e,r[e])},n)}function i(n,r,e){return null==n||null==r?n:Object.keys(r).reduce(function(n,t){var u=r[t],f=n[t],a=e?e(f,u,t):u;return s(u)&&s(f)?a===f?n:Array.isArray(u)?c.assoc(n,t,a):o(n,t,i(f,a,e)):o(n,t,a)},n)}function o(n,r,e){return n[r]===e?n:c.assoc(n,r,e)}var c=e,f=function(n){return n},s=function(n){return null!==n&&(Array.isArray(n)||a(n))},a=function(n){return"object"==typeof n&&n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype},l=function(n,r){var e,t;if(Array.isArray(n))for(e=n.length;e--;)r(e);else for(e=(t=Object.keys(n)).length;e--;)r(t[e])},p=function(n){for(var r,e={},t=Object.keys(n),u=t.length;u--;)e[r=t[u]]=n[r];return e},v=function(n){return Array.isArray(n)?n.slice():p(n)},y=f,d=f;e.freeze=f,e.thaw=function n(r){if(!s(r)||!Object.isFrozen(r))return r;var e=Array.isArray(r)?new Array(r.length):{};return l(r,function(t){e[t]=n(r[t])}),e},e.assoc=function(n,r,e){if(n[r]===e)return d(n);var t=v(n);return t[r]=y(e),d(t)},e.set=e.assoc,e.dissoc=function(n,r){var e=v(n);return delete e[r],d(e)},e.unset=e.dissoc,e.assocIn=function n(r,e,t){var u=e[0];return 1===e.length?c.assoc(r,u,t):c.assoc(r,u,n(r[u]||{},e.slice(1),t))},e.setIn=e.assocIn,e.getIn=t,e.updateIn=function(n,r,e){var u=t(n,r);return c.assocIn(n,r,e(u))},["push","unshift","pop","shift","reverse","sort"].forEach(function(n){e[n]=function(r,e){var t=[].concat(r);return t[n](y(e)),d(t)},e[n].displayName="icepick."+n}),e.splice=function(n){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];var t=[].concat(n),u=r.map(y);return t.splice.apply(t,u),d(t)},e.slice=function(n,r,e){var t=n.slice(r,e);return d(t)},["map","filter"].forEach(function(n){e[n]=function(r,e){var t=e[n](r);return d(t)},e[n].displayName="icepick."+n}),e.extend=e.assign=function(n){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];var t=r.reduce(u,n);return d(t)},e.merge=i;var h={value:function(){return this.val},thru:function(n){return this.val=y(n(this.val)),this}};Object.keys(e).forEach(function(n){h[n]=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return r.unshift(this.val),this.val=e[n].apply(null,r),this}}),e.chain=function(n){var r=Object.create(h);return r.val=n,r}},{}]},{},[1])(1)}); | ||
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).icepick=n()}}(function(){return function n(r,e,t){function i(u,c){if(!e[u]){if(!r[u]){var f="function"==typeof require&&require;if(!c&&f)return f(u,!0);if(o)return o(u,!0);var a=new Error("Cannot find module '"+u+"'");throw a.code="MODULE_NOT_FOUND",a}var s=e[u]={exports:{}};r[u][0].call(s.exports,function(n){var e=r[u][1][n];return i(e||n)},s,s.exports,n,r,e,t)}return e[u].exports}for(var o="function"==typeof require&&require,u=0;u<t.length;u++)i(t[u]);return i}({1:[function(n,r,e){"use strict";function t(n,r){return(r||[]).reduce(function(n,r){if(n)return n[r]},n)}function i(n,r){return Object.keys(r).reduce(function(n,e){return c.assoc(n,e,r[e])},n)}function o(n,r,e){return null==n||null==r?n:Object.keys(r).reduce(function(n,t){var i=r[t],f=n[t],s=e?e(f,i,t):i;return a(i)&&a(f)?s===f?n:Array.isArray(i)?c.assoc(n,t,s):u(n,t,o(f,s,e)):u(n,t,s)},n)}function u(n,r,e){return n[r]===e?n:c.assoc(n,r,e)}var c=e,f=function(n){return n},a=function(n){return null!==n&&(Array.isArray(n)||s(n))},s=function(n){return"object"==typeof n&&n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype},l=function(n,r){var e,t;if(Array.isArray(n))for(e=n.length;e--;)r(e);else for(e=(t=Object.keys(n)).length;e--;)r(t[e])},p=function(n){for(var r,e={},t=Object.keys(n),i=t.length;i--;)e[r=t[i]]=n[r];return e},v=function(n){return Array.isArray(n)?n.slice():p(n)},h=f,y=f;e.freeze=f,e.thaw=function n(r){if(!a(r)||!Object.isFrozen(r))return r;var e=Array.isArray(r)?new Array(r.length):{};return l(r,function(t){e[t]=n(r[t])}),e},e.assoc=function(n,r,e){if(n[r]===e)return y(n);var t=v(n);return t[r]=h(e),y(t)},e.set=e.assoc,e.dissoc=function(n,r){var e=v(n);return delete e[r],y(e)},e.unset=e.dissoc,e.assocIn=function n(r,e,t){var i=e[0];return 1===e.length?c.assoc(r,i,t):c.assoc(r,i,n(r[i]||{},e.slice(1),t))},e.setIn=e.assocIn,e.getIn=t,e.updateIn=function(n,r,e){var i=t(n,r);return c.assocIn(n,r,e(i))},["push","unshift","pop","shift","reverse","sort"].forEach(function(n){e[n]=function(r,e){var t=[].concat(r);return t[n](h(e)),y(t)},e[n].displayName="icepick."+n}),e.splice=function(n){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];var t=[].concat(n),i=r.map(h);return t.splice.apply(t,i),y(t)},e.slice=function(n,r,e){var t=n.slice(r,e);return y(t)},["map","filter"].forEach(function(n){e[n]=function(r,e){var t=e[n](r);return y(t)},e[n].displayName="icepick."+n}),e.extend=e.assign=function(n){for(var r=[],e=arguments.length-1;e-- >0;)r[e]=arguments[e+1];var t=r.reduce(i,n);return y(t)},e.merge=o;var d={value:function(){return this.val},thru:function(n){return this.val=h(n(this.val)),this}};Object.keys(e).forEach(function(n){n.match(/^(map|filter)$/)?d[n]=function(r){return this.val=e[n](r,this.val),this}:d[n]=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return this.val=e[n].apply(e,[this.val].concat(r)),this}}),e.chain=function(n){var r=Object.create(d);return r.val=n,r}},{}]},{},[1])(1)}); |
@@ -544,2 +544,12 @@ const i = require('./icepick') | ||
}) | ||
test('should work with map and filter', assert => { | ||
const o = [1, 2, 3] | ||
const result = i.chain(o) | ||
.map(val => val * 2) | ||
.filter(val => val > 2) | ||
.value() | ||
assert.ok(Object.isFrozen(result)) | ||
assert.same(result, [4, 6]) | ||
}) | ||
}) | ||
@@ -546,0 +556,0 @@ |
{ | ||
"name": "icepick", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "Utilities for treating frozen JavaScript objects as persistent immutable collections.", | ||
@@ -5,0 +5,0 @@ "main": "icepick.js", |
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
48299
833
9