Skip to content

Commit

Permalink
Add Impure Versions to filterby, groupby and orderby
Browse files Browse the repository at this point in the history
  • Loading branch information
drevah committed Aug 2, 2017
1 parent 005dd91 commit 6663d80
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 3 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,11 @@
- [some](#some)
- [sample](#sample)
- [groupBy](#groupby)
- [groupByImpure](#groupbyimpure)
- [filterBy](#filterby)
- [filterByImpure](#filterbyimpure)
- [orderBy](#orderby)
- [orderByImpure](#orderbyimpure)
- [Object](#object)
- [keys](#keys)
- [values](#values)
Expand Down Expand Up @@ -614,6 +617,12 @@ this.arrayNestedObject = [
<!-- Output:{foo: [{id: 1, prop: {deep: foo}}, {id: 3, prop: {deep: foo}}], bar: [{id: 2, prop: {deep: bar}}, {id: 4, prop: {deep: bar}}]}" -->
```

## groupByImpure

Identical to groupBy pipe, the only difference is that it's an impure pipe.

Pure pipes: https://angular.io/guide/pipes#pure-pipes

### filterBy

Returns object array of grouped by items by discriminator
Expand Down Expand Up @@ -643,6 +652,12 @@ this.users = [
<!-- Output: "[{id: 1, first_name: 'John', last_name: 'Doe', work: { company: 'Foo Tech', previous_company: '' }}]" -->
```

## filterByImpure

Identical to filterBy pipe, the only difference is that it's an impure pipe.

Pure pipes: https://angular.io/guide/pipes#pure-pipes

### orderBy

Returns ordered array by configuration
Expand Down Expand Up @@ -689,6 +704,12 @@ const deepObj = [
<!-- Output: [{id: 1, ...}, {id: 3, ...}, {id: 2, ...}, {id: 4, ...}] -->
```

## orderByImpure

Identical to orderBy pipe, the only difference is that it's an impure pipe.

Pure pipes: https://angular.io/guide/pipes#pure-pipes

## Object

### keys
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngx-pipes",
"version": "1.6.2",
"version": "1.6.3",
"author": "Dan Revah",
"description": "Useful angular2 pipes",
"license": "MIT",
Expand Down
5 changes: 5 additions & 0 deletions src/app/pipes/array/filter-by-impure.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {Pipe} from '@angular/core';
import {FilterByPipe} from './filter-by';

@Pipe({name: 'filterByImpure', pure: false})
export class FilterByImpurePipe extends FilterByPipe {}
2 changes: 1 addition & 1 deletion src/app/pipes/array/filter-by.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {PipeTransform, Pipe} from '@angular/core';
import {isString, extractDeepPropertyByMapKey, isNumberFinite, isBoolean, isUndefined} from '../helpers/helpers';

@Pipe({name: 'filterBy', pure: false})
@Pipe({name: 'filterBy'})
export class FilterByPipe implements PipeTransform {

transform(input: any, props: Array<string>, search: any = '', strict: boolean = false): any[] {
Expand Down
5 changes: 5 additions & 0 deletions src/app/pipes/array/group-by-impure.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {Pipe} from '@angular/core';
import {GroupByPipe} from './group-by';

@Pipe({name: 'groupByImpure', pure: false})
export class GroupByImpurePipe extends GroupByPipe {}
5 changes: 5 additions & 0 deletions src/app/pipes/array/order-by-impure.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {Pipe} from '@angular/core';
import {OrderByPipe} from './order-by';

@Pipe({name: 'orderByImpure'})
export class OrderByImpurePipe extends OrderByPipe {}
2 changes: 1 addition & 1 deletion src/app/pipes/array/order-by.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {PipeTransform, Pipe} from '@angular/core';
import {isString, extractDeepPropertyByMapKey, isUndefined} from '../helpers/helpers';

@Pipe({name: 'orderBy', pure: false})
@Pipe({name: 'orderBy'})
export class OrderByPipe implements PipeTransform {

transform(input: any, config?: any): any[] {
Expand Down

0 comments on commit 6663d80

Please sign in to comment.