kitsu-core
Advanced tools
Comparing version 9.1.18 to 9.1.19
@@ -6,2 +6,14 @@ # Change Log | ||
## [9.1.19](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/compare/v9.1.18...v9.1.19) (2021-06-07) | ||
### Chores | ||
* **release:** update documentation ([3adac5a](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/3adac5a)) | ||
## [9.1.18](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/compare/v9.1.17...v9.1.18) (2021-01-06) | ||
@@ -8,0 +20,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).kitsuCore={})}(this,(function(t){"use strict";function e(t){var r;if("object"==typeof t&&null!==t)if(Array.isArray(t))t.map(t=>e(t));else if((null===(r=t.attributes)||void 0===r?void 0:r.constructor)===Object){for(const e of Object.keys(t.attributes))t.attributes.attributes||(t[e]=t.attributes[e]);t.attributes.attributes?t.attributes=t.attributes.attributes:delete t.attributes}return t}function r(t){if(t.response){const e=t.response.data;null!=e&&e.errors&&(t.errors=e.errors)}throw t}function n(t,{id:e,type:n}){try{if(e&&n){const r=t.filter(t=>t.id===e&&t.type===n)[0]||{id:e,type:n};return Object.assign({},r)}return{}}catch(t){r(t)}}function i({id:t,type:r,meta:i},a){const o=n(a,{id:t,type:r});return o.relationships&&l(o,a),i&&(o.meta=i),e(o)}function a(t,e,r){t[r]={},t.relationships[r].links&&(t[r].links=t.relationships[r].links),t[r].data=[];for(const n of t.relationships[r].data)t[r].data.push(i(n,e));delete t.relationships[r]}function o(t,e,r){t[r]={},t[r].data=i(t.relationships[r].data,e),t.relationships[r].links&&(t[r].links=t.relationships[r].links),delete t.relationships[r]}function s(t,e){t[e]={},t.relationships[e].links&&(t[e].links=t.relationships[e].links),delete t.relationships[e]}function l(t,e=[]){const{relationships:r}=t;for(const i in r){var n;Array.isArray(null===(n=r[i])||void 0===n?void 0:n.data)?a(t,e,i):r[i].data?o(t,e,i):s(t,i)}return 0===Object.keys(r||[]).length&&(null==r?void 0:r.constructor)===Object&&delete t.relationships,t}function u(t,e=null){const r=[];for(const a in t)Object.prototype.hasOwnProperty.call(t,a)&&r.push((n=t[a],i=e?"".concat(e,"[").concat(a,"]"):a,null!==n&&"object"==typeof n?u(n,i):encodeURIComponent(i)+"="+encodeURIComponent(n)));var n,i;return r.join("&")}function c(t,e,r,n){const i=new Error("".concat(n," requires an ID for the ").concat(e," type"));if(void 0===e)throw new Error("".concat(n," requires a resource type"));if(t){if("POST"!==n&&r.length>0)for(const t of r)if(!t.id)throw i}else{if("object"!=typeof r||0===Object.keys(r).length)throw new Error("".concat(n," requires an object or array body"));if("POST"!==n&&!r.id)throw i}}function d(t,e,r){e[r]={data:{}};for(const n of Object.keys(t[r].data)){const i=t[r].data[n];let a=e[r].data;n&&!["id","type"].includes(n)?a=b(i,n,a):a[n]=i}return e}function p(t,e,r){e[r]={data:[]};for(const n of t[r].data)e[r].data.push(n);return e}function f(t){let e={};for(const r in t){e=Array.isArray(t[r].data)?p(t,e,r):d(t,e,r)}return e}function y(t,e,r,n){return n.relationships||(n.relationships={}),t.type||(t.type=e),n.relationships[r]={data:Object.assign(t)},n.relationships=f(n.relationships),n}function h(t,e,r,n){return n.relationships||(n.relationships={}),n.relationships[r]={data:t.map(({id:t,type:r,...n})=>({id:t,type:r||e,attributes:Object.keys(n).length?n:void 0}))},n.relationships=f(n.relationships),n}function b(t,e,r){return r.attributes||(r.attributes={}),r.attributes[e]=t,r}function j(t){return Object.prototype.hasOwnProperty.call(t,"id")}function O(t,e,r,n){c(!1,t,e,r);let i={type:t=n.pluralTypes(n.camelCaseTypes(t))};null!=e&&e.id&&(i.id=String(e.id));for(const t in e){const r=e[t],a=n.pluralTypes(n.camelCaseTypes(t));null!==r&&(null==r?void 0:r.constructor)===Object&&j(r)?i=y(r,a,t,i):null!==r&&Array.isArray(r)&&r.length>0&&j(r[0])?i=h(r,a,t,i):"id"!==t&&"type"!==t&&(i=b(r,t,i))}return{data:i}}t.camel=t=>t.replace(/[-_][a-z\u00E0-\u00F6\u00F8-\u00FE]/g,t=>t.slice(1).toUpperCase()),t.deattribute=e,t.deserialise=function(t){var r,n;if(t)return Array.isArray(t.data)?t=function(t){for(let r of t.data)t.included&&(r=l(r,t.included)),r.relationships&&(r=l(r)),r.attributes&&(r=e(r)),t.data[t.data.indexOf(r)]=r;return t}(t):t.included?t.data=l(t.data,t.included):(null===(r=t.data)||void 0===r?void 0:r.constructor)===Object&&(t.data=l(t.data)),delete t.included,null!==(n=t.data)&&void 0!==n&&n.attributes&&(t.data=e(t.data)),t},t.error=r,t.filterIncludes=n,t.kebab=t=>t.charAt(0).toLowerCase()+t.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,t=>"-"+t.toLowerCase()),t.linkRelationships=l,t.query=u,t.serialise=function(t,e={},n="POST",i={}){try{return i.camelCaseTypes||(i.camelCaseTypes=t=>t),i.pluralTypes||(i.pluralTypes=t=>t),null===e||Array.isArray(e)&&0===e.length?{data:e}:Array.isArray(e)&&(null==e?void 0:e.length)>0?function(t,e,r,n){c(!0,t,e,r);const i=[];for(const a of e)i.push(O(t,a,r,n).data);return{data:i}}(t,e,n,i):O(t,e,n,i)}catch(t){throw r(t)}},t.snake=t=>t.charAt(0).toLowerCase()+t.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,t=>"_"+t.toLowerCase()),t.splitModel=function(t,e={}){e.pluralModel||(e.pluralModel=t=>t),e.resourceCase||(e.resourceCase=t=>t);const r=t.split("/"),n=r.pop();return r.push(e.pluralModel(e.resourceCase(n))),[n,r.join("/")]},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).kitsuCore={})}(this,(function(t){"use strict";function e(t){var r;if("object"==typeof t&&null!==t)if(Array.isArray(t))t.map(t=>e(t));else if((null===(r=t.attributes)||void 0===r?void 0:r.constructor)===Object){for(const e of Object.keys(t.attributes))t.attributes.attributes||(t[e]=t.attributes[e]);t.attributes.attributes?t.attributes=t.attributes.attributes:delete t.attributes}return t}function r(t){if(t.response){const e=t.response.data;null!=e&&e.errors&&(t.errors=e.errors)}throw t}function n(t,{id:e,type:n}){try{if(e&&n){const r=t.filter(t=>t.id===e&&t.type===n)[0]||{id:e,type:n};return Object.assign({},r)}return{}}catch(t){r(t)}}function i({id:t,type:r,meta:i},a){const s=n(a,{id:t,type:r});return s.relationships&&l(s,a),i&&(s.meta=i),e(s)}function a(t,e,r){t[r]={},t.relationships[r].links&&(t[r].links=t.relationships[r].links),t[r].data=[];for(const n of t.relationships[r].data)t[r].data.push(i(n,e));delete t.relationships[r]}function s(t,e,r){t[r]={},t[r].data=i(t.relationships[r].data,e),t.relationships[r].links&&(t[r].links=t.relationships[r].links),delete t.relationships[r]}function o(t,e){t[e]={},t.relationships[e].links&&(t[e].links=t.relationships[e].links),delete t.relationships[e]}function l(t,e=[]){const{relationships:r}=t;for(const i in r){var n;Array.isArray(null===(n=r[i])||void 0===n?void 0:n.data)?a(t,e,i):r[i].data?s(t,e,i):o(t,i)}return 0===Object.keys(r||[]).length&&(null==r?void 0:r.constructor)===Object&&delete t.relationships,t}function u(t,e=null){const r=[];for(const a in t)Object.prototype.hasOwnProperty.call(t,a)&&r.push((n=t[a],i=e?`${e}[${a}]`:a,null!==n&&"object"==typeof n?u(n,i):encodeURIComponent(i)+"="+encodeURIComponent(n)));var n,i;return r.join("&")}function c(t,e,r,n){const i=new Error(`${n} requires an ID for the ${e} type`);if(void 0===e)throw new Error(n+" requires a resource type");if(t){if("POST"!==n&&r.length>0)for(const t of r)if(!t.id)throw i}else{if("object"!=typeof r||0===Object.keys(r).length)throw new Error(n+" requires an object or array body");if("POST"!==n&&!r.id)throw i}}function d(t,e,r){e[r]={data:{}};for(const n of Object.keys(t[r].data)){const i=t[r].data[n];let a=e[r].data;n&&!["id","type"].includes(n)?a=b(i,n,a):a[n]=i}return e}function p(t,e,r){e[r]={data:[]};for(const n of t[r].data)e[r].data.push(n);return e}function f(t){let e={};for(const r in t){e=Array.isArray(t[r].data)?p(t,e,r):d(t,e,r)}return e}function y(t,e,r,n){return n.relationships||(n.relationships={}),t.type||(t.type=e),n.relationships[r]={data:Object.assign(t)},n.relationships=f(n.relationships),n}function h(t,e,r,n){return n.relationships||(n.relationships={}),n.relationships[r]={data:t.map(({id:t,type:r,...n})=>({id:t,type:r||e,attributes:Object.keys(n).length?n:void 0}))},n.relationships=f(n.relationships),n}function b(t,e,r){return r.attributes||(r.attributes={}),r.attributes[e]=t,r}function j(t){return Object.prototype.hasOwnProperty.call(t,"id")}function O(t,e,r,n){c(!1,t,e,r);let i={type:t=n.pluralTypes(n.camelCaseTypes(t))};null!=e&&e.id&&(i.id=String(e.id));for(const t in e){const r=e[t],a=n.pluralTypes(n.camelCaseTypes(t));null!==r&&(null==r?void 0:r.constructor)===Object&&j(r)?i=y(r,a,t,i):null!==r&&Array.isArray(r)&&r.length>0&&j(r[0])?i=h(r,a,t,i):"id"!==t&&"type"!==t&&(i=b(r,t,i))}return{data:i}}t.camel=t=>t.replace(/[-_][a-z\u00E0-\u00F6\u00F8-\u00FE]/g,t=>t.slice(1).toUpperCase()),t.deattribute=e,t.deserialise=function(t){var r,n;if(t)return Array.isArray(t.data)?t=function(t){for(let r of t.data)t.included&&(r=l(r,t.included)),r.relationships&&(r=l(r)),r.attributes&&(r=e(r)),t.data[t.data.indexOf(r)]=r;return t}(t):t.included?t.data=l(t.data,t.included):(null===(r=t.data)||void 0===r?void 0:r.constructor)===Object&&(t.data=l(t.data)),delete t.included,null!==(n=t.data)&&void 0!==n&&n.attributes&&(t.data=e(t.data)),t},t.error=r,t.filterIncludes=n,t.kebab=t=>t.charAt(0).toLowerCase()+t.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,t=>"-"+t.toLowerCase()),t.linkRelationships=l,t.query=u,t.serialise=function(t,e={},n="POST",i={}){try{return i.camelCaseTypes||(i.camelCaseTypes=t=>t),i.pluralTypes||(i.pluralTypes=t=>t),null===e||Array.isArray(e)&&0===e.length?{data:e}:Array.isArray(e)&&(null==e?void 0:e.length)>0?function(t,e,r,n){c(!0,t,e,r);const i=[];for(const a of e)i.push(O(t,a,r,n).data);return{data:i}}(t,e,n,i):O(t,e,n,i)}catch(t){throw r(t)}},t.snake=t=>t.charAt(0).toLowerCase()+t.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,t=>"_"+t.toLowerCase()),t.splitModel=function(t,e={}){e.pluralModel||(e.pluralModel=t=>t),e.resourceCase||(e.resourceCase=t=>t);const r=t.split("/"),n=r.pop();return r.push(e.pluralModel(e.resourceCase(n))),[n,r.join("/")]},Object.defineProperty(t,"__esModule",{value:!0})})); |
@@ -1,1 +0,1 @@ | ||
"use strict";function e(o,t=null){const n=[];for(const p in o)Object.prototype.hasOwnProperty.call(o,p)&&n.push((c=o[p],r=t?"".concat(t,"[").concat(p,"]"):p,null!==c&&"object"==typeof c?e(c,r):encodeURIComponent(r)+"="+encodeURIComponent(c)));var c,r;return n.join("&")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.query=e; | ||
"use strict";function e(o,t=null){const n=[];for(const p in o)Object.prototype.hasOwnProperty.call(o,p)&&n.push((r=o[p],c=t?`${t}[${p}]`:p,null!==r&&"object"==typeof r?e(r,c):encodeURIComponent(c)+"="+encodeURIComponent(r)));var r,c;return n.join("&")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.query=e; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./error.js");function r(t,r,e,n){const a=new Error("".concat(n," requires an ID for the ").concat(r," type"));if(void 0===r)throw new Error("".concat(n," requires a resource type"));if(t){if("POST"!==n&&e.length>0)for(const t of e)if(!t.id)throw a}else{if("object"!=typeof e||0===Object.keys(e).length)throw new Error("".concat(n," requires an object or array body"));if("POST"!==n&&!e.id)throw a}}function e(t,r,e){r[e]={data:{}};for(const n of Object.keys(t[e].data)){const a=t[e].data[n];let o=r[e].data;n&&!["id","type"].includes(n)?o=i(a,n,o):o[n]=a}return r}function n(t,r,e){r[e]={data:[]};for(const n of t[e].data)r[e].data.push(n);return r}function a(t){let r={};for(const a in t){r=Array.isArray(t[a].data)?n(t,r,a):e(t,r,a)}return r}function o(t,r,e,n){return n.relationships||(n.relationships={}),t.type||(t.type=r),n.relationships[e]={data:Object.assign(t)},n.relationships=a(n.relationships),n}function s(t,r,e,n){return n.relationships||(n.relationships={}),n.relationships[e]={data:t.map(({id:t,type:e,...n})=>({id:t,type:e||r,attributes:Object.keys(n).length?n:void 0}))},n.relationships=a(n.relationships),n}function i(t,r,e){return e.attributes||(e.attributes={}),e.attributes[r]=t,e}function c(t){return Object.prototype.hasOwnProperty.call(t,"id")}function l(t,e,n,a){r(!1,t,e,n);let l={type:t=a.pluralTypes(a.camelCaseTypes(t))};null!=e&&e.id&&(l.id=String(e.id));for(const t in e){const r=e[t],n=a.pluralTypes(a.camelCaseTypes(t));null!==r&&(null==r?void 0:r.constructor)===Object&&c(r)?l=o(r,n,t,l):null!==r&&Array.isArray(r)&&r.length>0&&c(r[0])?l=s(r,n,t,l):"id"!==t&&"type"!==t&&(l=i(r,t,l))}return{data:l}}exports.serialise=function(e,n={},a="POST",o={}){try{return o.camelCaseTypes||(o.camelCaseTypes=t=>t),o.pluralTypes||(o.pluralTypes=t=>t),null===n||Array.isArray(n)&&0===n.length?{data:n}:Array.isArray(n)&&(null==n?void 0:n.length)>0?function(t,e,n,a){r(!0,t,e,n);const o=[];for(const r of e)o.push(l(t,r,n,a).data);return{data:o}}(e,n,a,o):l(e,n,a,o)}catch(r){throw t.error(r)}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("./error.js");function r(t,r,e,n){const a=new Error(`${n} requires an ID for the ${r} type`);if(void 0===r)throw new Error(n+" requires a resource type");if(t){if("POST"!==n&&e.length>0)for(const t of e)if(!t.id)throw a}else{if("object"!=typeof e||0===Object.keys(e).length)throw new Error(n+" requires an object or array body");if("POST"!==n&&!e.id)throw a}}function e(t,r,e){r[e]={data:{}};for(const n of Object.keys(t[e].data)){const a=t[e].data[n];let s=r[e].data;n&&!["id","type"].includes(n)?s=o(a,n,s):s[n]=a}return r}function n(t,r,e){r[e]={data:[]};for(const n of t[e].data)r[e].data.push(n);return r}function a(t){let r={};for(const a in t){r=Array.isArray(t[a].data)?n(t,r,a):e(t,r,a)}return r}function s(t,r,e,n){return n.relationships||(n.relationships={}),t.type||(t.type=r),n.relationships[e]={data:Object.assign(t)},n.relationships=a(n.relationships),n}function i(t,r,e,n){return n.relationships||(n.relationships={}),n.relationships[e]={data:t.map(({id:t,type:e,...n})=>({id:t,type:e||r,attributes:Object.keys(n).length?n:void 0}))},n.relationships=a(n.relationships),n}function o(t,r,e){return e.attributes||(e.attributes={}),e.attributes[r]=t,e}function l(t){return Object.prototype.hasOwnProperty.call(t,"id")}function u(t,e,n,a){r(!1,t,e,n);let u={type:t=a.pluralTypes(a.camelCaseTypes(t))};null!=e&&e.id&&(u.id=String(e.id));for(const t in e){const r=e[t],n=a.pluralTypes(a.camelCaseTypes(t));null!==r&&(null==r?void 0:r.constructor)===Object&&l(r)?u=s(r,n,t,u):null!==r&&Array.isArray(r)&&r.length>0&&l(r[0])?u=i(r,n,t,u):"id"!==t&&"type"!==t&&(u=o(r,t,u))}return{data:u}}exports.serialise=function(e,n={},a="POST",s={}){try{return s.camelCaseTypes||(s.camelCaseTypes=t=>t),s.pluralTypes||(s.pluralTypes=t=>t),null===n||Array.isArray(n)&&0===n.length?{data:n}:Array.isArray(n)&&(null==n?void 0:n.length)>0?function(t,e,n,a){r(!0,t,e,n);const s=[];for(const r of e)s.push(u(t,r,n,a).data);return{data:s}}(e,n,a,s):u(e,n,a,s)}catch(r){throw t.error(r)}}; |
{ | ||
"version": "9.1.18", | ||
"version": "9.1.19", | ||
"name": "kitsu-core", | ||
@@ -60,3 +60,3 @@ "description": "Simple, lightweight & framework agnostic JSON:API (de)serialsation components", | ||
], | ||
"gitHead": "7d88dbff7802d7f54c8dfa541adb6251016e96f2", | ||
"gitHead": "a3a7d62c900ef67b9c23b704f47ce1c1b693568b", | ||
"devDependencies": { | ||
@@ -63,0 +63,0 @@ "@size-limit/preset-small-lib": "~4.5.0" |
167
README.md
@@ -27,11 +27,11 @@ <h1 align=center>Kitsu Core</h1> | ||
# | ||
# | ||
## Features | ||
- JSON-API 1.0 compliant | ||
- Automatically links relationships to data | ||
- Works in Node & browsers | ||
- Tree shakeable components | ||
- Zero dependencies | ||
* JSON-API 1.0 compliant | ||
* Automatically links relationships to data | ||
* Works in Node & browsers | ||
* Tree shakeable components | ||
* Zero dependencies | ||
@@ -82,39 +82,39 @@ ## Node / Browser Support | ||
- [deattribute](#deattribute) | ||
- [Parameters](#parameters) | ||
- [Examples](#examples) | ||
- [deserialise](#deserialise) | ||
- [Parameters](#parameters-1) | ||
- [Examples](#examples-1) | ||
- [error](#error) | ||
- [Parameters](#parameters-2) | ||
- [Examples](#examples-2) | ||
- [filterIncludes](#filterincludes) | ||
- [Parameters](#parameters-3) | ||
- [Examples](#examples-3) | ||
- [linkRelationships](#linkrelationships) | ||
- [Parameters](#parameters-4) | ||
- [Examples](#examples-4) | ||
- [query](#query) | ||
- [Parameters](#parameters-5) | ||
- [Examples](#examples-5) | ||
- [serialise](#serialise) | ||
- [Parameters](#parameters-6) | ||
- [Examples](#examples-6) | ||
- [splitModel](#splitmodel) | ||
- [Parameters](#parameters-7) | ||
- [Examples](#examples-7) | ||
- [camel](#camel) | ||
- [Parameters](#parameters-8) | ||
- [Examples](#examples-8) | ||
- [kebab](#kebab) | ||
- [Parameters](#parameters-9) | ||
- [Examples](#examples-9) | ||
- [snake](#snake) | ||
- [Parameters](#parameters-10) | ||
- [Examples](#examples-10) | ||
* [deattribute](#deattribute) | ||
* [Parameters](#parameters) | ||
* [Examples](#examples) | ||
* [deserialise](#deserialise) | ||
* [Parameters](#parameters-1) | ||
* [Examples](#examples-1) | ||
* [error](#error) | ||
* [Parameters](#parameters-2) | ||
* [Examples](#examples-2) | ||
* [filterIncludes](#filterincludes) | ||
* [Parameters](#parameters-3) | ||
* [Examples](#examples-3) | ||
* [linkRelationships](#linkrelationships) | ||
* [Parameters](#parameters-4) | ||
* [Examples](#examples-4) | ||
* [query](#query) | ||
* [Parameters](#parameters-5) | ||
* [Examples](#examples-5) | ||
* [serialise](#serialise) | ||
* [Parameters](#parameters-6) | ||
* [Examples](#examples-6) | ||
* [splitModel](#splitmodel) | ||
* [Parameters](#parameters-7) | ||
* [Examples](#examples-7) | ||
* [camel](#camel) | ||
* [Parameters](#parameters-8) | ||
* [Examples](#examples-8) | ||
* [kebab](#kebab) | ||
* [Parameters](#parameters-9) | ||
* [Examples](#examples-9) | ||
* [snake](#snake) | ||
* [Parameters](#parameters-10) | ||
* [Examples](#examples-10) | ||
### deattribute | ||
[packages/kitsu-core/src/deattribute/index.js:29-51](https://github.com/wopian/kitsu/blob/7cb4513bb9c711ba6e1d06bba9fabca0afe15390/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/a88d18e07a2fc067cd6381188d713000a16b1335/packages/kitsu-core/src/deattribute/index.js#L29-L51 "Source code on GitHub") | ||
@@ -125,3 +125,3 @@ Hoists attributes to be top-level | ||
- `data` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>)** Resource data | ||
* `data` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>)** Resource data | ||
@@ -132,3 +132,2 @@ #### Examples | ||
```javascript | ||
@@ -149,3 +148,2 @@ // JSON:API 'data' field | ||
```javascript | ||
@@ -162,7 +160,7 @@ // JSON:API 'data' field | ||
Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>)** Deattributed resource data | ||
Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>)** Deattributed resource data | ||
### deserialise | ||
[packages/kitsu-core/src/deserialise/index.js:57-72](https://github.com/wopian/kitsu/blob/7cb4513bb9c711ba6e1d06bba9fabca0afe15390/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/a88d18e07a2fc067cd6381188d713000a16b1335/packages/kitsu-core/src/deserialise/index.js#L57-L72 "Source code on GitHub") | ||
@@ -173,3 +171,3 @@ Deserialises a JSON-API response | ||
- `response` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The raw JSON:API response object | ||
* `response` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The raw JSON:API response object | ||
@@ -180,3 +178,2 @@ #### Examples | ||
```javascript | ||
@@ -194,3 +191,2 @@ deserialise({ | ||
```javascript | ||
@@ -222,3 +218,3 @@ deserialise({ | ||
[packages/kitsu-core/src/error/index.js:27-33](https://github.com/wopian/kitsu/blob/7cb4513bb9c711ba6e1d06bba9fabca0afe15390/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/a88d18e07a2fc067cd6381188d713000a16b1335/packages/kitsu-core/src/error/index.js#L27-L33 "Source code on GitHub") | ||
@@ -229,3 +225,3 @@ Uniform error handling for Axios, JSON:API and internal package errors. Mutated Error object is rethrown to the caller. | ||
- `Error` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The Error | ||
* `Error` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The Error | ||
@@ -257,7 +253,7 @@ #### Examples | ||
- Throws **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The mutated Error | ||
* Throws **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The mutated Error | ||
### filterIncludes | ||
[packages/kitsu-core/src/filterIncludes/index.js:33-46](https://github.com/wopian/kitsu/blob/7cb4513bb9c711ba6e1d06bba9fabca0afe15390/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/a88d18e07a2fc067cd6381188d713000a16b1335/packages/kitsu-core/src/filterIncludes/index.js#L33-L46 "Source code on GitHub") | ||
@@ -268,7 +264,8 @@ Filters includes for the specific relationship requested | ||
- `included` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** The response included object | ||
- `relationship` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
- `relationship.id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship ID | ||
- `relationship.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship type | ||
* `included` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** The response included object | ||
* `relationship` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
* `relationship.id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship ID | ||
* `relationship.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship type | ||
#### Examples | ||
@@ -298,7 +295,7 @@ | ||
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** The matched includes | ||
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** The matched includes | ||
### linkRelationships | ||
[packages/kitsu-core/src/linkRelationships/index.js:97-117](https://github.com/wopian/kitsu/blob/7cb4513bb9c711ba6e1d06bba9fabca0afe15390/packages/kitsu-core/src/linkRelationships/index.js#L97-L117 "Source code on GitHub") | ||
[packages/kitsu-core/src/linkRelationships/index.js:97-117](https://github.com/wopian/kitsu/blob/a88d18e07a2fc067cd6381188d713000a16b1335/packages/kitsu-core/src/linkRelationships/index.js#L97-L117 "Source code on GitHub") | ||
@@ -309,4 +306,4 @@ Links relationships to included data | ||
- `data` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The response data object | ||
- `included` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>?** The response included object (optional, default `[]`) | ||
* `data` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The response data object | ||
* `included` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>?** The response included object (optional, default `[]`) | ||
@@ -342,3 +339,3 @@ #### Examples | ||
[packages/kitsu-core/src/query/index.js:33-44](https://github.com/wopian/kitsu/blob/7cb4513bb9c711ba6e1d06bba9fabca0afe15390/packages/kitsu-core/src/query/index.js#L33-L44 "Source code on GitHub") | ||
[packages/kitsu-core/src/query/index.js:33-44](https://github.com/wopian/kitsu/blob/a88d18e07a2fc067cd6381188d713000a16b1335/packages/kitsu-core/src/query/index.js#L33-L44 "Source code on GitHub") | ||
@@ -349,4 +346,4 @@ Constructs a URL query string for JSON:API parameters | ||
- `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Parameters to parse | ||
- `prefix` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Prefix for nested parameters - used internally (optional, default `null`) | ||
* `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Parameters to parse | ||
* `prefix` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Prefix for nested parameters - used internally (optional, default `null`) | ||
@@ -372,3 +369,3 @@ #### Examples | ||
[packages/kitsu-core/src/serialise/index.js:249-260](https://github.com/wopian/kitsu/blob/7cb4513bb9c711ba6e1d06bba9fabca0afe15390/packages/kitsu-core/src/serialise/index.js#L249-L260 "Source code on GitHub") | ||
[packages/kitsu-core/src/serialise/index.js:249-260](https://github.com/wopian/kitsu/blob/a88d18e07a2fc067cd6381188d713000a16b1335/packages/kitsu-core/src/serialise/index.js#L249-L260 "Source code on GitHub") | ||
@@ -379,9 +376,10 @@ Serialises an object into a JSON-API structure | ||
- `type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Resource type | ||
- `data` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>)?** The data (optional, default `{}`) | ||
- `method` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Request type (PATCH, POST, DELETE) (optional, default `'POST'`) | ||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Optional configuration for camelCase and pluralisation handling (optional, default `{}`) | ||
- `options.camelCaseTypes` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Convert library-entries and library_entries to libraryEntries (default no conversion). To use parameter, import camel from kitsu-core (optional, default `s=>s`) | ||
- `options.pluralTypes` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Pluralise types (default no pluralisation). To use parameter, import pluralize (or another pluralisation npm package) (optional, default `s=>s`) | ||
* `type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Resource type | ||
* `data` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>)?** The data (optional, default `{}`) | ||
* `method` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Request type (PATCH, POST, DELETE) (optional, default `'POST'`) | ||
* `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Optional configuration for camelCase and pluralisation handling (optional, default `{}`) | ||
* `options.camelCaseTypes` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Convert library-entries and library_entries to libraryEntries (default no conversion). To use parameter, import camel from kitsu-core (optional, default `s=>s`) | ||
* `options.pluralTypes` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Pluralise types (default no pluralisation). To use parameter, import pluralize (or another pluralisation npm package) (optional, default `s=>s`) | ||
#### Examples | ||
@@ -391,3 +389,2 @@ | ||
```javascript | ||
@@ -406,3 +403,2 @@ import { serialise, camel } from 'kitsu-core' | ||
```javascript | ||
@@ -422,3 +418,3 @@ import { serialise } from 'kitsu-core' | ||
[packages/kitsu-core/src/splitModel/index.js:29-39](https://github.com/wopian/kitsu/blob/7cb4513bb9c711ba6e1d06bba9fabca0afe15390/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/a88d18e07a2fc067cd6381188d713000a16b1335/packages/kitsu-core/src/splitModel/index.js#L29-L39 "Source code on GitHub") | ||
@@ -429,7 +425,8 @@ Split model name from the model's resource URL | ||
- `url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** URL path for the model | ||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Optional configuration for camelCase and pluralisation handling | ||
- `options.resourceCase` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Convert libraryEntries to library-entries or library_entries (default no conversion). To use parameter, import kebab or snake from kitsu-core (optional, default `s=>s`) | ||
- `options.pluralModel` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Pluralise models (default no pluralisation). To use parameter, import pluralize (or another pluralisation npm package) (optional, default `s=>s`) | ||
* `url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** URL path for the model | ||
* `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Optional configuration for camelCase and pluralisation handling | ||
* `options.resourceCase` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Convert libraryEntries to library-entries or library_entries (default no conversion). To use parameter, import kebab or snake from kitsu-core (optional, default `s=>s`) | ||
* `options.pluralModel` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Pluralise models (default no pluralisation). To use parameter, import pluralize (or another pluralisation npm package) (optional, default `s=>s`) | ||
#### Examples | ||
@@ -444,3 +441,2 @@ | ||
```javascript | ||
@@ -454,3 +450,2 @@ import plural from 'pluralize' | ||
```javascript | ||
@@ -469,3 +464,3 @@ import { kebab, snake } from 'kitsu-core' | ||
[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/7cb4513bb9c711ba6e1d06bba9fabca0afe15390/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/a88d18e07a2fc067cd6381188d713000a16b1335/packages/kitsu-core/src/camel/index.js#L14-L14 "Source code on GitHub") | ||
@@ -476,3 +471,3 @@ Converts kebab-case and snake_case into camelCase | ||
- `input` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** String to convert | ||
* `input` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** String to convert | ||
@@ -483,3 +478,2 @@ #### Examples | ||
```javascript | ||
@@ -491,3 +485,2 @@ camel('hello-world') // 'helloWorld' | ||
```javascript | ||
@@ -501,3 +494,3 @@ camel('hello_world') // 'helloWorld' | ||
[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/7cb4513bb9c711ba6e1d06bba9fabca0afe15390/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/a88d18e07a2fc067cd6381188d713000a16b1335/packages/kitsu-core/src/kebab/index.js#L11-L11 "Source code on GitHub") | ||
@@ -508,3 +501,3 @@ Converts camelCase into kebab-case | ||
- `input` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** camelCase string | ||
* `input` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** camelCase string | ||
@@ -521,3 +514,3 @@ #### Examples | ||
[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/7cb4513bb9c711ba6e1d06bba9fabca0afe15390/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/a88d18e07a2fc067cd6381188d713000a16b1335/packages/kitsu-core/src/snake/index.js#L11-L11 "Source code on GitHub") | ||
@@ -528,3 +521,3 @@ Converts camelCase into snake_case | ||
- `input` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** camelCase string | ||
* `input` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** camelCase string | ||
@@ -531,0 +524,0 @@ #### Examples |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
66273
334
516