kitsu-core
Advanced tools
Comparing version 10.0.0-alpha.21 to 10.0.0-alpha.22
@@ -6,2 +6,13 @@ # Change Log | ||
# [10.0.0-alpha.22](https://github.com/wopian/kitsu/compare/v10.0.0-alpha.21...v10.0.0-alpha.22) (2022-03-04) | ||
### Bug Fixes | ||
* **kitsu-core:** use typeof instead of constructor comparison for checking if Object ([#654](https://github.com/wopian/kitsu/issues/654)) ([af9d893](https://github.com/wopian/kitsu/commit/af9d8937117abcd678ec45e10815b6e8256a03da)) | ||
# [10.0.0-alpha.21](https://github.com/wopian/kitsu/compare/v10.0.0-alpha.20...v10.0.0-alpha.21) (2022-02-17) | ||
@@ -8,0 +19,0 @@ |
@@ -7,5 +7,3 @@ 'use strict'; | ||
if (typeof data === 'object' && data !== null) { | ||
var _data$attributes; | ||
if (Array.isArray(data)) data.map(el => deattribute(el));else if (((_data$attributes = data.attributes) === null || _data$attributes === void 0 ? void 0 : _data$attributes.constructor) === Object) { | ||
if (Array.isArray(data)) data.map(el => deattribute(el));else if (typeof data.attributes === 'object' && !Array.isArray(data.attributes) && data.attributes !== null) { | ||
for (const key of Object.keys(data.attributes)) { | ||
@@ -12,0 +10,0 @@ if (!data.attributes.attributes) { |
@@ -22,8 +22,8 @@ 'use strict'; | ||
function deserialise(response) { | ||
var _response$data, _response$data2; | ||
var _response$data; | ||
if (!response) return; | ||
if (Array.isArray(response.data)) response = deserialiseArray(response);else if (response.included) response.data = linkRelationships.linkRelationships(response.data, response.included);else if (((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.constructor) === Object) response.data = linkRelationships.linkRelationships(response.data); | ||
if (Array.isArray(response.data)) response = deserialiseArray(response);else if (response.included) response.data = linkRelationships.linkRelationships(response.data, response.included);else if (typeof response.data === 'object' && response.data !== null) response.data = linkRelationships.linkRelationships(response.data); | ||
delete response.included; | ||
if ((_response$data2 = response.data) !== null && _response$data2 !== void 0 && _response$data2.attributes) response.data = deattribute.deattribute(response.data); | ||
if ((_response$data = response.data) !== null && _response$data !== void 0 && _response$data.attributes) response.data = deattribute.deattribute(response.data); | ||
return response; | ||
@@ -30,0 +30,0 @@ } |
@@ -11,5 +11,3 @@ (function (global, factory) { | ||
if (typeof data === 'object' && data !== null) { | ||
var _data$attributes; | ||
if (Array.isArray(data)) data.map(el => deattribute(el));else if (((_data$attributes = data.attributes) === null || _data$attributes === void 0 ? void 0 : _data$attributes.constructor) === Object) { | ||
if (Array.isArray(data)) data.map(el => deattribute(el));else if (typeof data.attributes === 'object' && !Array.isArray(data.attributes) && data.attributes !== null) { | ||
for (const key of Object.keys(data.attributes)) { | ||
@@ -131,3 +129,3 @@ if (!data.attributes.attributes) { | ||
if (Object.keys(relationships || []).length === 0 && (relationships === null || relationships === void 0 ? void 0 : relationships.constructor) === Object) { | ||
if (Object.keys(relationships || []).length === 0 && typeof relationships === 'object' && !Array.isArray(relationships) && relationships !== null) { | ||
delete data.relationships; | ||
@@ -151,8 +149,8 @@ } | ||
function deserialise(response) { | ||
var _response$data, _response$data2; | ||
var _response$data; | ||
if (!response) return; | ||
if (Array.isArray(response.data)) response = deserialiseArray(response);else if (response.included) response.data = linkRelationships(response.data, response.included);else if (((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.constructor) === Object) response.data = linkRelationships(response.data); | ||
if (Array.isArray(response.data)) response = deserialiseArray(response);else if (response.included) response.data = linkRelationships(response.data, response.included);else if (typeof response.data === 'object' && response.data !== null) response.data = linkRelationships(response.data); | ||
delete response.included; | ||
if ((_response$data2 = response.data) !== null && _response$data2 !== void 0 && _response$data2.attributes) response.data = deattribute(response.data); | ||
if ((_response$data = response.data) !== null && _response$data !== void 0 && _response$data.attributes) response.data = deattribute(response.data); | ||
return response; | ||
@@ -240,3 +238,3 @@ } | ||
if (!data.attributes) data.attributes = {}; | ||
if (key === 'links' && (typeof node.self === 'string' || typeof node.related === 'string')) data.links = node;else if (key === 'meta' && node.constructor === Object) data.meta = node;else data.attributes[key] = node; | ||
if (key === 'links' && (typeof node.self === 'string' || typeof node.related === 'string')) data.links = node;else if (key === 'meta' && typeof node === 'object' && !Array.isArray(node) && node !== null) data.meta = node;else data.attributes[key] = node; | ||
return data; | ||
@@ -279,3 +277,3 @@ } | ||
if (node !== null && (node === null || node === void 0 ? void 0 : node.constructor) === Object && hasID(node)) { | ||
if (typeof node === 'object' && !Array.isArray(node) && node !== null && hasID(node)) { | ||
data = serialiseRelation(node, nodeType, key, data); | ||
@@ -282,0 +280,0 @@ } else if (key !== 'id' && key !== 'type') { |
@@ -76,3 +76,3 @@ 'use strict'; | ||
if (Object.keys(relationships || []).length === 0 && (relationships === null || relationships === void 0 ? void 0 : relationships.constructor) === Object) { | ||
if (Object.keys(relationships || []).length === 0 && typeof relationships === 'object' && !Array.isArray(relationships) && relationships !== null) { | ||
delete data.relationships; | ||
@@ -79,0 +79,0 @@ } |
@@ -69,3 +69,3 @@ 'use strict'; | ||
if (!data.attributes) data.attributes = {}; | ||
if (key === 'links' && (typeof node.self === 'string' || typeof node.related === 'string')) data.links = node;else if (key === 'meta' && node.constructor === Object) data.meta = node;else data.attributes[key] = node; | ||
if (key === 'links' && (typeof node.self === 'string' || typeof node.related === 'string')) data.links = node;else if (key === 'meta' && typeof node === 'object' && !Array.isArray(node) && node !== null) data.meta = node;else data.attributes[key] = node; | ||
return data; | ||
@@ -108,3 +108,3 @@ } | ||
if (node !== null && (node === null || node === void 0 ? void 0 : node.constructor) === Object && hasID(node)) { | ||
if (typeof node === 'object' && !Array.isArray(node) && node !== null && hasID(node)) { | ||
data = serialiseRelation(node, nodeType, key, data); | ||
@@ -111,0 +111,0 @@ } else if (key !== 'id' && key !== 'type') { |
{ | ||
"version": "10.0.0-alpha.21", | ||
"version": "10.0.0-alpha.22", | ||
"name": "kitsu-core", | ||
@@ -4,0 +4,0 @@ "description": "Simple, lightweight & framework agnostic JSON:API (de)serialsation components", |
@@ -138,3 +138,3 @@ <h1 align=center>Kitsu Core</h1> | ||
[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/a130f763dbc5b721b289d7ec27d780c1dacdb28e/packages/kitsu-core/src/camel/index.js#L14-L14 "Source code on GitHub") | ||
[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/af9d8937117abcd678ec45e10815b6e8256a03da/packages/kitsu-core/src/camel/index.js#L14-L14 "Source code on GitHub") | ||
@@ -165,3 +165,3 @@ Converts kebab-case and snake_case into camelCase | ||
[packages/kitsu-core/src/deattribute/index.js:29-51](https://github.com/wopian/kitsu/blob/a130f763dbc5b721b289d7ec27d780c1dacdb28e/packages/kitsu-core/src/deattribute/index.js#L29-L51 "Source code on GitHub") | ||
[packages/kitsu-core/src/deattribute/index.js:29-51](https://github.com/wopian/kitsu/blob/af9d8937117abcd678ec45e10815b6e8256a03da/packages/kitsu-core/src/deattribute/index.js#L29-L51 "Source code on GitHub") | ||
@@ -208,3 +208,3 @@ Hoists attributes to be top-level | ||
[packages/kitsu-core/src/deserialise/index.js:57-72](https://github.com/wopian/kitsu/blob/a130f763dbc5b721b289d7ec27d780c1dacdb28e/packages/kitsu-core/src/deserialise/index.js#L57-L72 "Source code on GitHub") | ||
[packages/kitsu-core/src/deserialise/index.js:57-72](https://github.com/wopian/kitsu/blob/af9d8937117abcd678ec45e10815b6e8256a03da/packages/kitsu-core/src/deserialise/index.js#L57-L72 "Source code on GitHub") | ||
@@ -259,3 +259,3 @@ Deserialises a JSON-API response | ||
[packages/kitsu-core/src/error/index.js:27-33](https://github.com/wopian/kitsu/blob/a130f763dbc5b721b289d7ec27d780c1dacdb28e/packages/kitsu-core/src/error/index.js#L27-L33 "Source code on GitHub") | ||
[packages/kitsu-core/src/error/index.js:27-33](https://github.com/wopian/kitsu/blob/af9d8937117abcd678ec45e10815b6e8256a03da/packages/kitsu-core/src/error/index.js#L27-L33 "Source code on GitHub") | ||
@@ -297,3 +297,3 @@ Uniform error handling for Axios, JSON:API and internal package errors. Mutated Error object is rethrown to the caller. | ||
[packages/kitsu-core/src/filterIncludes/index.js:33-46](https://github.com/wopian/kitsu/blob/a130f763dbc5b721b289d7ec27d780c1dacdb28e/packages/kitsu-core/src/filterIncludes/index.js#L33-L46 "Source code on GitHub") | ||
[packages/kitsu-core/src/filterIncludes/index.js:33-46](https://github.com/wopian/kitsu/blob/af9d8937117abcd678ec45e10815b6e8256a03da/packages/kitsu-core/src/filterIncludes/index.js#L33-L46 "Source code on GitHub") | ||
@@ -338,3 +338,3 @@ Filters includes for the specific relationship requested | ||
[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/a130f763dbc5b721b289d7ec27d780c1dacdb28e/packages/kitsu-core/src/kebab/index.js#L11-L11 "Source code on GitHub") | ||
[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/af9d8937117abcd678ec45e10815b6e8256a03da/packages/kitsu-core/src/kebab/index.js#L11-L11 "Source code on GitHub") | ||
@@ -357,3 +357,3 @@ Converts camelCase into kebab-case | ||
[packages/kitsu-core/src/linkRelationships/index.js:108-128](https://github.com/wopian/kitsu/blob/a130f763dbc5b721b289d7ec27d780c1dacdb28e/packages/kitsu-core/src/linkRelationships/index.js#L108-L128 "Source code on GitHub") | ||
[packages/kitsu-core/src/linkRelationships/index.js:108-128](https://github.com/wopian/kitsu/blob/af9d8937117abcd678ec45e10815b6e8256a03da/packages/kitsu-core/src/linkRelationships/index.js#L108-L128 "Source code on GitHub") | ||
@@ -397,3 +397,3 @@ Links relationships to included data | ||
[packages/kitsu-core/src/query/index.js:33-42](https://github.com/wopian/kitsu/blob/a130f763dbc5b721b289d7ec27d780c1dacdb28e/packages/kitsu-core/src/query/index.js#L33-L42 "Source code on GitHub") | ||
[packages/kitsu-core/src/query/index.js:33-42](https://github.com/wopian/kitsu/blob/af9d8937117abcd678ec45e10815b6e8256a03da/packages/kitsu-core/src/query/index.js#L33-L42 "Source code on GitHub") | ||
@@ -426,3 +426,3 @@ Constructs a URL query string for JSON:API parameters | ||
[packages/kitsu-core/src/serialise/index.js:213-224](https://github.com/wopian/kitsu/blob/a130f763dbc5b721b289d7ec27d780c1dacdb28e/packages/kitsu-core/src/serialise/index.js#L213-L224 "Source code on GitHub") | ||
[packages/kitsu-core/src/serialise/index.js:213-224](https://github.com/wopian/kitsu/blob/af9d8937117abcd678ec45e10815b6e8256a03da/packages/kitsu-core/src/serialise/index.js#L213-L224 "Source code on GitHub") | ||
@@ -472,3 +472,3 @@ Serialises an object into a JSON-API structure | ||
[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/a130f763dbc5b721b289d7ec27d780c1dacdb28e/packages/kitsu-core/src/snake/index.js#L11-L11 "Source code on GitHub") | ||
[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/af9d8937117abcd678ec45e10815b6e8256a03da/packages/kitsu-core/src/snake/index.js#L11-L11 "Source code on GitHub") | ||
@@ -491,3 +491,3 @@ Converts camelCase into snake_case | ||
[packages/kitsu-core/src/splitModel/index.js:29-39](https://github.com/wopian/kitsu/blob/a130f763dbc5b721b289d7ec27d780c1dacdb28e/packages/kitsu-core/src/splitModel/index.js#L29-L39 "Source code on GitHub") | ||
[packages/kitsu-core/src/splitModel/index.js:29-39](https://github.com/wopian/kitsu/blob/af9d8937117abcd678ec45e10815b6e8256a03da/packages/kitsu-core/src/splitModel/index.js#L29-L39 "Source code on GitHub") | ||
@@ -494,0 +494,0 @@ Split model name from the model's resource URL |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
90427
1131