Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
kitsu-core
Advanced tools
Core serialisation and deserialsation functions for the kitsu JSON:API client
Core JSON:API serialisation and deserialisation components for kitsu
Package | Package Size* | Node | Chrome | Firefox | Safari | Edge | IE |
---|---|---|---|---|---|---|---|
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+ |
* Including all dependencies, minified & gzipped
yarn add kitsu-core
npm install kitsu-core
import { camel } from 'kitsu-core' // ES Modules and Babel
const { camel } = require('kitsu-core') // CommonJS and Browserify
const { camel } = require('kitsu-core/legacy') // Legacy IE8+ support
const { camel } = require('kitsu-core/node') // Lighter node-only package
camel(...)
<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(...)
Converts kebab-case and snake_case into camelCase
Parameters
s
string String to convertExamples
Convert kebab-case
camel('hello-world') // 'helloWorld'
Convert snake_case
camel('hello_world') // 'helloWorld'
Returns string camelCase formatted string
Hoists attributes to be top-level
Parameters
Examples
Deattribute an array of resources
// JSON:API 'data' field
const data = [
{
id: '1',
type: 'users',
attributes: { slug: 'wopian' }
}
]
const output = await deattribute(data) // [ { id: '1', type: 'users', slug: 'wopian' } ]
Deattribute a resource
// JSON:API 'data' field
const data = {
id: '1',
type: 'users',
attributes: { slug: 'wopian' }
}
const output = await deattribute(data) // { id: '1', type: 'users', slug: 'wopian' }
Returns (Object | Array) Deattributed resource data
Deserialises a JSON-API response
Parameters
obj
Object The responseExamples
Deserialise with a basic data object
await deserialise({
data: {
id: '1',
attributes: { liked: true }
},
meta: { hello: 'world' }
}) // { data: { id: '1', liked: true }, meta: { hello: 'world' } }
Deserialise with relationships
await deserialise({
data: {
id: '1',
relationships: {
user: {
data: {
type: 'users',
id: '2' }
}
}
},
included: [
{
type: 'users',
id: '2',
attributes: { slug: 'wopian' }
}
]
}) // { data: { id: '1', user: { type: 'users', id: '2', slug: 'wopian' } } }
Returns Object The deserialised response
Mutates an error and rethrows it
Parameters
Filters includes for the specific relationship
Parameters
Returns Array The matched includes
Converts camelCase into kebab-case
Parameters
s
string camelCase stringExamples
kebab('helloWorld') // 'hello-world'
Returns string kekab-case formatted string
Links relationships to included data
Parameters
Constructs a URL query string for JSON:API parameters
Parameters
params
Object Parameters to parseprefix
boolean Prefix returned string with ?
(default false
) (optional, default false
)Returns string URL query string
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'
)Examples
Due to its usage in kitsu, it MUST be called with this set in 5.0.x
import { serialise, camel, kebab } from 'kitsu-core'
import plural from 'pluralize'
const output = await serialise.apply({ camel, resCase: kebab, plural }, [ model, obj, 'PATCH' ])
Returns Object The serialised data
Converts camelCase into snake_case
Parameters
s
string camelCase stringExamples
snake('helloWorld') // 'hello_world'
Returns string snake_case formatted string
See CONTRIBUTING
See CHANGELOG
All code released under MIT
FAQs
Simple, lightweight & framework agnostic JSON:API (de)serialsation components
The npm package kitsu-core receives a total of 6,250 weekly downloads. As such, kitsu-core popularity was classified as popular.
We found that kitsu-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.