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

kitsu-core

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kitsu-core - npm Package Compare versions

Comparing version 5.1.0 to 5.1.1

lib/index.m.js

25

CHANGELOG.md

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

#### 5.1.1 (2018-06-01)
##### Chores
* **vscode:** hide output directories (afdd4831)
* **deps:**
* update dependency documentation to ~7.1.0 (#171) (8526d828)
* update dependency jest to v23 (#170) (ec74d6bb)
* update dependency documentation to v7 (#169) (05ee3320)
* update dependency rollup-plugin-babel-minify to v5 (#168) (2ac8fca5)
* update dependency rollup to ~0.59.0 (#167) (6b989f93)
* update dependency size-limit to ~0.18.0 (#166) (5395b12d)
* update dependency babel-preset-env to ~1.7.0 (#165) (34e2042f)
* lock file maintenance (#163) (8c0b650f)
* lock file maintenance (4fac11f0)
* update lerna to ~2.10.0 (#157) (955c694a)
* update documentation to ~6.2.0 (#158) (cbc87cc2)
* update axios-mock-adapter to ~1.15.0 (#156) (b9cde7db)
* **renovate:** use shareable config (86b0d93a)
##### Documentation Changes
* **kitsu-core:** update browser support table (577b38f1)
* **kitsu:** update browser support table (c564c907)
### 5.1.0 (2018-04-01)

@@ -2,0 +27,0 @@

2

lib/index.js

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

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});function _interopDefault(a){return a&&'object'==typeof a&&'default'in a?a['default']:a}var _regeneratorRuntime=_interopDefault(require('babel-runtime/regenerator')),_asyncToGenerator=_interopDefault(require('babel-runtime/helpers/asyncToGenerator')),deattribute=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b){var c,d=this;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if('object'!=typeof b||null===b){a.next=7;break}if(!Array.isArray(b)){a.next=6;break}return a.next=4,b.map((()=>(c=_asyncToGenerator(_regeneratorRuntime.mark(function a(b){return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt('return',deattribute(b));case 1:case'end':return a.stop();}},a,d)})),function(){return c.apply(this,arguments)}))());case 4:a.next=7;break;case 6:b.attributes&&b.attributes.constructor===Object&&(Object.keys(b.attributes).forEach(function(a){b[a]=b.attributes[a]}),delete b.attributes);case 7:return a.abrupt('return',b);case 8:case'end':return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}})();function error(a){if(a.response){var b=a.response.data;b&&b.errors&&(a.errors=b.errors)}throw a}var filterIncludes=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b,c){var d,e=c.id,f=c.type;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,d=b.filter(function(a){return a.id===e&&a.type===f})[0]||{id:e,type:f},a.abrupt('return',Object.assign({},d));case 5:a.prev=5,a.t0=a['catch'](0),error(a.t0);case 8:case'end':return a.stop();}},a,this,[[0,5]])}));return function(){return a.apply(this,arguments)}})(),link=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b,c){var d,e=b.id,f=b.type,g=b.meta;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,filterIncludes(c,{id:e,type:f});case 2:if(d=a.sent,!d.relationships){a.next=6;break}return a.next=6,linkRelationships(d,c);case 6:return g&&(d.meta=g),a.abrupt('return',deattribute(d));case 8:case'end':return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}})(),linkArray=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b,c,d){var e,f,g,h,i,j;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return b[d]=[],e=!0,f=!1,g=void 0,a.prev=4,a.next=7,b.relationships[d].data;case 7:a.t0=Symbol.iterator,h=a.sent[a.t0]();case 9:if(e=(i=h.next()).done){a.next=19;break}return j=i.value,a.t1=b[d],a.next=14,link(j,c);case 14:a.t2=a.sent,a.t1.push.call(a.t1,a.t2);case 16:e=!0,a.next=9;break;case 19:a.next=25;break;case 21:a.prev=21,a.t3=a['catch'](4),f=!0,g=a.t3;case 25:a.prev=25,a.prev=26,!e&&h.return&&h.return();case 28:if(a.prev=28,!f){a.next=31;break}throw g;case 31:return a.finish(28);case 32:return a.finish(25);case 33:case'end':return a.stop();}},a,this,[[4,21,25,33],[26,,28,32]])}));return function(){return a.apply(this,arguments)}})(),linkObject=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b,c,d){return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,link(b.relationships[d].data,c);case 2:b[d]=a.sent,delete b[d].relationships;case 4:case'end':return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}})(),linkRelationships=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b,c){var d,e,f;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return d=b.relationships,e=!1,a.next=4,d;case 4:a.t0=_regeneratorRuntime.keys(a.sent);case 5:if((a.t1=a.t0()).done){a.next=19;break}if(f=a.t1.value,!(d[f].data&&Array.isArray(d[f].data))){a.next=13;break}return a.next=10,linkArray(b,c,f);case 10:e=!0,a.next=17;break;case 13:if(!d[f].data){a.next=17;break}return a.next=16,linkObject(b,c,f);case 16:e=!0;case 17:a.next=5;break;case 19:return e&&delete b.relationships,a.abrupt('return',b);case 21:case'end':return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}})(),deserialiseArray=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b){var c,d,e,f,g,h;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return c=!0,d=!1,e=void 0,a.prev=3,a.next=6,b.data;case 6:a.t0=Symbol.iterator,f=a.sent[a.t0]();case 8:if(c=(g=f.next()).done){a.next=22;break}if(h=g.value,!b.included){a.next=14;break}return a.next=13,linkRelationships(h,b.included);case 13:h=a.sent;case 14:if(!h.attributes){a.next=18;break}return a.next=17,deattribute(h);case 17:h=a.sent;case 18:b.data[b.data.indexOf(h)]=h;case 19:c=!0,a.next=8;break;case 22:a.next=28;break;case 24:a.prev=24,a.t1=a['catch'](3),d=!0,e=a.t1;case 28:a.prev=28,a.prev=29,!c&&f.return&&f.return();case 31:if(a.prev=31,!d){a.next=34;break}throw e;case 34:return a.finish(31);case 35:return a.finish(28);case 36:return a.abrupt('return',b);case 37:case'end':return a.stop();}},a,this,[[3,24,28,36],[29,,31,35]])}));return function(){return a.apply(this,arguments)}})(),deserialise=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b){return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(b.data&&b.data.constructor===Array)){a.next=6;break}return a.next=3,deserialiseArray(b);case 3:b=a.sent,a.next=10;break;case 6:if(!b.included){a.next=10;break}return a.next=9,linkRelationships(b.data,b.included);case 9:b.data=a.sent;case 10:if(delete b.included,!(b.data&&b.data.attributes)){a.next=15;break}return a.next=14,deattribute(b.data);case 14:b.data=a.sent;case 15:return a.abrupt('return',b);case 16:case'end':return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}})();function deObject(a,b){var c='';for(var d in a){var e=a[d];b&&(c+=`&${b}`),c+='object'==typeof e?`[${d}]${deObject(e)}`:`[${d}]=${e}`}return c}function query(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],c='';for(var d in a){var e=a[d];c+='object'==typeof e?deObject(e,d):`&${d}=${e}`}return c=encodeURI(c.slice(1)),a?b?`?${c}`:c:''}var requiresID=(a,b)=>`${a} requires an ID for the ${b} relationships`,serialise=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b){var c,d,e,f,g=this,h=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:'POST';return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(a.prev=0,h.constructor===Object&&0!==Object.keys(h).length){a.next=3;break}throw new Error(`${i} requires a JSON object body`);case 3:if(c=this.plural(this.camel(b)),d={type:c},'POST'===i||h.id){a.next=7;break}throw new Error(`${i} requires an ID for the ${c} type`);case 7:for(f in'POST'!==i&&(d.id=h.id.toString()),e=function(a){if(null!==h[a]&&h[a].constructor===Object){if('string'==typeof h[a].id)d.relationships||(d.relationships={}),h[a].type||(h[a].type=g.plural(g.camel(a))),d.relationships[a]={data:Object.assign(h[a])};else throw new Error(requiresID(i,a));}else if(null!==h[a]&&Array.isArray(h[a])){var b=g.plural(g.camel(a));d.relationships||(d.relationships={}),d.relationships[a]={data:h[a].map(function(c){if(!c.id)throw new Error(requiresID(i,a));return{id:c.id,type:c.type||b}})}}else'id'!==a&&'type'!==a&&(d.attributes||(d.attributes={}),d.attributes[a]=h[a])},h)e(f);return a.abrupt('return',{data:d});case 13:throw a.prev=13,a.t0=a['catch'](0),error(a.t0);case 16:case'end':return a.stop();}},a,this,[[0,13]])}));return function(){return a.apply(this,arguments)}})(),index=(a)=>a.replace(/[-_][a-z\u00E0-\u00F6\u00F8-\u00FE]/g,(a)=>a.slice(1).toUpperCase()),index$1=(a)=>a.charAt(0).toLowerCase()+a.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,(a)=>'-'+a.toLowerCase()),index$2=(a)=>a.charAt(0).toLowerCase()+a.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,(a)=>'_'+a.toLowerCase());exports.camel=index,exports.kebab=index$1,exports.snake=index$2,exports.deattribute=deattribute,exports.deserialise=deserialise,exports.error=error,exports.filterIncludes=filterIncludes,exports.linkRelationships=linkRelationships,exports.query=query,exports.serialise=serialise;
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});function _interopDefault(a){return a&&'object'==typeof a&&'default'in a?a['default']:a}var _regeneratorRuntime=_interopDefault(require('babel-runtime/regenerator')),_asyncToGenerator=_interopDefault(require('babel-runtime/helpers/asyncToGenerator')),deattribute=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b){var c,d=this;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if('object'!=typeof b||null===b){a.next=7;break}if(!Array.isArray(b)){a.next=6;break}return a.next=4,b.map((()=>(c=_asyncToGenerator(_regeneratorRuntime.mark(function a(b){return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.abrupt('return',deattribute(b));case 1:case'end':return a.stop();}},a,d)})),function(){return c.apply(this,arguments)}))());case 4:a.next=7;break;case 6:b.attributes&&b.attributes.constructor===Object&&(Object.keys(b.attributes).forEach(function(a){b[a]=b.attributes[a]}),delete b.attributes);case 7:return a.abrupt('return',b);case 8:case'end':return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}})();function error(a){if(a.response){var b=a.response.data;b&&b.errors&&(a.errors=b.errors)}throw a}var filterIncludes=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b,c){var d,e=c.id,f=c.type;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.prev=0,d=b.filter(function(a){return a.id===e&&a.type===f})[0]||{id:e,type:f},a.abrupt('return',Object.assign({},d));case 5:a.prev=5,a.t0=a['catch'](0),error(a.t0);case 8:case'end':return a.stop();}},a,this,[[0,5]])}));return function(){return a.apply(this,arguments)}})(),link=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b,c){var d,e=b.id,f=b.type,g=b.meta;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,filterIncludes(c,{id:e,type:f});case 2:if(d=a.sent,!d.relationships){a.next=6;break}return a.next=6,linkRelationships(d,c);case 6:return g&&(d.meta=g),a.abrupt('return',deattribute(d));case 8:case'end':return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}})(),linkArray=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b,c,d){var e,f,g,h,i,j;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return b[d]=[],e=!0,f=!1,g=void 0,a.prev=4,a.next=7,b.relationships[d].data;case 7:a.t0=Symbol.iterator,h=a.sent[a.t0]();case 9:if(e=(i=h.next()).done){a.next=19;break}return j=i.value,a.t1=b[d],a.next=14,link(j,c);case 14:a.t2=a.sent,a.t1.push.call(a.t1,a.t2);case 16:e=!0,a.next=9;break;case 19:a.next=25;break;case 21:a.prev=21,a.t3=a['catch'](4),f=!0,g=a.t3;case 25:a.prev=25,a.prev=26,!e&&h.return&&h.return();case 28:if(a.prev=28,!f){a.next=31;break}throw g;case 31:return a.finish(28);case 32:return a.finish(25);case 33:case'end':return a.stop();}},a,this,[[4,21,25,33],[26,,28,32]])}));return function(){return a.apply(this,arguments)}})(),linkObject=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b,c,d){return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return a.next=2,link(b.relationships[d].data,c);case 2:b[d]=a.sent,delete b[d].relationships;case 4:case'end':return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}})(),linkRelationships=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b,c){var d,e,f;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return d=b.relationships,e=!1,a.next=4,d;case 4:a.t0=_regeneratorRuntime.keys(a.sent);case 5:if((a.t1=a.t0()).done){a.next=19;break}if(f=a.t1.value,!(d[f].data&&Array.isArray(d[f].data))){a.next=13;break}return a.next=10,linkArray(b,c,f);case 10:e=!0,a.next=17;break;case 13:if(!d[f].data){a.next=17;break}return a.next=16,linkObject(b,c,f);case 16:e=!0;case 17:a.next=5;break;case 19:return e&&delete b.relationships,a.abrupt('return',b);case 21:case'end':return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}})(),deserialiseArray=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b){var c,d,e,f,g,h;return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:return c=!0,d=!1,e=void 0,a.prev=3,a.next=6,b.data;case 6:a.t0=Symbol.iterator,f=a.sent[a.t0]();case 8:if(c=(g=f.next()).done){a.next=22;break}if(h=g.value,!b.included){a.next=14;break}return a.next=13,linkRelationships(h,b.included);case 13:h=a.sent;case 14:if(!h.attributes){a.next=18;break}return a.next=17,deattribute(h);case 17:h=a.sent;case 18:b.data[b.data.indexOf(h)]=h;case 19:c=!0,a.next=8;break;case 22:a.next=28;break;case 24:a.prev=24,a.t1=a['catch'](3),d=!0,e=a.t1;case 28:a.prev=28,a.prev=29,!c&&f.return&&f.return();case 31:if(a.prev=31,!d){a.next=34;break}throw e;case 34:return a.finish(31);case 35:return a.finish(28);case 36:return a.abrupt('return',b);case 37:case'end':return a.stop();}},a,this,[[3,24,28,36],[29,,31,35]])}));return function(){return a.apply(this,arguments)}})(),deserialise=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b){return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(!(b.data&&b.data.constructor===Array)){a.next=6;break}return a.next=3,deserialiseArray(b);case 3:b=a.sent,a.next=10;break;case 6:if(!b.included){a.next=10;break}return a.next=9,linkRelationships(b.data,b.included);case 9:b.data=a.sent;case 10:if(delete b.included,!(b.data&&b.data.attributes)){a.next=15;break}return a.next=14,deattribute(b.data);case 14:b.data=a.sent;case 15:return a.abrupt('return',b);case 16:case'end':return a.stop();}},a,this)}));return function(){return a.apply(this,arguments)}})();function deObject(a,b){var c='';for(var d in a){var e=a[d];b&&(c+=`&${b}`),c+='object'==typeof e?`[${d}]${deObject(e)}`:`[${d}]=${e}`}return c}function query(a){var b=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],c='';for(var d in a){var e=a[d];c+='object'==typeof e?deObject(e,d):`&${d}=${e}`}return c=encodeURI(c.slice(1)),a?b?`?${c}`:c:''}var requiresID=(a,b)=>`${a} requires an ID for the ${b} relationships`,serialise=(()=>{var a=_asyncToGenerator(_regeneratorRuntime.mark(function a(b){var c,d,e,f,g=this,h=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{},i=2<arguments.length&&arguments[2]!==void 0?arguments[2]:'POST';return _regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(a.prev=0,h.constructor===Object&&0!==Object.keys(h).length){a.next=3;break}throw new Error(`${i} requires a JSON object body`);case 3:if(c=this.plural(this.camel(b)),d={type:c},'POST'===i||h.id){a.next=7;break}throw new Error(`${i} requires an ID for the ${c} type`);case 7:for(f in'POST'!==i&&(d.id=h.id.toString()),e=function(a){if(null!==h[a]&&h[a].constructor===Object){if('string'==typeof h[a].id)d.relationships||(d.relationships={}),h[a].type||(h[a].type=g.plural(g.camel(a))),d.relationships[a]={data:Object.assign(h[a])};else throw new Error(requiresID(i,a));}else if(null!==h[a]&&Array.isArray(h[a])){var b=g.plural(g.camel(a));d.relationships||(d.relationships={}),d.relationships[a]={data:h[a].map(function(c){if(!c.id)throw new Error(requiresID(i,a));return{id:c.id,type:c.type||b}})}}else'id'!==a&&'type'!==a&&(d.attributes||(d.attributes={}),d.attributes[a]=h[a])},h)e(f);return a.abrupt('return',{data:d});case 13:throw a.prev=13,a.t0=a['catch'](0),error(a.t0);case 16:case'end':return a.stop();}},a,this,[[0,13]])}));return function(){return a.apply(this,arguments)}})(),index=a=>a.replace(/[-_][a-z\u00E0-\u00F6\u00F8-\u00FE]/g,a=>a.slice(1).toUpperCase()),index$1=a=>a.charAt(0).toLowerCase()+a.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,a=>'-'+a.toLowerCase()),index$2=a=>a.charAt(0).toLowerCase()+a.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,a=>'_'+a.toLowerCase());exports.camel=index,exports.kebab=index$1,exports.snake=index$2,exports.deattribute=deattribute,exports.deserialise=deserialise,exports.error=error,exports.filterIncludes=filterIncludes,exports.linkRelationships=linkRelationships,exports.query=query,exports.serialise=serialise;
//# sourceMappingURL=index.js.map

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

