
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
@data-client/normalizr
Advanced tools
Normalizes and denormalizes JSON according to schema for Redux and Flux applications
Install from the NPM repository using yarn or npm:
yarn add @data-client/normalizr
npm install --save @data-client/normalizr
Many APIs, public or not, return JSON data that has deeply nested objects. Using data in this kind of structure is often very difficult for JavaScript applications, especially those using Flux or Redux.
Normalizr is a small, but powerful utility for taking JSON with a schema definition and returning nested entities with their IDs, gathered in dictionaries.
Consider a typical blog post. The API response for a single post might look something like this:
{
"id": "123",
"author": {
"id": "1",
"name": "Paul"
},
"title": "My awesome blog post",
"comments": [
{
"id": "324",
"commenter": {
"id": "2",
"name": "Nicole"
}
}
]
}
We have two nested entity types within our article
: users
and comments
. Using various schema
, we can normalize all three entity types down:
import { normalize, schema, Entity } from '@data-client/normalizr';
// Define a users schema
class User extends Entity {
pk() {
return this.id;
}
}
// Define your comments schema
class Comment extends Entity {
pk() {
return this.id;
}
static schema = {
commenter: User,
};
}
// Define your article
class Article extends Entity {
pk() {
return this.id;
}
static schema = {
author: User,
comments: [Comment],
};
}
const normalizedData = normalize(originalData, Article);
Now, normalizedData
will be:
{
result: "123",
entities: {
"Article": {
"123": {
id: "123",
author: "1",
title: "My awesome blog post",
comments: [ "324" ]
}
},
"User": {
"1": { "id": "1", "name": "Paul" },
"2": { "id": "2", "name": "Nicole" }
},
"Comment": {
"324": { id: "324", "commenter": "2" }
}
}
}
None.
Normalizr was originally created by Dan Abramov and inspired by a conversation with Jing Chen. Since v3, it was completely rewritten and maintained by Paul Armstrong. Since v4, it was largely rewritten and maintained by Nathaniel Tucker. It has also received much help, enthusiasm, and contributions from community members.
FAQs
Normalizes and denormalizes JSON according to schema for Redux and Flux applications
We found that @data-client/normalizr demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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 researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.