@hckrnews/normalizer
v0.3.3
Published
Normalizer objects
Downloads
3
Readme
Normalize objects
Installation
npm install @hckrnews/normalizer
or
yarn add @hckrnews/normalizer
Test the package
npm run test
or
yarn test
Usage
import makeNormalizer from '@hckrnews/normalizer';
const schemaFrom = {
pim_sku: String,
pim_productgroupname: String
}
const schemaTo = {
sku: String,
group: {
name: String
}
}
const Normalizer = makeNormalizer({ schemaFrom, schemaTo })
const rawData = [
{
pim_sku: '123',
pim_productgroupname: 'Bike'
}
]
const mapping = (data) => ({
sku: data.pim_sku,
group: {
name: data.pim_productgroupname
}
})
const normalizer = new Normalizer({ data: rawData, mapping })
normalizer.normalizedData
[
{
sku: '123',
group: {
name: 'Bike'
}
}
]