Comparing version 0.5.5 to 0.5.6
@@ -143,2 +143,4 @@ //! Imm | ||
var id, mergable; | ||
if (!array) array = []; | ||
if (args) _assertIsObject(args, 'You must provide an object for arguments'); | ||
@@ -284,3 +286,3 @@ | ||
return Object.keys(immutableCollection).map(function (key) { | ||
return immutableCollection[key].asMutable(); | ||
return immutableCollection[key].asMutable({deep: true}); | ||
}); | ||
@@ -371,3 +373,3 @@ } | ||
if (!record) return void(0); | ||
return record.asMutable(); | ||
return record.asMutable({deep: true}); | ||
} | ||
@@ -374,0 +376,0 @@ |
@@ -6,2 +6,2 @@ //! Imm | ||
//! https://github.com/sporto/imm | ||
!function(r,t){if("function"==typeof define&&define.amd)define(["seamless-immutable"],function(e){return r.imm=t(e)});else if("object"==typeof exports){var e=require("seamless-immutable");module.exports=t(e)}else r.imm=t(r.Immutable)}(this,function(r){"use strict";function t(r){return y(r)?r:[r]}function e(r){return r.map(function(r){return""+r})}function n(r,t){if(!t)throw new Error("Must provide a key");return r.map(function(r){return r[t]})}function o(t){return r.isImmutable(t)}function u(r){var t=typeof r;return"function"===t||"object"===t&&!!r}function i(r){var t=o(r);if(!t)throw new Error("Not an immutable object")}function a(r){var t=!y(r),e=o(r);if(t||e)throw new Error("You must provide an array")}function f(r,t){if(t||(t="Not an object"),!u(r))throw new Error(t)}function c(){var r=(new Date).getTime(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==t?e:3&e|8).toString(16)});return t}function m(r){r=r||{};for(var t=1,e=arguments.length;e>t;t++){var n=arguments[t];for(var o in n)void 0===r[o]&&(r[o]=n[o])}return r}function s(r,t){return v(r,t)}function v(t,e){var n,o;e&&f(e,"You must provide an object for arguments");var u={key:l};e=m(e,u),a(t);var i=r(t).asObject(function(r){return n=r[e.key],n||(n=c(),o={},o[e.key]=n,r=r.merge(o)),[n,r]});return x(i,e)}function x(r,o){function u(r){return v(r,o)}function a(r){return x(r,o)}function f(r,e){var u={strict:!1};if(e=m(e,u),e.strict){var i=t(r),a=n(i,o.key);if(l(a))throw new Error("Some records already exist")}return e.requireKey=!1,E(r,e)}function s(e){for(var n=t(e),o=0;o<n.length;o++){var u=n[o];if(!r[u])return!1}return!0}function l(e){for(var n=t(e),o=0;o<n.length;o++){var u=n[o];if(r[u])return!0}return!1}function y(){return d()}function d(){return Object.keys(r).map(function(t){return r[t].asMutable()})}function h(){return Object.keys(r).length}function w(r){var t=d();return t=t.filter(r),u(t)}function g(r){for(var t=d(),e=0;e<t.length;e++){var n=t[e];if(r(n))return n}return void 0}function b(t){var e=r[t];return e?e.asMutable():void 0}function p(r){var t=d();return t.map(r)}function k(n,o){var u=t(n);if(u=e(u),o&&o.strict&&!s(u))throw new Error("Some records do not exist");var i=r.without(u);return a(i)}function E(u,i){var f,s,v=t(u),x=n(v,o.key);x=e(x);var y=r.without(x),d={},h={strict:!1,requireKey:!0};if(i=m(i,h),i.strict&&l(x))throw new Error("Some records already exist");for(var w=0;w<v.length;w++){if(f=v[w],s=f[o.key],!s){if(i.requireKey)throw new Error("Record must have ."+o.key);s=c(),f[o.key]=s}if(!s)throw new Error("Record must have ."+o.key);d[s]=f}return y=y.merge(d),a(y)}function j(){return r}function S(e,u){var i={strict:!1};u=m(u,i);var f,c,s,v,x,y=t(e),d=r;if(u.strict){var h=t(e),w=n(h,o.key);if(l(w))throw new Error("Some records already exist")}for(var g=0;g<y.length;g++){if(c=y[g],f=c[o.key],!f)throw new Error("Record must have ."+o.key);v=r[f],x=v?v.merge(c):c,s={},s[f]=x,d=d.merge(s)}return a(d)}return i(r),{isImm:!0,add:f,allExist:s,anyExist:l,array:y,count:h,filter:w,find:g,get:b,replace:E,map:p,remove:k,toImmutable:j,update:S}}if(null==r)throw new Error("Immutable is null");var l="id",y=Array.isArray||function(r){return"[object Array]"===toString.call(r)};return s}); | ||
!function(r,e){if("function"==typeof define&&define.amd)define(["seamless-immutable"],function(t){return r.imm=e(t)});else if("object"==typeof exports){var t=require("seamless-immutable");module.exports=e(t)}else r.imm=e(r.Immutable)}(this,function(r){"use strict";function e(r){return y(r)?r:[r]}function t(r){return r.map(function(r){return""+r})}function n(r,e){if(!e)throw new Error("Must provide a key");return r.map(function(r){return r[e]})}function o(e){return r.isImmutable(e)}function u(r){var e=typeof r;return"function"===e||"object"===e&&!!r}function i(r){var e=o(r);if(!e)throw new Error("Not an immutable object")}function a(r){var e=!y(r),t=o(r);if(e||t)throw new Error("You must provide an array")}function f(r,e){if(e||(e="Not an object"),!u(r))throw new Error(e)}function c(){var r=(new Date).getTime(),e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==e?t:3&t|8).toString(16)});return e}function m(r){r=r||{};for(var e=1,t=arguments.length;t>e;e++){var n=arguments[e];for(var o in n)void 0===r[o]&&(r[o]=n[o])}return r}function s(r,e){return v(r,e)}function v(e,t){var n,o;e||(e=[]),t&&f(t,"You must provide an object for arguments");var u={key:l};t=m(t,u),a(e);var i=r(e).asObject(function(r){return n=r[t.key],n||(n=c(),o={},o[t.key]=n,r=r.merge(o)),[n,r]});return x(i,t)}function x(r,o){function u(r){return v(r,o)}function a(r){return x(r,o)}function f(r,t){var u={strict:!1};if(t=m(t,u),t.strict){var i=e(r),a=n(i,o.key);if(l(a))throw new Error("Some records already exist")}return t.requireKey=!1,E(r,t)}function s(t){for(var n=e(t),o=0;o<n.length;o++){var u=n[o];if(!r[u])return!1}return!0}function l(t){for(var n=e(t),o=0;o<n.length;o++){var u=n[o];if(r[u])return!0}return!1}function y(){return d()}function d(){return Object.keys(r).map(function(e){return r[e].asMutable({deep:!0})})}function h(){return Object.keys(r).length}function w(r){var e=d();return e=e.filter(r),u(e)}function g(r){for(var e=d(),t=0;t<e.length;t++){var n=e[t];if(r(n))return n}return void 0}function b(e){var t=r[e];return t?t.asMutable({deep:!0}):void 0}function p(r){var e=d();return e.map(r)}function k(n,o){var u=e(n);if(u=t(u),o&&o.strict&&!s(u))throw new Error("Some records do not exist");var i=r.without(u);return a(i)}function E(u,i){var f,s,v=e(u),x=n(v,o.key);x=t(x);var y=r.without(x),d={},h={strict:!1,requireKey:!0};if(i=m(i,h),i.strict&&l(x))throw new Error("Some records already exist");for(var w=0;w<v.length;w++){if(f=v[w],s=f[o.key],!s){if(i.requireKey)throw new Error("Record must have ."+o.key);s=c(),f[o.key]=s}if(!s)throw new Error("Record must have ."+o.key);d[s]=f}return y=y.merge(d),a(y)}function j(){return r}function S(t,u){var i={strict:!1};u=m(u,i);var f,c,s,v,x,y=e(t),d=r;if(u.strict){var h=e(t),w=n(h,o.key);if(l(w))throw new Error("Some records already exist")}for(var g=0;g<y.length;g++){if(c=y[g],f=c[o.key],!f)throw new Error("Record must have ."+o.key);v=r[f],x=v?v.merge(c):c,s={},s[f]=x,d=d.merge(s)}return a(d)}return i(r),{isImm:!0,add:f,allExist:s,anyExist:l,array:y,count:h,filter:w,find:g,get:b,replace:E,map:p,remove:k,toImmutable:j,update:S}}if(null==r)throw new Error("Immutable is null");var l="id",y=Array.isArray||function(r){return"[object Array]"===toString.call(r)};return s}); |
{ | ||
"name": "imm", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"description": "Immutable collections built on top of immutable.js", | ||
@@ -5,0 +5,0 @@ "main": "dist/imm.js", |
@@ -56,3 +56,3 @@ IMM.js | ||
### [add](src/imm.js#L203) | ||
### [add](src/imm.js#L205) | ||
@@ -76,3 +76,3 @@ Adds one or more records. If record already exists then it gets replaced. If a record doesn't have a key, then the key will be autogenerated. | ||
### [allExist](src/imm.js#L233) | ||
### [allExist](src/imm.js#L235) | ||
@@ -91,3 +91,3 @@ Check if the given ID or all given IDs exist. | ||
### [anyExist](src/imm.js#L256) | ||
### [anyExist](src/imm.js#L258) | ||
@@ -106,3 +106,3 @@ Check if the given ID or any given IDs exist | ||
### [array](src/imm.js#L278) | ||
### [array](src/imm.js#L280) | ||
@@ -119,3 +119,3 @@ Get all records. Records in the array are plain mutable JS objects. | ||
### [count](src/imm.js#L300) | ||
### [count](src/imm.js#L302) | ||
@@ -132,3 +132,3 @@ Records count. | ||
### [filter](src/imm.js#L319) | ||
### [filter](src/imm.js#L321) | ||
@@ -148,3 +148,3 @@ Filters the collection based on a filtering function. | ||
### [find](src/imm.js#L341) | ||
### [find](src/imm.js#L343) | ||
@@ -164,3 +164,3 @@ Finds one record. Returns a plain JS mutable object. | ||
### [get](src/imm.js#L367) | ||
### [get](src/imm.js#L369) | ||
@@ -179,3 +179,3 @@ Get a record. Returned record is a plain JS mutable object. | ||
### [map](src/imm.js#L388) | ||
### [map](src/imm.js#L390) | ||
@@ -195,3 +195,3 @@ Map the collection through a given function | ||
### [remove](src/imm.js#L410) | ||
### [remove](src/imm.js#L412) | ||
@@ -212,3 +212,3 @@ Removes one or many records based on the id. If record is not found then it just gets skipped. | ||
### [replace](src/imm.js#L444) | ||
### [replace](src/imm.js#L446) | ||
@@ -230,3 +230,3 @@ Replaces one item or many. This discards any previous data from the replaced items. If records doesn't exist then it just gets added. This throws if a record doesn't have an key. | ||
### [update](src/imm.js#L502) | ||
### [update](src/imm.js#L504) | ||
@@ -233,0 +233,0 @@ Updates one record or many. This merges the given data with the existing one. If a record is not found then it gets added. This throws if a record doesn't have an key |
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
56751
1587