/
githubmirror
/
immutable-js
Обзор
Документация
Войти
/
githubmirror
/
immutable-js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v5.1.0
src/Collection.js
37 строк
1 KB
Julien Deniau
Upgrade eslint and ignore no-constructor-return rule for actual constructors (#1974)
27 янв 2024, 01:57
Не верифицирован
27 янв 2024, 01:57
7f9ba58
Код
Авторство
О чём код?
import { Seq, KeyedSeq, IndexedSeq, SetSeq } from './Seq'; import { isCollection } from './predicates/isCollection'; import { isKeyed } from './predicates/isKeyed'; import { isIndexed } from './predicates/isIndexed'; import { isAssociative } from './predicates/isAssociative'; export class Collection { constructor(value) { // eslint-disable-next-line no-constructor-return return isCollection(value) ? value : Seq(value); } } export class KeyedCollection extends Collection { constructor(value) { // eslint-disable-next-line no-constructor-return return isKeyed(value) ? value : KeyedSeq(value); } } export class IndexedCollection extends Collection { constructor(value) { // eslint-disable-next-line no-constructor-return return isIndexed(value) ? value : IndexedSeq(value); } } export class SetCollection extends Collection { constructor(value) { // eslint-disable-next-line no-constructor-return return isCollection(value) && !isAssociative(value) ? value : SetSeq(value); } } Collection.Keyed = KeyedCollection; Collection.Indexed = IndexedCollection; Collection.Set = SetCollection;