Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

normalizr

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normalizr - npm Package Compare versions

Comparing version 3.2.0 to 3.2.1

2

CHANGELOG.md

@@ -6,3 +6,3 @@ # v3.2.0

* **Fixed** Gracefully handle missing data in `denormalize` (gh-232)
* **Fixed** Prevent infinite recursion in `denormalize` (gh-220)
* ~~**Fixed** Prevent infinite recursion in `denormalize` (gh-220)~~ Reverted in v3.2.1

@@ -9,0 +9,0 @@ # v3.1.0

@@ -631,22 +631,7 @@ 'use strict';

var getEntities = function getEntities(entities, visitedEntities, isImmutable$$1) {
var getEntities = function getEntities(entities, isImmutable$$1) {
return function (schema, entityOrId) {
var schemaKey = schema.key;
if (!visitedEntities[schemaKey]) {
visitedEntities[schemaKey] = {};
}
var entity = getEntity(entityOrId, schemaKey, entities, isImmutable$$1);
if ((typeof entity === 'undefined' ? 'undefined' : _typeof(entity)) !== 'object' || entity === null) {
return entity;
}
var id = schema.getId(entity);
if (visitedEntities[schemaKey][id]) {
return id;
}
visitedEntities[schemaKey][id] = true;
return entity;
return getEntity(entityOrId, schemaKey, entities, isImmutable$$1);
};

@@ -661,3 +646,3 @@ };

var isImmutable$$1 = isImmutable(entities);
var getDenormalizedEntity = getEntities(entities, {}, isImmutable$$1);
var getDenormalizedEntity = getEntities(entities, isImmutable$$1);
return unvisit(input, schema, getDenormalizedEntity);

@@ -664,0 +649,0 @@ };

@@ -1,1 +0,1 @@

