github-pages-deploy-action/node_modules/graphql/polyfills/flatMap.mjs
2020-03-06 22:45:40 -05:00

24 lines
497 B
JavaScript

var flatMapMethod = Array.prototype.flatMap;
/* eslint-disable no-redeclare */
// $FlowFixMe
var flatMap = flatMapMethod ? function (list, fn) {
return flatMapMethod.call(list, fn);
} : function (list, fn) {
var result = [];
for (var _i2 = 0; _i2 < list.length; _i2++) {
var _item = list[_i2];
var value = fn(_item);
if (Array.isArray(value)) {
result = result.concat(value);
} else {
result.push(value);
}
}
return result;
};
export default flatMap;