Skip to content

Commit

Permalink
tail
Browse files Browse the repository at this point in the history
  • Loading branch information
danrevah committed Nov 27, 2016
1 parent 206bab8 commit ed96ad9
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bin/app/pipes/array/tail.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PipeTransform } from '@angular/core';
export declare class TailPipe implements PipeTransform {
transform(arr: any[], [num]?: number[]): any[];
transform(arr: any[], num?: number): any[];
}
4 changes: 2 additions & 2 deletions bin/app/pipes/array/tail.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/app/pipes/array/tail.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ng2-pipes",
"version": "0.4.8",
"version": "0.4.9",
"author": "Dan Revah",
"description": "Useful angular2 pipes",
"license": "MIT",
Expand Down
8 changes: 4 additions & 4 deletions src/app/pipes/array/initial.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {InitialPipe} from "./initial";
import {InitialPipe} from './initial';

describe('InitialPipe', () => {
let pipe: InitialPipe;
Expand All @@ -14,15 +14,15 @@ describe('InitialPipe', () => {
});

it('should slice properly', () => {
expect(pipe.transform([1, 2, 3, 4], [1])).toEqual([1, 2, 3]);
expect(pipe.transform([1, 2, 3, 4], [3])).toEqual([1]);
expect(pipe.transform([1, 2, 3, 4], 1)).toEqual([1, 2, 3]);
expect(pipe.transform([1, 2, 3, 4], 3)).toEqual([1]);
});

it('should slice properly array of objects', () => {
let fooObj = {id: 1, name: 'foo'},
barObj = {id: 2, name: 'bar'},
cazObj = {id: 3, name: 'caz'};

expect(pipe.transform([fooObj, barObj, cazObj], [1])).toEqual([fooObj, barObj]);
expect(pipe.transform([fooObj, barObj, cazObj], 1)).toEqual([fooObj, barObj]);
});
});
8 changes: 4 additions & 4 deletions src/app/pipes/array/tail.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {TailPipe} from "./tail";
import {TailPipe} from './tail';

describe('TailPipe', () => {
let pipe: TailPipe;
Expand All @@ -14,15 +14,15 @@ describe('TailPipe', () => {
});

it('should slice properly', () => {
expect(pipe.transform([1, 2, 3, 4], [1])).toEqual([2, 3, 4]);
expect(pipe.transform([1, 2, 3, 4], [3])).toEqual([4]);
expect(pipe.transform([1, 2, 3, 4], 1)).toEqual([2, 3, 4]);
expect(pipe.transform([1, 2, 3, 4], 3)).toEqual([4]);
});

it('should slice properly array of objects', () => {
let fooObj = {id: 1, name: 'foo'},
barObj = {id: 2, name: 'bar'},
cazObj = {id: 3, name: 'caz'};

expect(pipe.transform([fooObj, barObj, cazObj], [1])).toEqual([barObj, cazObj]);
expect(pipe.transform([fooObj, barObj, cazObj], 1)).toEqual([barObj, cazObj]);
});
});
2 changes: 1 addition & 1 deletion src/app/pipes/array/tail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {PipeTransform, Pipe, Injectable} from '@angular/core';
@Pipe({name: 'tail'})
export class TailPipe implements PipeTransform {

transform(arr: any[], [num = 0]: number[] = []): any[]
transform(arr: any[], num: number = 0): any[]
{
return arr instanceof Array
? arr.slice(num)
Expand Down

0 comments on commit ed96ad9

Please sign in to comment.