MCPcopy Create free account
hub / github.com/mikro-orm/mikro-orm / slice

Method slice

packages/core/src/entity/Collection.ts:706–725  ·  view source on GitHub ↗

* Extracts a slice of the collection items starting at position start to end (exclusive) of the collection. * If end is null it returns all elements from start to the end of the collection.

(start = 0, end?: number)

Source from the content-addressed store, hash-verified

704 * If end is null it returns all elements from start to the end of the collection.
705 */
706 slice(start = 0, end?: number): T[] {
707 this.checkInitialized();
708 let index = 0;
709 end ??= this.#items.size;
710 const items: T[] = [];
711
712 for (const item of this.#items) {
713 if (index === end) {
714 break;
715 }
716
717 if (index >= start && index < end) {
718 items.push(item);
719 }
720
721 index++;
722 }
723
724 return items;
725 }
726
727 /**
728 * Tests for the existence of an element that satisfies the given predicate.

Callers 15

executeMethod · 0.80
mapJoinedPropFunction · 0.80
createTableMethod · 0.80
getAllIndexesMethod · 0.80
getAllColumnsMethod · 0.80
getAllTriggersMethod · 0.80
getTableTriggersMethod · 0.80
parseTriggerDDLMethod · 0.80
wrapWriteMethod · 0.80
resolveNestedPathMethod · 0.80

Calls 2

checkInitializedMethod · 0.95
pushMethod · 0.80

Tested by 2

convertToJSValueMethod · 0.64
decryptFunction · 0.64