mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-16 02:11:48 +08:00
66a6d0dc70
- Extract props on basic-year-table - Update the function signature of utils.castArray
14 lines
449 B
TypeScript
14 lines
449 B
TypeScript
export const unique = <T>(arr: T[]) => [...new Set(arr)]
|
|
|
|
type Many<T> = T | ReadonlyArray<T>
|
|
// TODO: rename to `ensureArray`
|
|
/** like `_.castArray`, except falsy value returns empty array. */
|
|
export const castArray = <T>(arr: Many<T>): T[] => {
|
|
if (!arr && (arr as any) !== 0) return []
|
|
return Array.isArray(arr) ? arr : [arr]
|
|
}
|
|
|
|
// TODO: remove import alias
|
|
// avoid naming conflicts
|
|
export { castArray as ensureArray } from 'lodash-unified'
|