mirror of
https://github.com/toss/es-toolkit.git
synced 2024-12-26 17:34:35 +03:00
8caab968b2
* feat : add toArray * feat : toArray bench * docs : add toArray * Update src/compat/util/toArray.ts --------- Co-authored-by: Sojin Park <raon0211@gmail.com>
740 B
740 B
toArray
::: info
This function is only available in es-toolkit/compat
for compatibility reasons. It either has alternative native JavaScript APIs or isn’t fully optimized yet.
When imported from es-toolkit/compat
, it behaves exactly like lodash and provides the same functionalities, as detailed here.
:::
Converts value into an array.
Signature
function toArray(value?: unknown): any[];
Parameters
value
(unknown
): The value to convert.
Returns
(any[]
): Returns the converted array.
Examples
toArray({ a: 1, b: 2 }); // returns [1, 2]
toArray('abc'); // returns ['a', 'b', 'c']
toArray(1); // returns []
toArray(null); // returns []