data-normalize
v0.1.1
Published
Library to normalize data structure changes
Downloads
1
Readme
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' }
*/