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

Method slice

src/Stack.js:117–140  ·  view source on GitHub ↗
(begin, end)

Source from the content-addressed store, hash-verified

115 }
116
117 slice(begin, end) {
118 if (wholeSlice(begin, end, this.size)) {
119 return this;
120 }
121 let resolvedBegin = resolveBegin(begin, this.size);
122 const resolvedEnd = resolveEnd(end, this.size);
123 if (resolvedEnd !== this.size) {
124 // super.slice(begin, end);
125 return IndexedCollection.prototype.slice.call(this, begin, end);
126 }
127 const newSize = this.size - resolvedBegin;
128 let head = this._head;
129 while (resolvedBegin--) {
130 head = head.next;
131 }
132 if (this.__ownerID) {
133 this.size = newSize;
134 this._head = head;
135 this.__hash = undefined;
136 this.__altered = true;
137 return this;
138 }
139 return makeStack(newSize, head);
140 }
141
142 // @pragma Mutability
143

Callers 1

popMethod · 0.95

Calls 4

wholeSliceFunction · 0.90
resolveBeginFunction · 0.90
resolveEndFunction · 0.90
makeStackFunction · 0.85

Tested by

no test coverage detected