MCPcopy Create free account
hub / github.com/Snapchat/Valdi / arrayGenerate

Function arrayGenerate

src/valdi_modules/src/valdi/foundation/src/array.ts:11–17  ·  view source on GitHub ↗
(size: number, call: (index: number) => T)

Source from the content-addressed store, hash-verified

9 * Create an array of arbitrary size by calling a function x times and saving its return value in the array
10 */
11export function arrayGenerate<T>(size: number, call: (index: number) => T): T[] {
12 const result: T[] = [];
13 for (let i = 0; i < size; i++) {
14 result.push(call(i));
15 }
16 return result;
17}
18
19/*
20 * Immutable insert function

Callers 1

arrayRepeatFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected