ob-map
Simple object mapper for creating flat javascript objects.
Description
Maps an object to a flat structure. Map object keys from one key to another with the help of a mapping object. Supports mapping of a nested object to a flat structure.
Installation
npm
npm install --save ob-map
yarn
yarn add ob-map
Usage
Flat Structure
; ;// => {y: 1, z: 2}
Nested Structure
; const obj = a: b: c: 1 d: e: 2 ; const mapping = x: 'a.b.c' y: 'd.e'; ;// => {x: 1, y: 2}
Bulk Map
; const arr = a: 1 b: 2 c: 3 a: 3 b: 4 c: 5 ; const mapping = x: 'a' y: 'b' z: 'c'; ;// => [{ x: 1, y: 2, z: 3 },{ x: 3, y: 4, z: 5 }]