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

Function sameFlatMap

test/fixtures/snapshot/typescript.js:761–781  ·  view source on GitHub ↗
(array, mapfn)

Source from the content-addressed store, hash-verified

759 }
760 ts.flatMapIterator = flatMapIterator;
761 function sameFlatMap(array, mapfn) {
762 var result;
763 if (array) {
764 for (var i = 0; i < array.length; i++) {
765 var item = array[i];
766 var mapped = mapfn(item, i);
767 if (result || item !== mapped || isArray(mapped)) {
768 if (!result) {
769 result = array.slice(0, i);
770 }
771 if (isArray(mapped)) {
772 addRange(result, mapped);
773 }
774 else {
775 result.push(mapped);
776 }
777 }
778 }
779 }
780 return result || array;
781 }
782 ts.sameFlatMap = sameFlatMap;
783 function mapAllOrFail(array, mapFn) {
784 var result = [];

Callers

nothing calls this directly

Calls 4

addRangeFunction · 0.85
isArrayFunction · 0.70
sliceMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected