@aegenet/belt-obj-to-array
v2.3.0
Published
Object to array
Downloads
78
Readme
@aegenet/belt-obj-to-array
Object to Array
💾 Installation
yarn add @aegenet/belt-obj-to-array@^2.0.0
# or
npm i @aegenet/belt-obj-to-array@^2.0.0
📝 Usage
import { objectToArray } from '@aegenet/belt-obj-to-array';
const results = objectToArray({
1: 'Bo',
2: 'Jack',
});
// results = ['Bo', 'Jack']
const results = objectToArray({
a: 'Bo',
b: 'Jack',
}),
// results = ['Bo', 'Jack']
const results = objectToArray({
a: 'Bo',
b: 'Jack',
c: () => 'Yo',
});
// results = ['Bo', 'Jack']
const results = objectToArray(
{
a: 'Bo',
b: 'Jack',
c: () => 'Yo',
},
{ fields: ['a'] }
);
// results = ['Bo']
const results = objectToArray(
{
1: 'Bo',
2: 'Jack',
3: () => 'Yo',
4: 'Boris',
5: 'Maurice',
6: 'Something',
},
{ control: /[0-3]/ }
);
// results = ['Bo', 'Jack']