MCPcopy Index your code
hub / github.com/nodejs/node / flatMap

Function flatMap

test/fixtures/snapshot/typescript.js:698–714  ·  view source on GitHub ↗

* Maps an array. If the mapped value is an array, it is spread into the result. * * @param array The array to map. * @param mapfn The callback used to map the result into one or more values.

(array, mapfn)

Source from the content-addressed store, hash-verified

696 * @param mapfn The callback used to map the result into one or more values.
697 */
698 function flatMap(array, mapfn) {
699 var result;
700 if (array) {
701 for (var i = 0; i < array.length; i++) {
702 var v = mapfn(array[i], i);
703 if (v) {
704 if (isArray(v)) {
705 result = addRange(result, v);
706 }
707 else {
708 result = append(result, v);
709 }
710 }
711 }
712 }
713 return result || ts.emptyArray;
714 }
715 ts.flatMap = flatMap;
716 function flatMapToMutable(array, mapfn) {
717 var result = [];

Callers

nothing calls this directly

Calls 3

addRangeFunction · 0.85
isArrayFunction · 0.70
appendFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…