diff --git a/src/utils/flatMap.spec.ts b/src/utils/flatMap.spec.ts deleted file mode 100644 index 4cd2c7a54..000000000 --- a/src/utils/flatMap.spec.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { flatMap } from './flatMap'; - -describe('flatMap', () => { - it('should produce correct result', () => { - expect(flatMap([1, 2, 3], i => [i])).toEqual([1, 2, 3]); - expect(flatMap([1, 2, 3], i => [i + 1])).toEqual([2, 3, 4]); - expect(flatMap([1, 2, 3], () => [1])).toEqual([1, 1, 1]); - }); -}); diff --git a/src/utils/flatMap.ts b/src/utils/flatMap.ts deleted file mode 100644 index 7dbcb3150..000000000 --- a/src/utils/flatMap.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Calls a defined callback on each element of an array. - * Then, flattens the result into a new array. - */ -export const flatMap = (array: T[], callback: (value: T, index: number, array: T[]) => U[]): U[] => { - const result: U[] = []; - array.map(callback).forEach(arr => { - result.push(...arr); - }); - return result; -}; diff --git a/src/utils/postProcessServiceOperations.ts b/src/utils/postProcessServiceOperations.ts index 5b88a5b21..fcbf524a8 100644 --- a/src/utils/postProcessServiceOperations.ts +++ b/src/utils/postProcessServiceOperations.ts @@ -1,6 +1,5 @@ import type { Operation } from '../client/interfaces/Operation'; import type { Service } from '../client/interfaces/Service'; -import { flatMap } from './flatMap'; export const postProcessServiceOperations = (service: Service): Operation[] => { const names = new Map(); @@ -10,8 +9,8 @@ export const postProcessServiceOperations = (service: Service): Operation[] => { // Parse the service parameters and results, very similar to how we parse // properties of models. These methods will extend the type if needed. - clone.imports.push(...flatMap(clone.parameters, parameter => parameter.imports)); - clone.imports.push(...flatMap(clone.results, result => result.imports)); + clone.imports.push(...clone.parameters.flatMap(parameter => parameter.imports)); + clone.imports.push(...clone.results.flatMap(result => result.imports)); // Check if the operation name is unique, if not then prefix this with a number const name = clone.name;