You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/kitsu-core/README.md
+87-21Lines changed: 87 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@
26
26
27
27
<palign=center>Core <ahref=http://jsonapi.org>JSON:API</a> serialisation and deserialisation components</p>
28
28
29
-
#
29
+
#
30
30
31
31
## Features
32
32
@@ -97,19 +97,22 @@ kitsuCore.camel(...)
97
97
-[serialise](#serialise)
98
98
-[Parameters](#parameters-6)
99
99
-[Examples](#examples-2)
100
-
-[camel](#camel)
100
+
-[splitModel](#splitmodel)
101
101
-[Parameters](#parameters-7)
102
102
-[Examples](#examples-3)
103
-
-[kebab](#kebab)
103
+
-[camel](#camel)
104
104
-[Parameters](#parameters-8)
105
105
-[Examples](#examples-4)
106
-
-[snake](#snake)
106
+
-[kebab](#kebab)
107
107
-[Parameters](#parameters-9)
108
108
-[Examples](#examples-5)
109
+
-[snake](#snake)
110
+
-[Parameters](#parameters-10)
111
+
-[Examples](#examples-6)
109
112
110
113
### deattribute
111
114
112
-
[packages/kitsu-core/src/deattribute/index.js:29-38](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/deattribute/index.js#L29-L38"Source code on GitHub")
115
+
[packages/kitsu-core/src/deattribute/index.js:29-38](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu-core/src/deattribute/index.js#L29-L38"Source code on GitHub")
[packages/kitsu-core/src/deserialise/index.js:56-72](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/deserialise/index.js#L56-L72"Source code on GitHub")
159
+
[packages/kitsu-core/src/deserialise/index.js:57-74](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu-core/src/deserialise/index.js#L57-L74"Source code on GitHub")
[packages/kitsu-core/src/error/index.js:7-13](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/error/index.js#L7-L13"Source code on GitHub")
211
+
[packages/kitsu-core/src/error/index.js:7-13](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu-core/src/error/index.js#L7-L13"Source code on GitHub")
209
212
210
213
Uniform error handling for Axios, JSON:API and internal package errors. Mutated Error object is rethrown to the caller.
211
214
@@ -218,33 +221,33 @@ Uniform error handling for Axios, JSON:API and internal package errors. Mutated
218
221
219
222
### filterIncludes
220
223
221
-
[packages/kitsu-core/src/filterIncludes/index.js:12-25](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/filterIncludes/index.js#L12-L25"Source code on GitHub")
224
+
[packages/kitsu-core/src/filterIncludes/index.js:12-25](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu-core/src/filterIncludes/index.js#L12-L25"Source code on GitHub")
222
225
223
226
Filters includes for the specific relationship
224
227
225
228
#### Parameters
226
229
227
230
-`included`**[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The response included object
-`opts.id`**[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship ID
230
233
-`opts.type`**[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship type
231
234
232
235
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** The matched includes
233
236
234
237
### linkRelationships
235
238
236
-
[packages/kitsu-core/src/linkRelationships/index.js:55-74](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/linkRelationships/index.js#L55-L74"Source code on GitHub")
239
+
[packages/kitsu-core/src/linkRelationships/index.js:75-96](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu-core/src/linkRelationships/index.js#L75-L96"Source code on GitHub")
237
240
238
241
Links relationships to included data
239
242
240
243
#### Parameters
241
244
242
245
-`data`**[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The response data object
243
-
-`included`**[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The response included object
246
+
-`included`**[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The response included object (optional, default `[]`)
244
247
245
248
### query
246
249
247
-
[packages/kitsu-core/src/query/index.js:21-32](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/query/index.js#L21-L32"Source code on GitHub")
250
+
[packages/kitsu-core/src/query/index.js:21-32](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu-core/src/query/index.js#L21-L32"Source code on GitHub")
248
251
249
252
Constructs a URL query string for JSON:API parameters
[packages/kitsu-core/src/serialise/index.js:103-134](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/serialise/index.js#L103-L134"Source code on GitHub")
263
+
[packages/kitsu-core/src/serialise/index.js:119-152](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu-core/src/serialise/index.js#L119-L152"Source code on GitHub")
261
264
262
265
Serialises an object into a JSON-API structure
263
266
264
267
#### Parameters
265
268
266
269
-`model`**[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Request model
267
270
-`obj`**[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The data (optional, default `{}`)
268
-
-`method`**[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Request type (optional, default `'POST'`)
271
+
-`method`**[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Request type (PATCH, POST, DELETE) (optional, default `'POST'`)
272
+
-`options`**[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Optional configuration for camelCase and pluralisation handling (optional, default `{}`)
273
+
-`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
274
+
-`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)
269
275
270
276
#### Examples
271
277
272
-
Due to its usage in kitsu, it **MUST** be called with **this** set in 6.0.x
278
+
Setting camelCaseTypes and pluralTypes options (example shows options used by `kitsu` by default)
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The serialised data
283
306
307
+
### splitModel
308
+
309
+
[packages/kitsu-core/src/splitModel/index.js:29-39](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu-core/src/splitModel/index.js#L29-L39"Source code on GitHub")
310
+
311
+
Split model name from the model's resource URL
312
+
313
+
#### Parameters
314
+
315
+
-`url`**[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** URL path for the model
-`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
318
+
-`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)
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** Array containing the model name and the resource URL with pluralisation applied
349
+
284
350
### camel
285
351
286
-
[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/camel/index.js#L14-L14"Source code on GitHub")
352
+
[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu-core/src/camel/index.js#L14-L14"Source code on GitHub")
[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/kebab/index.js#L11-L11"Source code on GitHub")
380
+
[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu-core/src/kebab/index.js#L11-L11"Source code on GitHub")
[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu-core/src/snake/index.js#L11-L11"Source code on GitHub")
398
+
[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu-core/src/snake/index.js#L11-L11"Source code on GitHub")
Copy file name to clipboardExpand all lines: packages/kitsu/README.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@
26
26
27
27
<palign=center>A simple, lightweight & framework agnostic <ahref=http://jsonapi.org>JSON:API</a> client for <ahref=https://kitsu.io>Kitsu.io</a> and other APIs</p>
28
28
29
-
#
29
+
#
30
30
31
31
## Features
32
32
@@ -192,7 +192,7 @@ If you're working with [Kitsu.io]'s API, their [API docs][kitsu.io api docs] lis
192
192
193
193
### Kitsu
194
194
195
-
[packages/kitsu/src/index.js:30-324](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu/src/index.js#L30-L324"Source code on GitHub")
195
+
[packages/kitsu/src/index.js:30-342](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu/src/index.js#L30-L342"Source code on GitHub")
196
196
197
197
Creates a new `kitsu` instance
198
198
@@ -239,7 +239,7 @@ const api = new Kitsu({
239
239
240
240
#### plural
241
241
242
-
[packages/kitsu/src/index.js:52-53](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu/src/index.js#L52-L53"Source code on GitHub")
242
+
[packages/kitsu/src/index.js:52-53](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu/src/index.js#L52-L53"Source code on GitHub")
243
243
244
244
-**See: <https://www.npmjs.com/package/pluralize> for documentation
[packages/kitsu/src/index.js:67-67](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu/src/index.js#L67-L67"Source code on GitHub")
264
+
[packages/kitsu/src/index.js:67-67](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu/src/index.js#L67-L67"Source code on GitHub")
[packages/kitsu/src/index.js:111-111](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu/src/index.js#L111-L111"Source code on GitHub")
295
+
[packages/kitsu/src/index.js:111-111](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu/src/index.js#L111-L111"Source code on GitHub")
296
296
297
297
Axios Interceptors (alias of `axios.interceptors`)
[packages/kitsu/src/index.js:184-203](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu/src/index.js#L184-L203"Source code on GitHub")
343
+
[packages/kitsu/src/index.js:184-203](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu/src/index.js#L184-L203"Source code on GitHub")
[packages/kitsu/src/index.js:219-233](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu/src/index.js#L219-L233"Source code on GitHub")
455
+
[packages/kitsu/src/index.js:219-239](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu/src/index.js#L219-L239"Source code on GitHub")
[packages/kitsu/src/index.js:256-269](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu/src/index.js#L256-L269"Source code on GitHub")
481
+
[packages/kitsu/src/index.js:262-281](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu/src/index.js#L262-L281"Source code on GitHub")
[packages/kitsu/src/index.js:282-294](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu/src/index.js#L282-L294"Source code on GitHub")
514
+
[packages/kitsu/src/index.js:294-312](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu/src/index.js#L294-L312"Source code on GitHub")
[packages/kitsu/src/index.js:316-323](https://github.com/wopian/kitsu/blob/72acbe7a81cc60718cbaaa4cc99c6b0dcf8b58de/packages/kitsu/src/index.js#L316-L323"Source code on GitHub")
537
+
[packages/kitsu/src/index.js:334-341](https://github.com/wopian/kitsu/blob/8576749f2211c86ac5fcbada6328efdf023c8eb4/packages/kitsu/src/index.js#L334-L341"Source code on GitHub")
0 commit comments