data-normalize

0.1.1 • Public • Published

Data Normalize

Description

A modified version for andreamangano/normalize-data.

Library to normalize data structure changes, include Map object.

Usage

  • CJS
    const { normalize } = require("data-normalize")
  • ESM
    import { normalize } from "data-normalize";
import { normalize } from "data-normalize";

const originObjectMap = {
    name: new Map([
        ["first", "Fajar"],
        ["last", "BC"],
    ]),

};

function transformToFullname(name) {
return `${name.get("first")} ${name.get("last")}`;
}

console.log(normalize(originObjectMap, [["fullname", "name", transformToFullname]], true))
/**
 * Output
 * { fullname: 'Fajar BC' }
 */
console.log(normalize(originObjectMap, [["name", "name.first"]]))
/**
 * Output
 * { name: 'Fajar' }
 */

Package Sidebar

Install

npm i data-normalize

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

5.99 kB

Total Files

5

Last publish

Collaborators

  • fajarbc