/
githubmirror
/
immutable-js
Обзор
Документация
Войти
/
githubmirror
/
immutable-js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v5.1.9
src/predicates/isCollection.ts
27 строк
909 B
Julien Deniau
import comments into TS files
23 фев 2025, 22:59
23 фев 2025, 22:59
c16cbcf
Код
Авторство
О чём код?
import type { Collection } from '../../type-definitions/immutable'; // Note: value is unchanged to not break immutable-devtools. export const IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@'; /** * True if `maybeCollection` is a Collection, or any of its subclasses. * * ```js * import { isCollection, Map, List, Stack } from 'immutable'; * * isCollection([]); // false * isCollection({}); // false * isCollection(Map()); // true * isCollection(List()); // true * isCollection(Stack()); // true * ``` */ export function isCollection( maybeCollection: unknown ): maybeCollection is Collection<unknown, unknown> { return Boolean( maybeCollection && // @ts-expect-error: maybeCollection is typed as `{}`, need to change in 6.0 to `maybeCollection && typeof maybeCollection === 'object' && IS_COLLECTION_SYMBOL in maybeCollection` maybeCollection[IS_COLLECTION_SYMBOL] ); }