Comparing version 0.5.1 to 0.5.2
{ | ||
"name": "ng2-pipes", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"author": "Dan Revah", | ||
@@ -5,0 +5,0 @@ "description": "Useful angular2 pipes", |
@@ -46,2 +46,5 @@ # Angular2 Pipes | ||
- [sample](#sample) | ||
- [groupBy](#groupBy) | ||
- [keys](#keys) | ||
- [values](#values) | ||
- [Math](#Math) | ||
@@ -523,2 +526,44 @@ - [min](#min) | ||
### groupBy | ||
Returns object of grouped by items by discriminator | ||
API: `array | groupBy: [string | Function]` | ||
```javascript | ||
import {GroupByPipe} from 'ng2-pipes/src/app/pipes/array/group-by'; | ||
@Component({ | ||
// ... | ||
providers: [GroupByPipe] | ||
}) | ||
export class AppComponent { | ||
constructor(private groupByPipe: GroupByPipe) { | ||
// .. | ||
const arrayObject = [{elm: 'foo', value: 0}, {elm: 'bar', value: 1}, {elm: 'foo', value: 2}]; | ||
const groupedObject = groupByPipe.transform(arrayObject, 'elm')); | ||
// `groupedObject` -> Contains: {foo: [{elm: 'foo', value: 0}, {elm: 'foo', value: 2}], bar: [{elm: 'bar', value: 1}]} | ||
} | ||
``` | ||
### keys | ||
Returns array of object keys | ||
API: `object | keys` | ||
```html | ||
<p>{{ {foo: 1, bar: 2} | keys }}</p> <!-- Output: "['foo', 'bar']" --> | ||
``` | ||
### values | ||
Returns array of object values | ||
API: `object | values` | ||
```html | ||
<p>{{ {foo: 1, bar: 2} | values }}</p> <!-- Output: "[1, 2]" --> | ||
``` | ||
## Math | ||
@@ -525,0 +570,0 @@ |
@@ -18,1 +18,4 @@ export declare class NgArrayPipesModule { | ||
export * from './sample'; | ||
export * from './keys'; | ||
export * from './values'; | ||
export * from './group-by'; |
@@ -29,2 +29,5 @@ "use strict"; | ||
var sample_1 = require('./sample'); | ||
var group_by_1 = require('./group-by'); | ||
var keys_1 = require('./keys'); | ||
var values_1 = require('./values'); | ||
var core_1 = require('@angular/core'); | ||
@@ -34,3 +37,3 @@ var ARRAY_PIPES = [ | ||
truthify_1.TrurthifyPipe, union_1.UnionPipe, unique_1.UniquePipe, without_1.WithoutPipe, pluck_1.PluckPipe, shuffle_1.ShufflePipe, | ||
every_1.EveryPipe, some_1.SomePipe, sample_1.SamplePipe | ||
every_1.EveryPipe, some_1.SomePipe, sample_1.SamplePipe, group_by_1.GroupByPipe, keys_1.KeysPipe, values_1.ValuesPipe | ||
]; | ||
@@ -66,3 +69,6 @@ var NgArrayPipesModule = (function () { | ||
__export(require('./sample')); | ||
__export(require('./keys')); | ||
__export(require('./values')); | ||
__export(require('./group-by')); | ||
//# sourceMappingURL=index.js.map |
@@ -1,17 +0,20 @@ | ||
import {DiffPipe} from './diff'; | ||
import {InitialPipe} from './initial'; | ||
import {FlattenPipe} from './flatten'; | ||
import {IntersectionPipe} from './intersection'; | ||
import {ReversePipe} from './reverse'; | ||
import {TailPipe} from './tail'; | ||
import {TrurthifyPipe} from './truthify'; | ||
import {UnionPipe} from './union'; | ||
import {UniquePipe} from './unique'; | ||
import {WithoutPipe} from './without'; | ||
import {PluckPipe} from './pluck'; | ||
import {ShufflePipe} from './shuffle'; | ||
import {EveryPipe} from './every'; | ||
import {SomePipe} from './some'; | ||
import {SamplePipe} from './sample'; | ||
import {NgModule} from '@angular/core'; | ||
import { DiffPipe } from './diff'; | ||
import { InitialPipe } from './initial'; | ||
import { FlattenPipe } from './flatten'; | ||
import { IntersectionPipe } from './intersection'; | ||
import { ReversePipe } from './reverse'; | ||
import { TailPipe } from './tail'; | ||
import { TrurthifyPipe } from './truthify'; | ||
import { UnionPipe } from './union'; | ||
import { UniquePipe } from './unique'; | ||
import { WithoutPipe } from './without'; | ||
import { PluckPipe } from './pluck'; | ||
import { ShufflePipe } from './shuffle'; | ||
import { EveryPipe } from './every'; | ||
import { SomePipe } from './some'; | ||
import { SamplePipe } from './sample'; | ||
import { GroupByPipe } from './group-by'; | ||
import { KeysPipe } from './keys'; | ||
import { ValuesPipe } from './values'; | ||
import { NgModule } from '@angular/core'; | ||
@@ -21,11 +24,11 @@ const ARRAY_PIPES = [ | ||
TrurthifyPipe, UnionPipe, UniquePipe, WithoutPipe, PluckPipe, ShufflePipe, | ||
EveryPipe, SomePipe, SamplePipe | ||
EveryPipe, SomePipe, SamplePipe, GroupByPipe, KeysPipe, ValuesPipe | ||
]; | ||
@NgModule({ | ||
declarations: [...ARRAY_PIPES], | ||
declarations: [ ...ARRAY_PIPES ], | ||
imports: [], | ||
exports: [...ARRAY_PIPES] | ||
exports: [ ...ARRAY_PIPES ] | ||
}) | ||
export class NgArrayPipesModule {} | ||
export class NgArrayPipesModule { } | ||
@@ -47,1 +50,4 @@ export * from './diff'; | ||
export * from './sample'; | ||
export * from './keys'; | ||
export * from './values'; | ||
export * from './group-by'; |
export default class GeneralHelper { | ||
static isUndefined(value: any): boolean; | ||
static isFunction(value: any): boolean; | ||
static isNumber(value: any): boolean; | ||
static isString(value: any): boolean; | ||
static isObject(value: any): boolean; | ||
static isNumberFinite(value: any): boolean; | ||
static extractDeepPropertyByMapKey(obj: Object, map: string): any; | ||
} |
@@ -8,2 +8,5 @@ "use strict"; | ||
}; | ||
GeneralHelper.isFunction = function (value) { | ||
return typeof value === 'function'; | ||
}; | ||
GeneralHelper.isNumber = function (value) { | ||
@@ -15,2 +18,5 @@ return typeof value === 'number'; | ||
}; | ||
GeneralHelper.isObject = function (value) { | ||
return value !== null && typeof value === 'object'; | ||
}; | ||
GeneralHelper.isNumberFinite = function (value) { | ||
@@ -17,0 +23,0 @@ return GeneralHelper.isNumber(value) && isFinite(value); |
export default class GeneralHelper { | ||
static isUndefined(value) { | ||
static isUndefined(value: any) { | ||
return typeof value === 'undefined'; | ||
} | ||
static isFunction(value: any) { | ||
return typeof value === 'function'; | ||
} | ||
static isNumber(value: any) { | ||
@@ -15,2 +19,6 @@ return typeof value === 'number'; | ||
static isObject(value: any) { | ||
return value !== null && typeof value === 'object'; | ||
} | ||
static isNumberFinite(value: any) { | ||
@@ -17,0 +25,0 @@ return GeneralHelper.isNumber(value) && isFinite(value); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
328620
354
4770
899