DEV Community

Discussion on: Array.filter() Is Awesome

Collapse
 
karandikarmihir profile image
Mihir Karandikar

Another way is to normalize the array into an object and directly deleting the desired object. Check out "normalizr" library when you have free time.

Collapse
 
dance2die profile image
Sung M. Kim

Is this the library you are referring to?

paularmstrong / normalizr

Normalizes nested JSON according to a schema

normalizr build status Coverage Status npm version npm downloads

Install

Install from the NPM repository using yarn or npm:

yarn add normalizr
npm install normalizr

Motivation

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.

Solution

Normalizr is a small, but powerful utility for taking JSON with a schema definition and returning nested entities with their IDs, gathered in dictionaries.

Documentation

Examples

Quick Start

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"
Collapse
 
karandikarmihir profile image
Mihir Karandikar

That's right.