/
githubmirror
/
immutable-js
Обзор
Документация
Войти
/
githubmirror
/
immutable-js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v5.1.2
src/utils/coerceKeyPath.ts
15 строк
487 B
Julien Deniau
Migrate functional files to TS (#2063)
23 мар 2025, 00:38
Не верифицирован
23 мар 2025, 00:38
70826e6
Код
Авторство
О чём код?
import type { KeyPath } from '../../type-definitions/immutable'; import { isOrdered } from '../predicates/isOrdered'; import isArrayLike from './isArrayLike'; export default function coerceKeyPath<K>(keyPath: KeyPath<K>): ArrayLike<K> { if (isArrayLike(keyPath) && typeof keyPath !== 'string') { return keyPath; } if (isOrdered(keyPath)) { return keyPath.toArray(); } throw new TypeError( 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath ); }