Comparing version 0.4.9 to 0.4.10
import { PipeTransform } from '@angular/core'; | ||
export declare class IntersectionPipe implements PipeTransform { | ||
transform(arr: any[], args?: any[]): any[]; | ||
transform(arr: any[], ...args: any[]): any[]; | ||
} |
@@ -15,4 +15,7 @@ "use strict"; | ||
} | ||
IntersectionPipe.prototype.transform = function (arr, args) { | ||
if (args === void 0) { args = []; } | ||
IntersectionPipe.prototype.transform = function (arr) { | ||
var args = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
args[_i - 1] = arguments[_i]; | ||
} | ||
return args.reduce(function (newArr, currArr) { | ||
@@ -19,0 +22,0 @@ return newArr.filter(function (elm) { return !!~currArr.indexOf(elm); }); |
{ | ||
"name": "ng2-pipes", | ||
"version": "0.4.9", | ||
"version": "0.4.10", | ||
"author": "Dan Revah", | ||
@@ -5,0 +5,0 @@ "description": "Useful angular2 pipes", |
@@ -1,2 +0,2 @@ | ||
import {IntersectionPipe} from "./intersection"; | ||
import {IntersectionPipe} from './intersection'; | ||
@@ -15,10 +15,10 @@ describe('IntersectionPipe', () => { | ||
it('should return empty array if there are no elements in the intersection', () => { | ||
expect(pipe.transform([1, 2, 3], [[4, 5, 6]])).toEqual([]); | ||
expect(pipe.transform([1, 2, 3], [[4, 5, 6], [7, 8, 9]])).toEqual([]); | ||
expect(pipe.transform([1, 2, 3], [4, 5, 6])).toEqual([]); | ||
expect(pipe.transform([1, 2, 3], [4, 5, 6], [7, 8, 9])).toEqual([]); | ||
}); | ||
it('should return intersection of arrays', () => { | ||
expect(pipe.transform([1, 2, 3], [[1, 2 ,3, 4, 5, 6]])).toEqual([1,2,3]); | ||
expect(pipe.transform([1, 2, 3], [[1, 2, 4, 5, 6], [1, 2, 7, 8, 9]])).toEqual([1, 2]); | ||
expect(pipe.transform([1, 2, 3], [1, 2 ,3, 4, 5, 6])).toEqual([1,2,3]); | ||
expect(pipe.transform([1, 2, 3], [1, 2, 4, 5, 6], [1, 2, 7, 8, 9])).toEqual([1, 2]); | ||
}); | ||
}); |
@@ -7,7 +7,7 @@ import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
transform(arr:any[], args:any[] = []):any[] { | ||
transform(arr: any[], ...args: any[]): any[] { | ||
return args.reduce((newArr, currArr) => | ||
newArr.filter(elm => !!~currArr.indexOf(elm)) | ||
, arr); | ||
, arr); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
238388
3895