From ec26aeca478378dd243ef2dafbf1a88bf7f4b744 Mon Sep 17 00:00:00 2001 From: Alex Miller Date: Wed, 26 Nov 2025 13:09:47 +1300 Subject: [PATCH] feat: Replace polyfill with `Array.flat` --- src/filter.ts | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/filter.ts b/src/filter.ts index f9ea1b6..b28644f 100644 --- a/src/filter.ts +++ b/src/filter.ts @@ -59,7 +59,7 @@ export class Filter { private getPatterns(item: FilterItemYaml): string[] { if (Array.isArray(item)) { - return flat(item.map(i => this.getPatterns(i))) + return item.map(i => this.getPatterns(i)).flat() } if (typeof item === 'string') { @@ -73,9 +73,3 @@ export class Filter { throw new Error(`Invalid filter YAML format: ${message}.`) } } - -// Creates a new array with all sub-array elements concatenated -// In future could be replaced by Array.prototype.flat (supported on Node.js 11+) -function flat(arr: T[][]): T[] { - return arr.reduce((acc, val) => acc.concat(val), []) -}