'use strict';Object.defineProperty(exports,'__esModule',{value:!0});function _interopDefault(a){return a&&'object'==typeof a&&'default'in a?a['default']:a}var _asyncToGenerator=_interopDefault(require('babel-runtime/helpers/asyncToGenerator'));let deattribute=(()=>{var a=_asyncToGenerator(function*(a){return'object'==typeof a&&null!==a&&(Array.isArray(a)?yield a.map((()=>{var a=_asyncToGenerator(function*(a){return deattribute(a)});return function(){return a.apply(this,arguments)}})()):a.attributes&&a.attributes.constructor===Object&&(Object.keys(a.attributes).forEach(function(b){a[b]=a.attributes[b]}),delete a.attributes)),a});return function(){return a.apply(this,arguments)}})();function error(a){if(a.response){const b=a.response.data;b&&b.errors&&(a.errors=b.errors)}throw a}let filterIncludes=(()=>{var a=_asyncToGenerator(function*(a,{id:b,type:c}){try{const d=a.filter(function(a){return a.id===b&&a.type===c})[0]||{id:b,type:c};return Object.assign({},d)}catch(a){error(a)}});return function(){return a.apply(this,arguments)}})(),link=(()=>{var a=_asyncToGenerator(function*({id:a,type:b,meta:c},d){const e=yield filterIncludes(d,{id:a,type:b});return e.relationships&&(yield linkRelationships(e,d)),c&&(e.meta=c),deattribute(e)});return function(){return a.apply(this,arguments)}})(),linkArray=(()=>{var a=_asyncToGenerator(function*(a,b,c){a[c]=[];var d,e=!0,f=!1;try{for(var g,h=(yield a.relationships[c].data)[Symbol.iterator]();!(e=(g=h.next()).done);e=!0){let d=g.value;a[c].push((yield link(d,b)))}}catch(a){f=!0,d=a}finally{try{!e&&h.return&&h.return()}finally{if(f)throw d}}});return function(){return a.apply(this,arguments)}})(),linkObject=(()=>{var a=_asyncToGenerator(function*(a,b,c){a[c]=yield link(a.relationships[c].data,b),delete a[c].relationships});return function(){return a.apply(this,arguments)}})(),linkRelationships=(()=>{var a=_asyncToGenerator(function*(a,b){const c=a.relationships;let d=!1;for(let e in yield c)c[e].data&&Array.isArray(c[e].data)?(yield linkArray(a,b,e),d=!0):c[e].data&&(yield linkObject(a,b,e),d=!0);return d&&delete a.relationships,a});return function(){return a.apply(this,arguments)}})(),deserialiseArray=(()=>{var a=_asyncToGenerator(function*(a){var b,c=!0,d=!1;try{for(var e,f=(yield a.data)[Symbol.iterator]();!(c=(e=f.next()).done);c=!0){let b=e.value;a.included&&(b=yield linkRelationships(b,a.included)),b.attributes&&(b=yield deattribute(b)),a.data[a.data.indexOf(b)]=b}}catch(a){d=!0,b=a}finally{try{!c&&f.return&&f.return()}finally{if(d)throw b}}return a});return function(){return a.apply(this,arguments)}})(),deserialise=(()=>{var a=_asyncToGenerator(function*(a){return a.data&&a.data.constructor===Array?a=yield deserialiseArray(a):a.included&&(a.data=yield linkRelationships(a.data,a.included)),delete a.included,a.data&&a.data.attributes&&(a.data=yield deattribute(a.data)),a});return function(){return a.apply(this,arguments)}})();function deObject(a,b){let c='';for(let d in a){let e=a[d];b&&(c+=`&${b}`),c+='object'==typeof e?`[${d}]${deObject(e)}`:`[${d}]=${e}`}return c}function query(a,b=!1){let c='';for(let d in a){let b=a[d];c+='object'==typeof b?deObject(b,d):`&${d}=${b}`}return c=encodeURI(c.slice(1)),a?b?`?${c}`:c:''}const requiresID=(a,b)=>`${a} requires an ID for the ${b} relationships`;let serialise=(()=>{var a=_asyncToGenerator(function*(a,b={},c='POST'){try{if(b.constructor!==Object||0===Object.keys(b).length)throw new Error(`${c} requires a JSON object body`);const d=this.plural(this.camel(a)),e={type:d};if('POST'!==c&&!b.id)throw new Error(`${c} requires an ID for the ${d} type`);for(let a in'POST'!==c&&(e.id=b.id.toString()),b)if(null!==b[a]&&b[a].constructor===Object){if('string'==typeof b[a].id)e.relationships||(e.relationships={}),b[a].type||(b[a].type=this.plural(this.camel(a))),e.relationships[a]={data:Object.assign(b[a])};else throw new Error(requiresID(c,a));}else if(null!==b[a]&&Array.isArray(b[a])){const d=this.plural(this.camel(a));e.relationships||(e.relationships={}),e.relationships[a]={data:b[a].map(function(b){if(!b.id)throw new Error(requiresID(c,a));return{id:b.id,type:b.type||d}})}}else'id'!==a&&'type'!==a&&(e.attributes||(e.attributes={}),e.attributes[a]=b[a]);return{data:e}}catch(a){throw error(a)}});return function(){return a.apply(this,arguments)}})();var index=(a)=>a.replace(/[-_][a-z\u00E0-\u00F6\u00F8-\u00FE]/g,(a)=>a.slice(1).toUpperCase()),index$1=(a)=>a.charAt(0).toLowerCase()+a.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,(a)=>'-'+a.toLowerCase()),index$2=(a)=>a.charAt(0).toLowerCase()+a.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,(a)=>'_'+a.toLowerCase());exports.camel=index,exports.kebab=index$1,exports.snake=index$2,exports.deattribute=deattribute,exports.deserialise=deserialise,exports.error=error,exports.filterIncludes=filterIncludes,exports.linkRelationships=linkRelationships,exports.query=query,exports.serialise=serialise;
'use strict';Object.defineProperty(exports,'__esModule',{value:!0});function _interopDefault(a){return a&&'object'==typeof a&&'default'in a?a['default']:a}var _asyncToGenerator=_interopDefault(require('babel-runtime/helpers/asyncToGenerator'));let deattribute=(()=>{var a=_asyncToGenerator(function*(a){return'object'==typeof a&&null!==a&&(Array.isArray(a)?yield a.map((()=>{var a=_asyncToGenerator(function*(a){return deattribute(a)});return function(){return a.apply(this,arguments)}})()):a.attributes&&a.attributes.constructor===Object&&(Object.keys(a.attributes).forEach(function(b){a[b]=a.attributes[b]}),delete a.attributes)),a});return function(){return a.apply(this,arguments)}})();function error(a){if(a.response){const b=a.response.data;b&&b.errors&&(a.errors=b.errors)}throw a}let filterIncludes=(()=>{var a=_asyncToGenerator(function*(a,{id:b,type:c}){try{const d=a.filter(function(a){return a.id===b&&a.type===c})[0]||{id:b,type:c};return Object.assign({},d)}catch(a){error(a)}});return function(){return a.apply(this,arguments)}})(),link=(()=>{var a=_asyncToGenerator(function*({id:a,type:b,meta:c},d){const e=yield filterIncludes(d,{id:a,type:b});return e.relationships&&(yield linkRelationships(e,d)),c&&(e.meta=c),deattribute(e)});return function(){return a.apply(this,arguments)}})(),linkArray=(()=>{var a=_asyncToGenerator(function*(a,b,c){a[c]=[];var d=!0,e=!1,f=void 0;try{for(var g,h=(yield a.relationships[c].data)[Symbol.iterator]();!(d=(g=h.next()).done);d=!0){let d=g.value;a[c].push((yield link(d,b)))}}catch(a){e=!0,f=a}finally{try{!d&&h.return&&h.return()}finally{if(e)throw f}}});return function(){return a.apply(this,arguments)}})(),linkObject=(()=>{var a=_asyncToGenerator(function*(a,b,c){a[c]=yield link(a.relationships[c].data,b),delete a[c].relationships});return function(){return a.apply(this,arguments)}})(),linkRelationships=(()=>{var a=_asyncToGenerator(function*(a,b){const c=a.relationships;let d=!1;for(let e in yield c)c[e].data&&Array.isArray(c[e].data)?(yield linkArray(a,b,e),d=!0):c[e].data&&(yield linkObject(a,b,e),d=!0);return d&&delete a.relationships,a});return function(){return a.apply(this,arguments)}})(),deserialiseArray=(()=>{var a=_asyncToGenerator(function*(a){var b=!0,c=!1,d=void 0;try{for(var e,f=(yield a.data)[Symbol.iterator]();!(b=(e=f.next()).done);b=!0){let b=e.value;a.included&&(b=yield linkRelationships(b,a.included)),b.attributes&&(b=yield deattribute(b)),a.data[a.data.indexOf(b)]=b}}catch(a){c=!0,d=a}finally{try{!b&&f.return&&f.return()}finally{if(c)throw d}}return a});return function(){return a.apply(this,arguments)}})(),deserialise=(()=>{var a=_asyncToGenerator(function*(a){return a.data&&a.data.constructor===Array?a=yield deserialiseArray(a):a.included&&(a.data=yield linkRelationships(a.data,a.included)),delete a.included,a.data&&a.data.attributes&&(a.data=yield deattribute(a.data)),a});return function(){return a.apply(this,arguments)}})();function deObject(a,b){let c='';for(let d in a){let e=a[d];b&&(c+=`&${b}`),c+='object'==typeof e?`[${d}]${deObject(e)}`:`[${d}]=${e}`}return c}function query(a,b=!1){let c='';for(let d in a){let b=a[d];c+='object'==typeof b?deObject(b,d):`&${d}=${b}`}return c=encodeURI(c.slice(1)),a?b?`?${c}`:c:''}const requiresID=(a,b)=>`${a} requires an ID for the ${b} relationships`;let serialise=(()=>{var a=_asyncToGenerator(function*(a,b={},c='POST'){try{if(b.constructor!==Object||0===Object.keys(b).length)throw new Error(`${c} requires a JSON object body`);const d=this.plural(this.camel(a)),e={type:d};if('POST'!==c&&!b.id)throw new Error(`${c} requires an ID for the ${d} type`);for(let a in'POST'!==c&&(e.id=b.id.toString()),b)if(null!==b[a]&&b[a].constructor===Object){if('string'==typeof b[a].id)e.relationships||(e.relationships={}),b[a].type||(b[a].type=this.plural(this.camel(a))),e.relationships[a]={data:Object.assign(b[a])};else throw new Error(requiresID(c,a));}else if(null!==b[a]&&Array.isArray(b[a])){const d=this.plural(this.camel(a));e.relationships||(e.relationships={}),e.relationships[a]={data:b[a].map(function(b){if(!b.id)throw new Error(requiresID(c,a));return{id:b.id,type:b.type||d}})}}else'id'!==a&&'type'!==a&&(e.attributes||(e.attributes={}),e.attributes[a]=b[a]);return{data:e}}catch(a){throw error(a)}});return function(){return a.apply(this,arguments)}})();var index=a=>a.replace(/[-_][a-z\u00E0-\u00F6\u00F8-\u00FE]/g,a=>a.slice(1).toUpperCase()),index$1=a=>a.charAt(0).toLowerCase()+a.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,a=>'-'+a.toLowerCase()),index$2=a=>a.charAt(0).toLowerCase()+a.slice(1).replace(/[A-Z\u00C0-\u00D6\u00D8-\u00DE]/g,a=>'_'+a.toLowerCase());exports.camel=index,exports.kebab=index$1,exports.snake=index$2,exports.deattribute=deattribute,exports.deserialise=deserialise,exports.error=error,exports.filterIncludes=filterIncludes,exports.linkRelationships=linkRelationships,exports.query=query,exports.serialise=serialise;
//# sourceMappingURL=index.js.map
{
"version": "5.1.0",
"version": "5.1.1",
"name": "kitsu-core",

@@ -4,0 +4,0 @@ "description": "Core serialisation and deserialsation functions for the kitsu JSON:API client",

@@ -28,5 +28,5 @@ # Kitsu Core

| ------------------: | :----------------: | :--: | :----: | :-----: | :----: | :--: | :-: |
| `kitsu-core` | 9.9 kb | 6+ | 51+ | 47+ | 9.1+ | 14+ | |
| `kitsu-core/legacy` | 11.8 kb | 6+ | 4+ | 3+ | 3.1+ | 12+ | 8+ |
| `kitsu-core/node` | 7.2 kb | 6+ | | | | | |
| `kitsu-core` | 9.9 kb | 6+ | 52+ | 47+ | 10+ | 14+ | |
| `kitsu-core/legacy` | 11.9 kb | 6+ | 4+ | 3+ | 3.2+ | 12+ | 8+ |
| `kitsu-core/node` | 7.3 kb | 6+ | | | | | |

@@ -33,0 +33,0 @@ \* Including all dependencies, minified & gzipped

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

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