json-api-denormalizr
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -5,2 +5,7 @@ # Change Log | ||
<a name="0.1.5"></a> | ||
## [0.1.5](https://github.com/willsoto/json-api-denormalizr/compare/v0.1.4...v0.1.5) (2017-07-03) | ||
<a name="0.1.4"></a> | ||
@@ -7,0 +12,0 @@ ## [0.1.4](https://github.com/willsoto/json-api-denormalizr/compare/v0.1.3...v0.1.4) (2017-07-03) |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lodash")):"function"==typeof define&&define.amd?define(["exports","lodash"],t):t(e["json-api-denormalizr"]=e["json-api-denormalizr"]||{},e._)}(this,function(e,t){"use strict";t=t&&"default"in t?t.default:t;var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])}return e},r=function(e,i,r){for(var o in i){var a=i[o].data;a&&(t.isArray(a)?e[o]=t.map(a,function(e){return n(e,r)}):e[o]=n(a,r))}return e},n=function(e,t){var n=t[e.type][e.id],o=i({id:n.id},n.attributes);return n.relationships&&(o=r(o,n.relationships,t)),o};e.denormalize=function(e,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};o.pathToEntities&&(e=t.get(e,o.pathToEntities));var a=i({id:n.id},n.attributes);return n.relationships&&(a=r(a,n.relationships,e)),a},Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t["json-api-denormalizr"]=t["json-api-denormalizr"]||{})}(this,function(t){"use strict";var e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},r=function(t,e,r){for(var n in e){var o=e[n].data;o&&(Array.isArray(o)?t[n]=o.map(function(t){return i(t,r)}):t[n]=i(o,r))}return t},i=function(t,i){var n=i[t.type][t.id],o=e({id:n.id},n.attributes);return n.relationships&&(o=r(o,n.relationships,i)),o};t.denormalize=function(t,i){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n.pathToEntities&&(t=t[n.pathToEntities]);var o=e({id:i.id},i.attributes);return i.relationships&&(o=r(o,i.relationships,t)),o},Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "json-api-denormalizr", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Denormalize JSON API responses for Redux applications", | ||
@@ -60,5 +60,3 @@ "main": "./dist/index.js", | ||
}, | ||
"dependencies": { | ||
"lodash": "^4.17.4" | ||
}, | ||
"dependencies": {}, | ||
"lint-staged": { | ||
@@ -65,0 +63,0 @@ "*.js": ["prettier --single-quote --print-width 120 --write", "eslint --fix", "git add"], |
@@ -1,6 +0,4 @@ | ||
import _ from 'lodash'; | ||
export const denormalize = (state, entity, options = {}) => { | ||
if (options.pathToEntities) { | ||
state = _.get(state, options.pathToEntities); | ||
state = state[options.pathToEntities]; | ||
} | ||
@@ -29,4 +27,4 @@ | ||
if (_.isArray(data)) { | ||
entity[type] = _.map(data, item => createRelationship(item, state)); | ||
if (Array.isArray(data)) { | ||
entity[type] = data.map(item => createRelationship(item, state)); | ||
} else { | ||
@@ -33,0 +31,0 @@ entity[type] = createRelationship(data, state); |
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
0
2
20942
44
- Removedlodash@^4.17.4
- Removedlodash@4.17.21(transitive)