https://github.com/fajarbc/data-normalize
Library to normalize data structure changes, a modified version of andreamangano/normalize-data
https://github.com/fajarbc/data-normalize
Last synced: about 2 months ago
JSON representation
Library to normalize data structure changes, a modified version of andreamangano/normalize-data
- Host: GitHub
- URL: https://github.com/fajarbc/data-normalize
- Owner: fajarbc
- License: mit
- Created: 2022-11-10T07:28:34.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-10T07:35:45.000Z (over 3 years ago)
- Last Synced: 2025-08-26T10:50:24.488Z (10 months ago)
- Language: JavaScript
- Size: 86.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Data Normalize
## Description
A modified version for [andreamangano/normalize-data](https://github.com/andreamangano/normalize-data).
Library to normalize data structure changes, include Map object.
## Usage
- CJS
```javascript
const { normalize } = require("data-normalize")
```
- ESM
```javascript
import { normalize } from "data-normalize";
```
```javascript
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' }
*/
```