feat: Replace polyfill with Array.flat

This commit is contained in:
Alex Miller 2025-11-26 13:09:47 +13:00
parent 24eda3954a
commit ec26aeca47

View File

@ -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<T>(arr: T[][]): T[] {
return arr.reduce((acc, val) => acc.concat(val), [])
}