mirror of
https://github.com/swc-project/swc.git
synced 2024-12-20 20:22:26 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
25 lines
538 B
TypeScript
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; |