normaliz
A tiny library that normalizes data according to a schema.
Inspired by normalizr which is a great library. I just needed something more intuitive and lightweight.
Features
-
💸 Lightweight (~ 800 bytes minzipped)
-
💪 Simple but powerful and intuitive API
-
✅ Battle tested
Setup
npm i normaliz
Usage
const payload = id: 1 title: 'My Item' post: id: 4 date: '01-01-1970' users: userId: 1 name: 'john' userId: 2 name: 'jane' comments: id: 3 sub_id: 1 content: 'Hello' // Note: payload can also be an array of items. const entities = // Normalized entities: items : 1: id: 1 title: 'My Item' post: 4 users: 1 2 users: 1: userId: 1 name: 'john' 2: userId: 2 name: 'jane' comments: '3 - 1' posts: 4: id: 4 date: '01-01-1970' comments: '3 - 1': id: 3 sub_id: 1 content: 'Hello' itemsContainer: container_1: items: 1 // De-normalize an entityconst originalData =