swc/bundler/tests/.cache/deno/e07fc48ca28e556adcca084ee40f7e652d4fe4c3.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

25 lines
538 B
TypeScript

// Loaded from https://deno.land/x/graphql_deno@v15.0.0/lib/polyfills/flatMap.js
const flatMapMethod = Array.prototype.flatMap;
/* eslint-disable no-redeclare */
// $FlowFixMe
const flatMap = flatMapMethod ? function (list, fn) {
return flatMapMethod.call(list, fn);
} : function (list, fn) {
let result = [];
for (const item of list) {
const value = fn(item);
if (Array.isArray(value)) {
result = result.concat(value);
} else {
result.push(value);
}
}
return result;
};
export default flatMap;