listify
@guoba-ai/utils / object / listify
Function: listify()
function listify<T, U>(obj, fn): U[];Defined in: object.ts:262
Convert an object to an array by mapping each key-value pair.
Type Parameters
T
T extends object
U
U
Parameters
obj
T
The source object
fn
(key, value) => U
Function that receives each key and value, returns the array element
Returns
U[]
An array of mapped values
Example
listify({ a: 1, b: 2 }, (key, value) => `${key}=${value}`)
// ['a=1', 'b=2']