|
24 | 24 |
|
25 | 25 | <p align=center><a href=https://github.com/wopian/kitsu/blob/master/packages/kitsu-core/MIGRATING.md>Migration guide</a> for v10 & previous major releases</p> |
26 | 26 |
|
27 | | -# |
| 27 | +# |
28 | 28 |
|
29 | 29 | ## Features |
30 | 30 |
|
|
38 | 38 |
|
39 | 39 | | Package | Package<br> Size\* | ESM Size† | Node | Chrome | Firefox | Safari | Edge | |
40 | 40 | | -----------: | :----------------: | :-------: | :--: | :----: | :-----: | :----: | :--: | |
41 | | -| `kitsu-core` | ≤ 1.5 kb | ≤ 1.4 KB | 12+ | 72+ | 78+ | 12.1+ | 86+ | |
| 41 | +| `kitsu-core` | ≤ 1.5 kb | ≤ 1.4 KB | 12+ | 72+ | 78+ | 12.1+ | 86+ | |
42 | 42 |
|
43 | 43 | \* Minified with brotli |
44 | 44 | † EcmaScript Modules package size\* |
@@ -91,43 +91,71 @@ All code released under [MIT] |
91 | 91 |
|
92 | 92 | #### Table of Contents |
93 | 93 |
|
94 | | -- [deattribute](#deattribute) |
| 94 | +- [camel](#camel) |
95 | 95 | - [Parameters](#parameters) |
96 | 96 | - [Examples](#examples) |
97 | | -- [deserialise](#deserialise) |
| 97 | +- [deattribute](#deattribute) |
98 | 98 | - [Parameters](#parameters-1) |
99 | 99 | - [Examples](#examples-1) |
100 | | -- [error](#error) |
| 100 | +- [deserialise](#deserialise) |
101 | 101 | - [Parameters](#parameters-2) |
102 | 102 | - [Examples](#examples-2) |
103 | | -- [filterIncludes](#filterincludes) |
| 103 | +- [error](#error) |
104 | 104 | - [Parameters](#parameters-3) |
105 | 105 | - [Examples](#examples-3) |
106 | | -- [linkRelationships](#linkrelationships) |
| 106 | +- [filterIncludes](#filterincludes) |
107 | 107 | - [Parameters](#parameters-4) |
108 | 108 | - [Examples](#examples-4) |
109 | | -- [query](#query) |
| 109 | +- [kebab](#kebab) |
110 | 110 | - [Parameters](#parameters-5) |
111 | 111 | - [Examples](#examples-5) |
112 | | -- [serialise](#serialise) |
| 112 | +- [linkRelationships](#linkrelationships) |
113 | 113 | - [Parameters](#parameters-6) |
114 | 114 | - [Examples](#examples-6) |
115 | | -- [splitModel](#splitmodel) |
| 115 | +- [query](#query) |
116 | 116 | - [Parameters](#parameters-7) |
117 | 117 | - [Examples](#examples-7) |
118 | | -- [camel](#camel) |
| 118 | +- [serialise](#serialise) |
119 | 119 | - [Parameters](#parameters-8) |
120 | 120 | - [Examples](#examples-8) |
121 | | -- [kebab](#kebab) |
| 121 | +- [snake](#snake) |
122 | 122 | - [Parameters](#parameters-9) |
123 | 123 | - [Examples](#examples-9) |
124 | | -- [snake](#snake) |
| 124 | +- [splitModel](#splitmodel) |
125 | 125 | - [Parameters](#parameters-10) |
126 | 126 | - [Examples](#examples-10) |
127 | 127 |
|
| 128 | +### camel |
| 129 | + |
| 130 | +[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/camel/index.js#L14-L14 "Source code on GitHub") |
| 131 | + |
| 132 | +Converts kebab-case and snake_case into camelCase |
| 133 | + |
| 134 | +#### Parameters |
| 135 | + |
| 136 | +- `input` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** String to convert |
| 137 | + |
| 138 | +#### Examples |
| 139 | + |
| 140 | +Convert kebab-case |
| 141 | + |
| 142 | + |
| 143 | +```javascript |
| 144 | +camel('hello-world') // 'helloWorld' |
| 145 | +``` |
| 146 | + |
| 147 | +Convert snake_case |
| 148 | + |
| 149 | + |
| 150 | +```javascript |
| 151 | +camel('hello_world') // 'helloWorld' |
| 152 | +``` |
| 153 | + |
| 154 | +Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** camelCase formatted string |
| 155 | + |
128 | 156 | ### deattribute |
129 | 157 |
|
130 | | -[packages/kitsu-core/src/deattribute/index.js:29-51](https://github.com/wopian/kitsu/blob/e1b988cb961081f12309f5e881d63d123be7f4cf/packages/kitsu-core/src/deattribute/index.js#L29-L51 "Source code on GitHub") |
| 158 | +[packages/kitsu-core/src/deattribute/index.js:29-51](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/deattribute/index.js#L29-L51 "Source code on GitHub") |
131 | 159 |
|
132 | 160 | Hoists attributes to be top-level |
133 | 161 |
|
@@ -171,7 +199,7 @@ Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/ |
171 | 199 |
|
172 | 200 | ### deserialise |
173 | 201 |
|
174 | | -[packages/kitsu-core/src/deserialise/index.js:57-72](https://github.com/wopian/kitsu/blob/e1b988cb961081f12309f5e881d63d123be7f4cf/packages/kitsu-core/src/deserialise/index.js#L57-L72 "Source code on GitHub") |
| 202 | +[packages/kitsu-core/src/deserialise/index.js:57-72](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/deserialise/index.js#L57-L72 "Source code on GitHub") |
175 | 203 |
|
176 | 204 | Deserialises a JSON-API response |
177 | 205 |
|
@@ -223,7 +251,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G |
223 | 251 |
|
224 | 252 | ### error |
225 | 253 |
|
226 | | -[packages/kitsu-core/src/error/index.js:27-33](https://github.com/wopian/kitsu/blob/e1b988cb961081f12309f5e881d63d123be7f4cf/packages/kitsu-core/src/error/index.js#L27-L33 "Source code on GitHub") |
| 254 | +[packages/kitsu-core/src/error/index.js:27-33](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/error/index.js#L27-L33 "Source code on GitHub") |
227 | 255 |
|
228 | 256 | Uniform error handling for Axios, JSON:API and internal package errors. Mutated Error object is rethrown to the caller. |
229 | 257 |
|
@@ -260,14 +288,14 @@ error({ |
260 | 288 |
|
261 | 289 | ### filterIncludes |
262 | 290 |
|
263 | | -[packages/kitsu-core/src/filterIncludes/index.js:33-46](https://github.com/wopian/kitsu/blob/e1b988cb961081f12309f5e881d63d123be7f4cf/packages/kitsu-core/src/filterIncludes/index.js#L33-L46 "Source code on GitHub") |
| 291 | +[packages/kitsu-core/src/filterIncludes/index.js:33-46](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/filterIncludes/index.js#L33-L46 "Source code on GitHub") |
264 | 292 |
|
265 | 293 | Filters includes for the specific relationship requested |
266 | 294 |
|
267 | 295 | #### Parameters |
268 | 296 |
|
269 | 297 | - `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 |
270 | | -- `relationship` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** |
| 298 | +- `relationship` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** |
271 | 299 | - `relationship.id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship ID |
272 | 300 | - `relationship.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship type |
273 | 301 |
|
@@ -297,9 +325,27 @@ const response = filterIncludes(includes, relationship) |
297 | 325 |
|
298 | 326 | 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 |
299 | 327 |
|
| 328 | +### kebab |
| 329 | + |
| 330 | +[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/kebab/index.js#L11-L11 "Source code on GitHub") |
| 331 | + |
| 332 | +Converts camelCase into kebab-case |
| 333 | + |
| 334 | +#### Parameters |
| 335 | + |
| 336 | +- `input` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** camelCase string |
| 337 | + |
| 338 | +#### Examples |
| 339 | + |
| 340 | +```javascript |
| 341 | +kebab('helloWorld') // 'hello-world' |
| 342 | +``` |
| 343 | + |
| 344 | +Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** kebab-case formatted string |
| 345 | + |
300 | 346 | ### linkRelationships |
301 | 347 |
|
302 | | -[packages/kitsu-core/src/linkRelationships/index.js:97-117](https://github.com/wopian/kitsu/blob/e1b988cb961081f12309f5e881d63d123be7f4cf/packages/kitsu-core/src/linkRelationships/index.js#L97-L117 "Source code on GitHub") |
| 348 | +[packages/kitsu-core/src/linkRelationships/index.js:97-117](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/linkRelationships/index.js#L97-L117 "Source code on GitHub") |
303 | 349 |
|
304 | 350 | Links relationships to included data |
305 | 351 |
|
@@ -337,7 +383,7 @@ Returns **any** Parsed data |
337 | 383 |
|
338 | 384 | ### query |
339 | 385 |
|
340 | | -[packages/kitsu-core/src/query/index.js:33-44](https://github.com/wopian/kitsu/blob/e1b988cb961081f12309f5e881d63d123be7f4cf/packages/kitsu-core/src/query/index.js#L33-L44 "Source code on GitHub") |
| 386 | +[packages/kitsu-core/src/query/index.js:33-44](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/query/index.js#L33-L44 "Source code on GitHub") |
341 | 387 |
|
342 | 388 | Constructs a URL query string for JSON:API parameters |
343 | 389 |
|
@@ -365,7 +411,7 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G |
365 | 411 |
|
366 | 412 | ### serialise |
367 | 413 |
|
368 | | -[packages/kitsu-core/src/serialise/index.js:210-221](https://github.com/wopian/kitsu/blob/e1b988cb961081f12309f5e881d63d123be7f4cf/packages/kitsu-core/src/serialise/index.js#L210-L221 "Source code on GitHub") |
| 414 | +[packages/kitsu-core/src/serialise/index.js:210-221](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/serialise/index.js#L210-L221 "Source code on GitHub") |
369 | 415 |
|
370 | 416 | Serialises an object into a JSON-API structure |
371 | 417 |
|
@@ -409,9 +455,27 @@ const output = serialise(model, obj, 'PATCH') |
409 | 455 |
|
410 | 456 | Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The serialised data |
411 | 457 |
|
| 458 | +### snake |
| 459 | + |
| 460 | +[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/snake/index.js#L11-L11 "Source code on GitHub") |
| 461 | + |
| 462 | +Converts camelCase into snake_case |
| 463 | + |
| 464 | +#### Parameters |
| 465 | + |
| 466 | +- `input` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** camelCase string |
| 467 | + |
| 468 | +#### Examples |
| 469 | + |
| 470 | +```javascript |
| 471 | +snake('helloWorld') // 'hello_world' |
| 472 | +``` |
| 473 | + |
| 474 | +Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** snake_case formatted string |
| 475 | + |
412 | 476 | ### splitModel |
413 | 477 |
|
414 | | -[packages/kitsu-core/src/splitModel/index.js:29-39](https://github.com/wopian/kitsu/blob/e1b988cb961081f12309f5e881d63d123be7f4cf/packages/kitsu-core/src/splitModel/index.js#L29-L39 "Source code on GitHub") |
| 478 | +[packages/kitsu-core/src/splitModel/index.js:29-39](https://github.com/wopian/kitsu/blob/b34d85434473d745bfc9ce5784704ddc3855dd3c/packages/kitsu-core/src/splitModel/index.js#L29-L39 "Source code on GitHub") |
415 | 479 |
|
416 | 480 | Split model name from the model's resource URL |
417 | 481 |
|
@@ -451,67 +515,3 @@ splitModel('libraryEntries', { resourceCase: snake }) |
451 | 515 | ``` |
452 | 516 |
|
453 | 517 | Returns **\[[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)]** } Array containing the model name and the resource URL with pluralisation applied |
454 | | - |
455 | | -### camel |
456 | | - |
457 | | -[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/e1b988cb961081f12309f5e881d63d123be7f4cf/packages/kitsu-core/src/camel/index.js#L14-L14 "Source code on GitHub") |
458 | | - |
459 | | -Converts kebab-case and snake_case into camelCase |
460 | | - |
461 | | -#### Parameters |
462 | | - |
463 | | -- `input` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** String to convert |
464 | | - |
465 | | -#### Examples |
466 | | - |
467 | | -Convert kebab-case |
468 | | - |
469 | | - |
470 | | -```javascript |
471 | | -camel('hello-world') // 'helloWorld' |
472 | | -``` |
473 | | - |
474 | | -Convert snake_case |
475 | | - |
476 | | - |
477 | | -```javascript |
478 | | -camel('hello_world') // 'helloWorld' |
479 | | -``` |
480 | | - |
481 | | -Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** camelCase formatted string |
482 | | - |
483 | | -### kebab |
484 | | - |
485 | | -[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/e1b988cb961081f12309f5e881d63d123be7f4cf/packages/kitsu-core/src/kebab/index.js#L11-L11 "Source code on GitHub") |
486 | | - |
487 | | -Converts camelCase into kebab-case |
488 | | - |
489 | | -#### Parameters |
490 | | - |
491 | | -- `input` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** camelCase string |
492 | | - |
493 | | -#### Examples |
494 | | - |
495 | | -```javascript |
496 | | -kebab('helloWorld') // 'hello-world' |
497 | | -``` |
498 | | - |
499 | | -Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** kebab-case formatted string |
500 | | - |
501 | | -### snake |
502 | | - |
503 | | -[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/e1b988cb961081f12309f5e881d63d123be7f4cf/packages/kitsu-core/src/snake/index.js#L11-L11 "Source code on GitHub") |
504 | | - |
505 | | -Converts camelCase into snake_case |
506 | | - |
507 | | -#### Parameters |
508 | | - |
509 | | -- `input` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** camelCase string |
510 | | - |
511 | | -#### Examples |
512 | | - |
513 | | -```javascript |
514 | | -snake('helloWorld') // 'hello_world' |
515 | | -``` |
516 | | - |
517 | | -Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** snake_case formatted string |
0 commit comments