HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/shop.komma.nl/node_modules/graphql/polyfills/flatMap.js.flow
// @flow strict

declare function flatMap<T, U>(
  list: $ReadOnlyArray<T>,
  fn: (item: T, index: number) => $ReadOnlyArray<U> | U,
): Array<U>;

// Workaround to make older Flow versions happy
const flatMapMethod = (Array.prototype: any).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;