0.1.1 • Published 1 year ago

data-normalize v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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' }
 */