Convert an object to array.
$ npm install --save object2array
const object2array = require('object2array')
object2array({
foo: 'blah',
bar: 'oops'
})
/*
[
{
key: 'foo',
value: 'blah'
},
{
key: 'bar',
value: 'oops'
}
]
*/
keyName
Default: 'key'
Example:
object2array({
foo: 'blah',
bar: 'oops'
}, {
keyName: 'id',
})
/*
[
{
id: 'foo',
value: 'blah'
},
{
id: 'bar',
value: 'oops'
}
]
*/
valueName
Default: 'value'
Example:
object2array({
foo: 'blah',
bar: 'oops'
}, {
valueName: 'data',
})
/*
[
{
key: 'foo',
data: 'blah'
},
{
key: 'bar',
data: 'oops'
}
]
*/
MIT © EGOIST