"use strict";function isImmutable(e){return!(!e||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function denormalizeImmutable(e,t,n,r){return Object.keys(e).reduce(function(t,i){var o=""+i;return t.has(o)?t.set(o,n(t.get(o),e[o],r)):t},t)}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},get$1=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,r)}if("value"in i)return i.value;var a=i.get;if(void 0!==a)return a.call(r)},inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},possibleConstructorReturn=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},set=function e(t,n,r,i){var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var a=Object.getPrototypeOf(t);null!==a&&e(a,n,r,i)}else if("value"in o&&o.writable)o.value=r;else{var u=o.set;void 0!==u&&u.call(i,r)}return r},getDefaultGetId=function(e){return function(t){return isImmutable(t)?t.get(e):t[e]}},EntitySchema=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(classCallCheck(this,e),!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");var i=r.idAttribute,o=void 0===i?"id":i,a=r.mergeStrategy,u=void 0===a?function(e,t){return _extends({},e,t)}:a,c=r.processStrategy,s=void 0===c?function(e){return _extends({},e)}:c;this._key=t,this._getId="function"==typeof o?o:getDefaultGetId(o),this._idAttribute=o,this._mergeStrategy=u,this._processStrategy=s,this.define(n)}return createClass(e,[{key:"define",value:function(e){this.schema=Object.keys(e).reduce(function(t,n){var r=e[n];return _extends({},t,defineProperty({},n,r))},this.schema||{})}},{key:"getId",value:function(e,t,n){return this._getId(e,t,n)}},{key:"merge",value:function(e,t){return this._mergeStrategy(e,t)}},{key:"normalize",value:function(e,t,n,r,i){var o=this,a=this._processStrategy(e,t,n);return Object.keys(this.schema).forEach(function(e){if(a.hasOwnProperty(e)&&"object"===_typeof(a[e])){var t=o.schema[e];a[e]=r(a[e],a,e,t,i)}}),i(this,a,e,t,n),this.getId(e,t,n)}},{key:"denormalize",value:function(e,t,n){var r=this,i=n(this,e);if("object"!==("undefined"==typeof i?"undefined":_typeof(i))||null===i)return i;if(isImmutable(i))return denormalizeImmutable(this.schema,i,t,n);var o=_extends({},i);return Object.keys(this.schema).forEach(function(e){if(o.hasOwnProperty(e)){var i=r.schema[e];o[e]=t(o[e],i,n)}}),o}},{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),e}(),PolymorphicSchema=function(){function e(t,n){classCallCheck(this,e),n&&(this._schemaAttribute="string"==typeof n?function(e){return e[n]}:n),this.define(t)}return createClass(e,[{key:"define",value:function(e){this.schema=e}},{key:"getSchemaAttribute",value:function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)}},{key:"inferSchema",value:function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]}},{key:"normalizeValue",value:function(e,t,n,r,i){var o=this.inferSchema(e,t,n);if(!o)return e;var a=r(e,t,n,o,i);return this.isSingleSchema||void 0===a||null===a?a:{id:a,schema:this.getSchemaAttribute(e,t,n)}}},{key:"denormalizeValue",value:function(e,t,n){if(!this.isSingleSchema&&!e.schema)return e;var r=this.isSingleSchema?this.schema:this.schema[e.schema];return t(e.id||e,r,n)}},{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),UnionSchema=function(e){function t(e,n){if(classCallCheck(this,t),!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n))}return inherits(t,e),createClass(t,[{key:"normalize",value:function(e,t,n,r,i){return this.normalizeValue(e,t,n,r,i)}},{key:"denormalize",value:function(e,t,n){return this.denormalizeValue(e,t,n)}}]),t}(PolymorphicSchema),ValuesSchema=function(e){function t(){return classCallCheck(this,t),possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return inherits(t,e),createClass(t,[{key:"normalize",value:function(e,t,n,r,i){var o=this;return Object.keys(e).reduce(function(t,n,a){var u=e[n];return void 0!==u&&null!==u?_extends({},t,defineProperty({},n,o.normalizeValue(u,e,n,r,i))):t},{})}},{key:"denormalize",value:function(e,t,n){var r=this;return Object.keys(e).reduce(function(i,o){var a=e[o];return _extends({},i,defineProperty({},o,r.denormalizeValue(a,t,n)))},{})}}]),t}(PolymorphicSchema),validateSchema=function(e){var t=Array.isArray(e);if(t&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},getValues=function(e){return Array.isArray(e)?e:Object.keys(e).map(function(t){return e[t]})},normalize$2=function(e,t,n,r,i,o){e=validateSchema(e);var a=getValues(t);return a.map(function(t,a){return i(t,n,r,e,o)})},denormalize$2=function(e,t,n,r){return e=validateSchema(e),Array.isArray(t)?t.map(function(t){return n(t,e,r)}):t},ArraySchema=function(e){function t(){return classCallCheck(this,t),possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return inherits(t,e),createClass(t,[{key:"normalize",value:function(e,t,n,r,i){var o=this,a=getValues(e);return a.map(function(e,a){return o.normalizeValue(e,t,n,r,i)}).filter(function(e){return void 0!==e&&null!==e})}},{key:"denormalize",value:function(e,t,n){var r=this;return Array.isArray(e)?e.map(function(e){return r.denormalizeValue(e,t,n)}):e}}]),t}(PolymorphicSchema),_normalize=function(e,t,n,r,i,o){var a=_extends({},t);return Object.keys(e).forEach(function(n){var r=e[n],u=i(t[n],t,n,r,o);void 0===u||null===u?delete a[n]:a[n]=u}),a},_denormalize=function(e,t,n,r){if(isImmutable(t))return denormalizeImmutable(e,t,n,r);var i=_extends({},t);return Object.keys(e).forEach(function(t){i[t]&&(i[t]=n(i[t],e[t],r))}),i},ObjectSchema=function(){function e(t){classCallCheck(this,e),this.define(t)}return createClass(e,[{key:"define",value:function(e){this.schema=Object.keys(e).reduce(function(t,n){var r=e[n];return _extends({},t,defineProperty({},n,r))},this.schema||{})}},{key:"normalize",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return _normalize.apply(void 0,[this.schema].concat(t))}},{key:"denormalize",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return _denormalize.apply(void 0,[this.schema].concat(t))}}]),e}(),visit=function e(t,n,r,i,o){if("object"!==("undefined"==typeof t?"undefined":_typeof(t))||!t)return t;if("object"===("undefined"==typeof i?"undefined":_typeof(i))&&(!i.normalize||"function"!=typeof i.normalize)){var a=Array.isArray(i)?normalize$2:_normalize;return a(i,t,n,r,e,o)}return i.normalize(t,n,r,e,o)},addEntities=function(e){return function(t,n,r,i,o){var a=t.key,u=t.getId(r,i,o);a in e||(e[a]={});var c=e[a][u];c?e[a][u]=t.merge(c,n):e[a][u]=n}},schema={Array:ArraySchema,Entity:EntitySchema,Object:ObjectSchema,Union:UnionSchema,Values:ValuesSchema},normalize$1=function(e,t){if(!e||"object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+("undefined"==typeof e?"undefined":_typeof(e))+'".');var n={},r=addEntities(n),i=visit(e,e,null,t,r);return{entities:n,result:i}},unvisit=function e(t,n,r){if("object"===("undefined"==typeof n?"undefined":_typeof(n))&&(!n.denormalize||"function"!=typeof n.denormalize)){var i=Array.isArray(n)?denormalize$2:_denormalize;return i(n,t,e,r)}return void 0===t||null===t?t:n.denormalize(t,e,r)},getEntity=function(e,t,n,r){return"object"===("undefined"==typeof e?"undefined":_typeof(e))?e:r?n.getIn([t,e.toString()]):n[t][e]},getEntities=function(e,t,n){return function(r,i){var o=r.key;t[o]||(t[o]={});var a=getEntity(i,o,e,n);if("object"!==("undefined"==typeof a?"undefined":_typeof(a))||null===a)return a;var u=r.getId(a);return t[o][u]?u:(t[o][u]=!0,a)}},denormalize$1=function(e,t,n){if(!e)return e;var r=isImmutable(n),i=getEntities(n,{},r);return unvisit(e,t,i)};exports.schema=schema,exports.normalize=normalize$1,exports.denormalize=denormalize$1;
"use strict";function isImmutable(e){return!(!e||!(e.hasOwnProperty("__ownerID")||e._map&&e._map.hasOwnProperty("__ownerID")))}function denormalizeImmutable(e,t,n,r){return Object.keys(e).reduce(function(t,i){var o=""+i;return t.has(o)?t.set(o,n(t.get(o),e[o],r)):t},t)}Object.defineProperty(exports,"__esModule",{value:!0});var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},classCallCheck=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),defineProperty=function(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e},_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},get$1=function e(t,n,r){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var o=Object.getPrototypeOf(t);return null===o?void 0:e(o,n,r)}if("value"in i)return i.value;var a=i.get;if(void 0!==a)return a.call(r)},inherits=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},possibleConstructorReturn=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},set=function e(t,n,r,i){var o=Object.getOwnPropertyDescriptor(t,n);if(void 0===o){var a=Object.getPrototypeOf(t);null!==a&&e(a,n,r,i)}else if("value"in o&&o.writable)o.value=r;else{var u=o.set;void 0!==u&&u.call(i,r)}return r},getDefaultGetId=function(e){return function(t){return isImmutable(t)?t.get(e):t[e]}},EntitySchema=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(classCallCheck(this,e),!t||"string"!=typeof t)throw new Error("Expected a string key for Entity, but found "+t+".");var i=r.idAttribute,o=void 0===i?"id":i,a=r.mergeStrategy,u=void 0===a?function(e,t){return _extends({},e,t)}:a,c=r.processStrategy,s=void 0===c?function(e){return _extends({},e)}:c;this._key=t,this._getId="function"==typeof o?o:getDefaultGetId(o),this._idAttribute=o,this._mergeStrategy=u,this._processStrategy=s,this.define(n)}return createClass(e,[{key:"define",value:function(e){this.schema=Object.keys(e).reduce(function(t,n){var r=e[n];return _extends({},t,defineProperty({},n,r))},this.schema||{})}},{key:"getId",value:function(e,t,n){return this._getId(e,t,n)}},{key:"merge",value:function(e,t){return this._mergeStrategy(e,t)}},{key:"normalize",value:function(e,t,n,r,i){var o=this,a=this._processStrategy(e,t,n);return Object.keys(this.schema).forEach(function(e){if(a.hasOwnProperty(e)&&"object"===_typeof(a[e])){var t=o.schema[e];a[e]=r(a[e],a,e,t,i)}}),i(this,a,e,t,n),this.getId(e,t,n)}},{key:"denormalize",value:function(e,t,n){var r=this,i=n(this,e);if("object"!==("undefined"==typeof i?"undefined":_typeof(i))||null===i)return i;if(isImmutable(i))return denormalizeImmutable(this.schema,i,t,n);var o=_extends({},i);return Object.keys(this.schema).forEach(function(e){if(o.hasOwnProperty(e)){var i=r.schema[e];o[e]=t(o[e],i,n)}}),o}},{key:"key",get:function(){return this._key}},{key:"idAttribute",get:function(){return this._idAttribute}}]),e}(),PolymorphicSchema=function(){function e(t,n){classCallCheck(this,e),n&&(this._schemaAttribute="string"==typeof n?function(e){return e[n]}:n),this.define(t)}return createClass(e,[{key:"define",value:function(e){this.schema=e}},{key:"getSchemaAttribute",value:function(e,t,n){return!this.isSingleSchema&&this._schemaAttribute(e,t,n)}},{key:"inferSchema",value:function(e,t,n){if(this.isSingleSchema)return this.schema;var r=this.getSchemaAttribute(e,t,n);return this.schema[r]}},{key:"normalizeValue",value:function(e,t,n,r,i){var o=this.inferSchema(e,t,n);if(!o)return e;var a=r(e,t,n,o,i);return this.isSingleSchema||void 0===a||null===a?a:{id:a,schema:this.getSchemaAttribute(e,t,n)}}},{key:"denormalizeValue",value:function(e,t,n){if(!this.isSingleSchema&&!e.schema)return e;var r=this.isSingleSchema?this.schema:this.schema[e.schema];return t(e.id||e,r,n)}},{key:"isSingleSchema",get:function(){return!this._schemaAttribute}}]),e}(),UnionSchema=function(e){function t(e,n){if(classCallCheck(this,t),!n)throw new Error('Expected option "schemaAttribute" not found on UnionSchema.');return possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n))}return inherits(t,e),createClass(t,[{key:"normalize",value:function(e,t,n,r,i){return this.normalizeValue(e,t,n,r,i)}},{key:"denormalize",value:function(e,t,n){return this.denormalizeValue(e,t,n)}}]),t}(PolymorphicSchema),ValuesSchema=function(e){function t(){return classCallCheck(this,t),possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return inherits(t,e),createClass(t,[{key:"normalize",value:function(e,t,n,r,i){var o=this;return Object.keys(e).reduce(function(t,n,a){var u=e[n];return void 0!==u&&null!==u?_extends({},t,defineProperty({},n,o.normalizeValue(u,e,n,r,i))):t},{})}},{key:"denormalize",value:function(e,t,n){var r=this;return Object.keys(e).reduce(function(i,o){var a=e[o];return _extends({},i,defineProperty({},o,r.denormalizeValue(a,t,n)))},{})}}]),t}(PolymorphicSchema),validateSchema=function(e){var t=Array.isArray(e);if(t&&e.length>1)throw new Error("Expected schema definition to be a single schema, but found "+e.length+".");return e[0]},getValues=function(e){return Array.isArray(e)?e:Object.keys(e).map(function(t){return e[t]})},normalize$2=function(e,t,n,r,i,o){e=validateSchema(e);var a=getValues(t);return a.map(function(t,a){return i(t,n,r,e,o)})},denormalize$2=function(e,t,n,r){return e=validateSchema(e),Array.isArray(t)?t.map(function(t){return n(t,e,r)}):t},ArraySchema=function(e){function t(){return classCallCheck(this,t),possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return inherits(t,e),createClass(t,[{key:"normalize",value:function(e,t,n,r,i){var o=this,a=getValues(e);return a.map(function(e,a){return o.normalizeValue(e,t,n,r,i)}).filter(function(e){return void 0!==e&&null!==e})}},{key:"denormalize",value:function(e,t,n){var r=this;return Array.isArray(e)?e.map(function(e){return r.denormalizeValue(e,t,n)}):e}}]),t}(PolymorphicSchema),_normalize=function(e,t,n,r,i,o){var a=_extends({},t);return Object.keys(e).forEach(function(n){var r=e[n],u=i(t[n],t,n,r,o);void 0===u||null===u?delete a[n]:a[n]=u}),a},_denormalize=function(e,t,n,r){if(isImmutable(t))return denormalizeImmutable(e,t,n,r);var i=_extends({},t);return Object.keys(e).forEach(function(t){i[t]&&(i[t]=n(i[t],e[t],r))}),i},ObjectSchema=function(){function e(t){classCallCheck(this,e),this.define(t)}return createClass(e,[{key:"define",value:function(e){this.schema=Object.keys(e).reduce(function(t,n){var r=e[n];return _extends({},t,defineProperty({},n,r))},this.schema||{})}},{key:"normalize",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return _normalize.apply(void 0,[this.schema].concat(t))}},{key:"denormalize",value:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return _denormalize.apply(void 0,[this.schema].concat(t))}}]),e}(),visit=function e(t,n,r,i,o){if("object"!==("undefined"==typeof t?"undefined":_typeof(t))||!t)return t;if("object"===("undefined"==typeof i?"undefined":_typeof(i))&&(!i.normalize||"function"!=typeof i.normalize)){var a=Array.isArray(i)?normalize$2:_normalize;return a(i,t,n,r,e,o)}return i.normalize(t,n,r,e,o)},addEntities=function(e){return function(t,n,r,i,o){var a=t.key,u=t.getId(r,i,o);a in e||(e[a]={});var c=e[a][u];c?e[a][u]=t.merge(c,n):e[a][u]=n}},schema={Array:ArraySchema,Entity:EntitySchema,Object:ObjectSchema,Union:UnionSchema,Values:ValuesSchema},normalize$1=function(e,t){if(!e||"object"!==("undefined"==typeof e?"undefined":_typeof(e)))throw new Error('Unexpected input given to normalize. Expected type to be "object", found "'+("undefined"==typeof e?"undefined":_typeof(e))+'".');var n={},r=addEntities(n),i=visit(e,e,null,t,r);return{entities:n,result:i}},unvisit=function e(t,n,r){if("object"===("undefined"==typeof n?"undefined":_typeof(n))&&(!n.denormalize||"function"!=typeof n.denormalize)){var i=Array.isArray(n)?denormalize$2:_denormalize;return i(n,t,e,r)}return void 0===t||null===t?t:n.denormalize(t,e,r)},getEntity=function(e,t,n,r){return"object"===("undefined"==typeof e?"undefined":_typeof(e))?e:r?n.getIn([t,e.toString()]):n[t][e]},getEntities=function(e,t){return function(n,r){var i=n.key;return getEntity(r,i,e,t)}},denormalize$1=function(e,t,n){if(!e)return e;var r=isImmutable(n),i=getEntities(n,r);return unvisit(e,t,i)};exports.schema=schema,exports.normalize=normalize$1,exports.denormalize=denormalize$1;

