MCPcopy Create free account
hub / github.com/blacksmithgu/datacore / flatMap

Method flatMap

src/api/data-array.ts:225–235  ·  view source on GitHub ↗
(f: ArrayFunc<T, U[]>)

Source from the content-addressed store, hash-verified

223 }
224
225 public flatMap<U>(f: ArrayFunc<T, U[]>): DataArray<U> {
226 let result = [];
227 for (let index = 0; index < this.length; index++) {
228 let value = f(this.values[index], index, this.values);
229 if (!value || value.length == 0) continue;
230
231 for (let r of value) result.push(r);
232 }
233
234 return this.lwrap(result);
235 }
236
237 public mutate(f: ArrayFunc<T, void>): DataArray<T> {
238 for (let index = 0; index < this.values.length; index++) {

Callers

nothing calls this directly

Calls 1

lwrapMethod · 0.95

Tested by

no test coverage detected