diff --git a/lib/index.js b/lib/index.js index cab056f..309c0a6 100644 --- a/lib/index.js +++ b/lib/index.js @@ -157,11 +157,15 @@ var deserialize = function deserialize(resp) { __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mapRelationships", function() { return mapRelationships; }); /* harmony import */ var _flattenAttributes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4); -function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } -function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } -function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } +function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } + +function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } + +function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } @@ -186,7 +190,7 @@ var findResource = function findResource(rel, included) { var deserializeIncluded = function deserializeIncluded(rel, included) { var resource = findResource(rel, included); - if (!resource) return []; + if (!resource) return [undefined, included]; var filteredIncluded = included.map(function (res) { if (res !== resource) return res; @@ -195,7 +199,7 @@ var deserializeIncluded = function deserializeIncluded(rel, included) { return filter; }); - return [_objectSpread({}, rel, {}, Object(_flattenAttributes__WEBPACK_IMPORTED_MODULE_0__["flattenAttributes"])(resource)), filteredIncluded]; + return [_objectSpread(_objectSpread({}, rel), Object(_flattenAttributes__WEBPACK_IMPORTED_MODULE_0__["flattenAttributes"])(resource)), filteredIncluded]; }; var mapRelationships = function mapRelationships(resource, included) { @@ -270,7 +274,7 @@ var asAttributes = function asAttributes(_ref) { rest = _objectWithoutProperties(_ref, ["attributes"]); if (!attributes || attributes.constructor !== Object) return rest; - return _objectSpread({}, rest, {}, attributes); + return _objectSpread(_objectSpread({}, rest), attributes); }; var flattenAttributes = function flattenAttributes(data) { diff --git a/package.json b/package.json index 540c96a..e331b3c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "deserialize-json-api", - "version": "1.3.1", + "version": "1.3.2", "description": "Immutable json:api deserializer", "main": "lib/index.js", "repository": "https://github.com/weilandia/deserialize-json-api",