Kitsu Core
Core JSON:API serialisation and deserialisation components for kitsu
Features
- JSON-API 1.0 compliant
- Automatically links relationships to data
- Works in Node and on the web
- Uses the Promise API
Node / Browser Support
Package | Package Size* | Node | Chrome | Firefox | Safari | Edge | IE |
---|
kitsu-core | 9.9 kb | 6+ | 49+ | 47+ | 9.1+ | 14+ | |
kitsu-core/legacy | 11.9 kb | 6+ | 4+ | 3+ | 3.1+ | 12+ | 8+ |
kitsu-core/node | 7.2 kb | 6+ | | | | | |
* Including all dependencies, minified & gzipped
Install
Yarn / NPM
yarn add kitsu-core
npm install kitsu-core
import { camel } from 'kitsu-core'
const { camel } = require('kitsu-core')
const { camel } = require('kitsu-core/legacy')
const { camel } = require('kitsu-core/node')
camel(...)
Try it on RunKit
Packd CDN
<script src='https://bundle.run/kitsu-core@5?name=kitsuCore'></script>
<script src='https://bundle.run/kitsu@5/legacy/index.js?name=kitsuCore'></script>
kitsuCore.camel(...)
Try it on CodePen
API
Table of Contents
camel
Converts kebab-case and snake_case into camelCase
Parameters
Returns string camelCase formatted string
deattribute
Hoists attributes to be top-level
Parameters
Returns (Object | Array) Deattributed resource data
deserialise
Deserialises an object from a JSON-API structure
Parameters
Returns Object The deserialised response
error
Mutates an error and rethrows it
Parameters
filterIncludes
Filters includes for the specific relationship
Parameters
included
Object The response included objectopts
Object
opts.id
string The relationship IDopts.type
string The relationship type
Returns Array The matched includes
kebab
Converts camelCase into kebab-case
Parameters
Returns string kekab-case formatted string
linkRelationships
Links relationships to included data
Parameters
data
Object The response data objectincluded
Object The response included object
query
Constructs a URL query string for JSON:API parameters
Parameters
params
Object Parameters to parse
Returns string URL query string
serialise
Serialises an object into a JSON-API structure
Parameters
model
string Request modelobj
Object The data (optional, default {}
)method
string Request type (optional, default 'POST'
)
Returns Object The serialised data
snake
Converts camelCase into snake_case
Parameters
Returns string snake_case formatted string
Contributing
See CONTRIBUTING
Releases
See CHANGELOG
License
All code released under MIT