ng2-pipes
Version:
Useful angular2 pipes
17 lines (14 loc) • 474 B
text/typescript
import {PipeTransform, Pipe, Injectable} from '@angular/core';
()
({name: 'union'})
export class UnionPipe implements PipeTransform {
transform(arr:any[], args:any[] = []):any[] {
return args.reduce((newArr, currArr) =>
newArr.concat(currArr.reduce((noDupArr, curr) =>
((!~noDupArr.indexOf(curr) && !~newArr.indexOf(curr))
? noDupArr.push(curr)
: noDupArr, noDupArr)
, [])
), arr);
}
}