MCPcopy Create free account
hub / github.com/activejs/activejs / insert

Method insert

packages/core/src/lib/list-unit.ts:159–168  ·  view source on GitHub ↗

* Inserts items to the list-value. \ * Dispatches a new copy of the value, without mutating the current-value. * * It only works if the Unit is not frozen and there's at least 1 item to be inserted. * * @param start The zero-based index in the list from which to start adding i

(start: number, ...items: Item[])

Source from the content-addressed store, hash-verified

157 * @category Custom ListUnit
158 */
159 insert(start: number, ...items: Item[]): number {
160 if (this.isFrozen || !items.length) {
161 return this.length;
162 }
163 this.checkSerializabilityMaybe(items);
164
165 this.splice(start, 0, ...items); // splice also takes care of empty spaces
166
167 return this.length;
168 }
169
170 /**
171 * Removes items at given indices from the list-{@link value}. \

Callers 3

utils.tsFile · 0.80
list-unit.spec.tsFile · 0.80

Calls 1

spliceMethod · 0.95

Tested by

no test coverage detected