mirror of
https://github.com/dorny/paths-filter.git
synced 2026-03-10 16:34:28 +00:00
feat: Replace polyfill with Array.flat
This commit is contained in:
parent
24eda3954a
commit
ec26aeca47
@ -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), [])
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user