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), []) -}