| 7 | import assertNotInfinite from './utils/assertNotInfinite'; |
| 8 | |
| 9 | export class OrderedSet extends Set { |
| 10 | // @pragma Construction |
| 11 | |
| 12 | constructor(value) { |
| 13 | // eslint-disable-next-line no-constructor-return |
| 14 | return value === undefined || value === null |
| 15 | ? emptyOrderedSet() |
| 16 | : isOrderedSet(value) |
| 17 | ? value |
| 18 | : emptyOrderedSet().withMutations((set) => { |
| 19 | const iter = SetCollection(value); |
| 20 | assertNotInfinite(iter.size); |
| 21 | iter.forEach((v) => set.add(v)); |
| 22 | }); |
| 23 | } |
| 24 | |
| 25 | static of(/*...values*/) { |
| 26 | return this(arguments); |
| 27 | } |
| 28 | |
| 29 | static fromKeys(value) { |
| 30 | return this(KeyedCollection(value).keySeq()); |
| 31 | } |
| 32 | |
| 33 | toString() { |
| 34 | return this.__toString('OrderedSet {', '}'); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | OrderedSet.isOrderedSet = isOrderedSet; |
| 39 |
no outgoing calls
no test coverage detected