@@ -109,22 +109,7 @@ 'use strict';

var getEntities = function getEntities(entities, visitedEntities, isImmutable) {
var getEntities = function getEntities(entities, isImmutable) {
return function (schema, entityOrId) {
var schemaKey = schema.key;
if (!visitedEntities[schemaKey]) {
visitedEntities[schemaKey] = {};
}
var entity = getEntity(entityOrId, schemaKey, entities, isImmutable);
if ((typeof entity === 'undefined' ? 'undefined' : _typeof(entity)) !== 'object' || entity === null) {
return entity;
}
var id = schema.getId(entity);
if (visitedEntities[schemaKey][id]) {
return id;
}
visitedEntities[schemaKey][id] = true;
return entity;
return getEntity(entityOrId, schemaKey, entities, isImmutable);
};

@@ -139,4 +124,4 @@ };

var isImmutable = ImmutableUtils.isImmutable(entities);
var getDenormalizedEntity = getEntities(entities, {}, isImmutable);
var getDenormalizedEntity = getEntities(entities, isImmutable);
return unvisit(input, schema, getDenormalizedEntity);
};
{
"name": "normalizr",
"version": "3.2.0",
"version": "3.2.1",
"description": "Normalizes and denormalizes JSON according to schema for Redux and Flux applications",

@@ -5,0 +5,0 @@ "bugs": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc