Compact doesn't handle undefined values like lodash does
```javascript
import {compact as loCompact} from 'lodash';
import {compact as esCompact} from 'es-toolkit';
console.log('lodash: ', loCompact(undefined)); // => returns []
console.log('es-toolkit: ', esCompact(undefined)); // => throws error
```
see:
https://codepen.io/editor/bertyhell/pen/019dbbb4-1d6a-786d-84b8-e63a47a9fe39
<img width="2559" height="1019" alt="Image" src="https://github.com/user-attachments/assets/0341b251-b0b1-4fa0-a437-3ccb3b698d57" />
Should i add this to the start of the compact function, or do we trust the typescript input type that the input of the compact function should always be an array instead of undefined
```javascript
arr = arr || [];
```
0 条评论