dynamic-object-yadab
v1.1.0
Published
Manage a list by dividing it in a dynamic object depending on that list's specific item
Downloads
13
Maintainers
Readme
Divide a list into object based on a specific field
New object = { key will be that field value: Value will be a list item containing that filed value }
Installation
Use the package manager to install foobar.
npm install dynamic-object-yadab
Usage
import { getDynamicObject } from 'dynamic-object-package'
# your data
let list = [
{
product: 1,
name: xiaomi 2/64
brand: xiaomi
},
{
product: 2,
name: samsung A21
brand: samsung
},
{
product: 3,
name: pocco x3 8/256
brand: xiaomi
},
]
getDynamicObject(list, 'brand') // instruct to divide list depending on brand (brandwise)
/* output:
{
xioami: [
{
product: 1,
name: xiaomi 2/64
brand: xiaomi
},{
product: 3,
name: pocco x3 8/256
brand: xiaomi
}
],
samsung: [
{
product: 2,
name: samsung A21
brand: samsung
}
]
}
*/