mirror of
https://github.com/element-plus/element-plus.git
synced 2024-12-15 02:40:46 +08:00
7bba5332f1
* chore: update dependencies typescript: v5.5 vue-tsc: v2 eslint: v8-latest @commitlint/*: v18 * fix: apply suggestions * fix: ignore some ts errors
16 lines
483 B
TypeScript
16 lines
483 B
TypeScript
import { isArray } from './types'
|
|
|
|
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 isArray(arr) ? arr : [arr as T]
|
|
}
|
|
|
|
// TODO: remove import alias
|
|
// avoid naming conflicts
|
|
export { castArray as ensureArray } from 'lodash-unified'
|