MCPcopy
hub / github.com/immutable-js/immutable-js / constructor

Method constructor

src/List.js:32–58  ·  view source on GitHub ↗
(value)

Source from the content-addressed store, hash-verified

30 // @pragma Construction
31
32 constructor(value) {
33 const empty = emptyList();
34 if (value === undefined || value === null) {
35 // eslint-disable-next-line no-constructor-return
36 return empty;
37 }
38 if (isList(value)) {
39 // eslint-disable-next-line no-constructor-return
40 return value;
41 }
42 const iter = IndexedCollection(value);
43 const size = iter.size;
44 if (size === 0) {
45 // eslint-disable-next-line no-constructor-return
46 return empty;
47 }
48 assertNotInfinite(size);
49 if (size > 0 && size < SIZE) {
50 // eslint-disable-next-line no-constructor-return
51 return makeList(0, size, SHIFT, undefined, new VNode(iter.toArray()));
52 }
53 // eslint-disable-next-line no-constructor-return
54 return empty.withMutations((list) => {
55 list.setSize(size);
56 iter.forEach((v, i) => list.set(i, v));
57 });
58 }
59
60 static of(/*...values*/) {
61 return this(arguments);

Callers 1

concatMethod · 0.95

Calls 10

isListFunction · 0.90
IndexedCollectionClass · 0.90
emptyListFunction · 0.85
assertNotInfiniteFunction · 0.85
makeListFunction · 0.85
forEachMethod · 0.80
toArrayMethod · 0.65
withMutationsMethod · 0.65
setSizeMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected