Comparing version 0.5.8 to 1.2.3
{ | ||
"name": "ng-pipe", | ||
"version": "0.5.8", | ||
"version": "1.2.3", | ||
"author": "Dan Revah", | ||
@@ -30,3 +30,3 @@ "description": "Useful angular2 pipes", | ||
"type": "git", | ||
"url": "https://github.com/danrevah/ng-pipes.git" | ||
"url": "https://github.com/danrevah/ngx-pipes.git" | ||
}, | ||
@@ -33,0 +33,0 @@ "devDependencies": { |
203
README.md
@@ -1,4 +0,5 @@ | ||
# Angular Pipes [](https://www.npmjs.com/package/ng2-pipes) [](https://travis-ci.org/danrevah/ng-pipes) [](https://coveralls.io/github/danrevah/ng2-pipes?branch=master) | ||
# ngx-pipes | ||
[](https://www.npmjs.com/package/ngx-pipes) [](https://travis-ci.org/danrevah/ngx-pipes) [](https://coveralls.io/github/danrevah/ngx-pipes?branch=master) [](https://www.npmjs.com/package/ng2-pipes) [](https://github.com/danrevah/ng-pipes/blob/master/LICENSE.md) | ||
> Useful pipes for Angular 2 | ||
> Useful pipes for Angular 2 and beyond with no external dependencies! | ||
@@ -27,2 +28,4 @@ ## Table of contents | ||
- [match](#match) | ||
- [lpad](#lpad) | ||
- [rpad](#rpad) | ||
- [Array](#Array) | ||
@@ -44,3 +47,4 @@ - [diff](#diff) | ||
- [sample](#sample) | ||
- [groupBy](#groupBy) | ||
- [groupBy](#groupby) | ||
- [filterBy](#filterby) | ||
- [Object](#object) | ||
@@ -57,2 +61,3 @@ - [keys](#keys) | ||
- [max](#max) | ||
- [sum](#sum) | ||
- [percentage](#percentage) | ||
@@ -91,3 +96,3 @@ - [ceil](#ceil) | ||
```terminal | ||
$ npm install ng2-pipes --save | ||
$ npm install ngx-pipes --save | ||
``` | ||
@@ -98,3 +103,3 @@ | ||
```typescript | ||
import {NgPipesModule} from 'ng2-pipes'; | ||
import {NgPipesModule} from 'ngx-pipes'; | ||
@@ -113,3 +118,3 @@ @NgModule({ | ||
```typescript | ||
import {ReversePipe} from 'ng2-pipes/src/app/pipes/array/reverse'; | ||
import {ReversePipe} from 'ngx-pipes/src/app/pipes/array/reverse'; | ||
@@ -137,3 +142,3 @@ @Component({ | ||
API: `string | repeat: times: [separator|optional]` | ||
**Usage:** `string | repeat: times: [separator|optional]` | ||
@@ -148,3 +153,3 @@ ```html | ||
API: `string | scan: [ARRAY]` | ||
**Usage:** `string | scan: [ARRAY]` | ||
@@ -159,5 +164,4 @@ ```html | ||
**Usage:** `string | shorten: length: [suffix|optional]: [wordBreak boolean|optional]` | ||
API: `string | shorten: length: [suffix|optional]: [wordBreak boolean|optional]` | ||
```html | ||
@@ -171,3 +175,3 @@ <p>{{'Hey foo bar' | shorten: 3: '...'}}</p> <!-- Output: "Hey..." --> | ||
API: `string | stripTags: [ARRAY]` | ||
**Usage:** `string | stripTags: [ARRAY]` | ||
@@ -199,3 +203,3 @@ ```html | ||
API: `string | trim: [characters|optional]` | ||
**Usage:** `string | trim: [characters|optional]` | ||
@@ -211,3 +215,3 @@ ```html | ||
API: `string | ltrim: [characters|optional]` | ||
**Usage:** `string | ltrim: [characters|optional]` | ||
@@ -223,3 +227,3 @@ ```html | ||
API: `string | rtrim: [characters|optional]` | ||
**Usage:** `string | rtrim: [characters|optional]` | ||
@@ -235,3 +239,3 @@ ```html | ||
API: `string | reverse` | ||
**Usage:** `string | reverse` | ||
@@ -246,3 +250,3 @@ ```html | ||
API: `string | slugify` | ||
**Usage:** `string | slugify` | ||
@@ -258,3 +262,3 @@ ```html | ||
API: `string | camelize` | ||
**Usage:** `string | camelize` | ||
@@ -271,3 +275,3 @@ ```html | ||
API: `string | latinise` | ||
**Usage:** `string | latinise` | ||
@@ -281,5 +285,5 @@ ```html | ||
Removes accents from Latin characters. | ||
Converts a string with new lines into an array of each line. | ||
API: `string | lines` | ||
**Usage:** `string | lines` | ||
@@ -294,3 +298,3 @@ ```html | ||
API: `string | underscore` | ||
**Usage:** `string | underscore` | ||
@@ -306,3 +310,3 @@ ```html | ||
API: `string | test: {RegExp}: {Flags}` | ||
**Usage:** `string | test: {RegExp}: {Flags}` | ||
@@ -319,3 +323,3 @@ ```html | ||
API: `string | match: {RegExp}: {Flags}` | ||
**Usage:** `string | match: {RegExp}: {Flags}` | ||
@@ -328,2 +332,26 @@ ```html | ||
### lpad | ||
Left pad a string to a given length using a given pad character (default is a space) | ||
**Usage:** `string | lpad: length: [padCharacter:string|optional]` | ||
```html | ||
<p>{{'foo' | lpad: 5}}</p> <!-- Output: " foo" --> | ||
<!-- Cast a number to string in order to left pad it with zeros --> | ||
<p>{{String(3) | lpad: 5: '0'}}</p> <!-- Output: "00003" --> | ||
``` | ||
### rpad | ||
Right pad a string to a given length using a given pad character (default is a space) | ||
**Usage:** `string | rpad: length: [padCharacter:string|optional]` | ||
```html | ||
<p>{{'Foo' | rpad: 5: '#'}}</p> <!-- Output: "Foo##" --> | ||
``` | ||
## Array | ||
@@ -335,3 +363,3 @@ | ||
API: `array | diff: [ARRAY]: [ARRAY]: ... : [ARRAY]` | ||
**Usage:** `array | diff: [ARRAY]: [ARRAY]: ... : [ARRAY]` | ||
@@ -350,3 +378,3 @@ ```typescript | ||
API: `array | flatten: [shallow|optional]` | ||
**Usage:** `array | flatten: [shallow|optional]` | ||
@@ -366,3 +394,3 @@ ```typescript | ||
API: `array | initial: n` | ||
**Usage:** `array | initial: n` | ||
@@ -381,3 +409,3 @@ ```typescript | ||
API: `array | tail: n` | ||
**Usage:** `array | tail: n` | ||
@@ -396,3 +424,3 @@ ```typescript | ||
API: `array | intersection: [ARRAY]: [ARRAY]: ... : [ARRAY]` | ||
**Usage:** `array | intersection: [ARRAY]: [ARRAY]: ... : [ARRAY]` | ||
@@ -411,3 +439,3 @@ ```typescript | ||
API: `array | reverse` | ||
**Usage:** `array | reverse` | ||
@@ -426,3 +454,3 @@ ```typescript | ||
API: `array | truthify` | ||
**Usage:** `array | truthify` | ||
@@ -441,3 +469,3 @@ ```typescript | ||
API: `array | union: [ARRAY]` | ||
**Usage:** `array | union: [ARRAY]` | ||
@@ -456,3 +484,3 @@ ```typescript | ||
API: `array | unique` | ||
**Usage:** `array | unique` | ||
@@ -471,3 +499,3 @@ ```typescript | ||
API: `array | without: [ARRAY]` | ||
**Usage:** `array | without: [ARRAY]` | ||
@@ -486,3 +514,3 @@ ```typescript | ||
API: `array | pluck: propertyName` | ||
**Usage:** `array | pluck: propertyName` | ||
@@ -521,3 +549,3 @@ ```typescript | ||
API: `array | shuffle` | ||
**Usage:** `array | shuffle` | ||
@@ -536,3 +564,3 @@ ```typescript | ||
API: `array | every: predicate` | ||
**Usage:** `array | every: predicate` | ||
@@ -558,3 +586,3 @@ ```typescript | ||
API: `array | some: predicate` | ||
**Usage:** `array | some: predicate` | ||
@@ -580,3 +608,3 @@ ```typescript | ||
API: `array | sample: [amount | default = 1]` | ||
**Usage:** `array | sample: [amount | default = 1]` | ||
@@ -592,3 +620,3 @@ ```html | ||
API: `array | groupBy: [string | Function]` | ||
**Usage:** `array | groupBy: [string | Function]` | ||
@@ -603,2 +631,31 @@ ```typescript | ||
### filterBy | ||
Returns object of grouped by items by discriminator | ||
**Usage:** `array | filterBy: [prop, nested.prop, ...]: search: [strict | optional]` | ||
```typescript | ||
this.users = [ | ||
{id: 1, first_name: 'John', last_name: 'Doe', work: { company: 'Foo Tech' }}, | ||
{id: 2, first_name: 'Jane', last_name: 'West', work: { company: 'AAA Solutions' }}, | ||
{id: 3, first_name: 'Bruce', last_name: 'John', work: { company: 'Bar Tech' }}, | ||
{id: 4, first_name: 'William', last_name: 'Cent', work: { company: 'Foo Tech' }} | ||
]; | ||
``` | ||
```html | ||
<!-- Returns users with `id` of 1 --> | ||
<p>{{ users | filterBy: ['id']: 1 }}</p> | ||
<!-- Output: "[{id: 1, first_name: 'John', last_name: 'Doe', work: { company: 'Foo Tech', previous_company: '' }}]" --> | ||
<!-- filterBy also support nested properties --> | ||
<p>{{ users | filterBy: ['work.company']: 'Bar Tech' }}</p> | ||
<!-- Output: "[{ "id": 3, "first_name": "Bruce", "last_name": "John", "work": { "company": "Bar Tech", "previous_company": "" } }]" --> | ||
<!-- Return users whose first name or last name is 'John'. --> | ||
<p>{{ users | filterBy: ['first_name', 'last_name']: 'John' }}</p> | ||
<!-- Output: "[{id: 1, first_name: 'John', last_name: 'Doe', work: { company: 'Foo Tech', previous_company: '' }}]" --> | ||
``` | ||
## Object | ||
@@ -610,3 +667,3 @@ | ||
API: `object | keys` | ||
**Usage:** `object | keys` | ||
@@ -621,3 +678,3 @@ ```html | ||
API: `object | values` | ||
**Usage:** `object | values` | ||
@@ -632,3 +689,3 @@ ```html | ||
API: `object | pairs` | ||
**Usage:** `object | pairs` | ||
@@ -644,3 +701,3 @@ ```html | ||
API: `object | pick: [key | string]]` | ||
**Usage:** `object | pick: [key | string]]` | ||
@@ -656,3 +713,3 @@ ```html | ||
API: `object | omit: [key | string]]` | ||
**Usage:** `object | omit: [key | string]]` | ||
@@ -668,3 +725,3 @@ ```html | ||
API: `object | invert` | ||
**Usage:** `object | invert` | ||
@@ -679,3 +736,3 @@ ```html | ||
API: `object | invertBy: [Function | optional]` | ||
**Usage:** `object | invertBy: [Function | optional]` | ||
@@ -700,3 +757,3 @@ ```typescript | ||
API: `array | min` | ||
**Usage:** `array | min` | ||
@@ -711,3 +768,3 @@ ```html | ||
API: `array | max` | ||
**Usage:** `array | max` | ||
@@ -722,3 +779,3 @@ ```html | ||
API: `array | sum` | ||
**Usage:** `array | sum` | ||
@@ -733,3 +790,3 @@ ```html | ||
API: `number | percentage: [total | default = 100]: [floor | default = false]` | ||
**Usage:** `number | percentage: [total | default = 100]: [floor | default = false]` | ||
@@ -746,3 +803,3 @@ ```html | ||
API: `number | ceil: [precision | default = 0]` | ||
**Usage:** `number | ceil: [precision | default = 0]` | ||
@@ -758,3 +815,3 @@ ```html | ||
API: `number | floor: [precision | default = 0]` | ||
**Usage:** `number | floor: [precision | default = 0]` | ||
@@ -770,3 +827,3 @@ ```html | ||
API: `number | round: [precision | default = 0]` | ||
**Usage:** `number | round: [precision | default = 0]` | ||
@@ -783,3 +840,3 @@ ```html | ||
API: `number | sqrt` | ||
**Usage:** `number | sqrt` | ||
@@ -794,3 +851,3 @@ ```html | ||
API: `number | pow: [power | default = 2]` | ||
**Usage:** `number | pow: [power | default = 2]` | ||
@@ -806,3 +863,3 @@ ```html | ||
API: `number | degrees` | ||
**Usage:** `number | degrees` | ||
@@ -817,3 +874,3 @@ ```html | ||
API: `number | radians` | ||
**Usage:** `number | radians` | ||
@@ -828,3 +885,3 @@ ```html | ||
API: `number | bytes` | ||
**Usage:** `number | bytes` | ||
@@ -842,3 +899,3 @@ ```html | ||
API: `any | isNull` | ||
**Usage:** `any | isNull` | ||
@@ -852,3 +909,3 @@ ```html | ||
API: `any | isDefined` | ||
**Usage:** `any | isDefined` | ||
@@ -862,3 +919,3 @@ ```html | ||
API: `any | isUndefined` | ||
**Usage:** `any | isUndefined` | ||
@@ -873,3 +930,3 @@ ```html | ||
API: `any | isString` | ||
**Usage:** `any | isString` | ||
@@ -883,3 +940,3 @@ ```html | ||
API: `any | isNumber` | ||
**Usage:** `any | isNumber` | ||
@@ -898,3 +955,3 @@ ```typescript | ||
API: `any | isArray` | ||
**Usage:** `any | isArray` | ||
@@ -913,3 +970,3 @@ ```typescript | ||
API: `any | isObject` | ||
**Usage:** `any | isObject` | ||
@@ -928,3 +985,3 @@ ```typescript | ||
API: `number | isGreaterThan: otherNumber` | ||
**Usage:** `number | isGreaterThan: otherNumber` | ||
@@ -939,3 +996,3 @@ ```html | ||
API: `number | isGreaterEqualThan: otherNumber` | ||
**Usage:** `number | isGreaterEqualThan: otherNumber` | ||
@@ -950,3 +1007,3 @@ ```html | ||
API: `number | isLessThan: otherNumber` | ||
**Usage:** `number | isLessThan: otherNumber` | ||
@@ -961,3 +1018,3 @@ ```html | ||
API: `number | isLessEqualThan: otherNumber` | ||
**Usage:** `number | isLessEqualThan: otherNumber` | ||
@@ -972,3 +1029,3 @@ ```html | ||
API: `number | isEqualTo: otherNumber` | ||
**Usage:** `number | isEqualTo: otherNumber` | ||
@@ -984,3 +1041,3 @@ ```html | ||
API: `number | isNotEqualTo: otherNumber` | ||
**Usage:** `number | isNotEqualTo: otherNumber` | ||
@@ -996,3 +1053,3 @@ ```html | ||
API: `number | isIdenticalTo: otherNumber` | ||
**Usage:** `number | isIdenticalTo: otherNumber` | ||
@@ -1008,3 +1065,3 @@ ```html | ||
API: `number | isNotIdenticalTo: otherNumber` | ||
**Usage:** `number | isNotIdenticalTo: otherNumber` | ||
@@ -1011,0 +1068,0 @@ ```html |
@@ -19,1 +19,2 @@ export declare class NgArrayPipesModule { | ||
export * from './group-by'; | ||
export * from './filter-by'; |
@@ -30,2 +30,3 @@ "use strict"; | ||
var group_by_1 = require('./group-by'); | ||
var filter_by_1 = require('./filter-by'); | ||
var core_1 = require('@angular/core'); | ||
@@ -35,3 +36,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, group_by_1.GroupByPipe | ||
every_1.EveryPipe, some_1.SomePipe, sample_1.SamplePipe, group_by_1.GroupByPipe, filter_by_1.FilterByPipe | ||
]; | ||
@@ -68,3 +69,4 @@ var NgArrayPipesModule = (function () { | ||
__export(require('./group-by')); | ||
__export(require('./filter-by')); | ||
//# sourceMappingURL=index.js.map |
@@ -1,18 +0,19 @@ | ||
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 { 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 {FilterByPipe} from './filter-by'; | ||
import {NgModule} from '@angular/core'; | ||
@@ -22,3 +23,3 @@ const ARRAY_PIPES = [ | ||
TrurthifyPipe, UnionPipe, UniquePipe, WithoutPipe, PluckPipe, ShufflePipe, | ||
EveryPipe, SomePipe, SamplePipe, GroupByPipe | ||
EveryPipe, SomePipe, SamplePipe, GroupByPipe, FilterByPipe | ||
]; | ||
@@ -31,3 +32,4 @@ | ||
}) | ||
export class NgArrayPipesModule {} | ||
export class NgArrayPipesModule { | ||
} | ||
@@ -50,1 +52,2 @@ export * from './diff'; | ||
export * from './group-by'; | ||
export * from './filter-by'; |
@@ -21,1 +21,3 @@ import { LinesPipe } from './lines'; | ||
export * from './test'; | ||
export * from './lpad'; | ||
export * from './rpad'; |
@@ -31,2 +31,4 @@ "use strict"; | ||
var test_1 = require('./test'); | ||
var lpad_1 = require('./lpad'); | ||
var rpad_1 = require('./rpad'); | ||
exports.STRING_PIPES = [ | ||
@@ -36,3 +38,3 @@ ltrim_1.LeftTrimPipe, repeat_1.RepeatPipe, rtrim_1.RightTrimPipe, scan_1.ScanPipe, shorten_1.ShortenPipe, | ||
camelize_1.CamelizePipe, latinise_1.LatinisePipe, lines_1.LinesPipe, underscore_1.UnderscorePipe, match_1.MatchPipe, | ||
test_1.TestPipe | ||
test_1.TestPipe, lpad_1.LeftPadPipe, rpad_1.RightPadPipe | ||
]; | ||
@@ -69,3 +71,5 @@ var NgStringPipesModule = (function () { | ||
__export(require('./test')); | ||
__export(require('./lpad')); | ||
__export(require('./rpad')); | ||
//# sourceMappingURL=index.js.map |
@@ -18,2 +18,4 @@ import {NgModule} from '@angular/core'; | ||
import {TestPipe} from './test'; | ||
import {LeftPadPipe} from './lpad'; | ||
import {RightPadPipe} from './rpad'; | ||
@@ -24,3 +26,3 @@ export const STRING_PIPES = [ | ||
CamelizePipe, LatinisePipe, LinesPipe, UnderscorePipe, MatchPipe, | ||
TestPipe | ||
TestPipe, LeftPadPipe, RightPadPipe | ||
]; | ||
@@ -51,1 +53,3 @@ | ||
export * from './test'; | ||
export * from './lpad'; | ||
export * from './rpad'; |
@@ -18,3 +18,5 @@ "use strict"; | ||
return helpers_1.default.isString(str) | ||
? str.toLowerCase().replace(/\s+/g, '-') | ||
? str.toLowerCase().trim() | ||
.replace(/[^\w\-]+/g, ' ') | ||
.replace(/\s+/g, '-') | ||
: str; | ||
@@ -21,0 +23,0 @@ }; |
@@ -19,2 +19,7 @@ import {SlugifyPipe} from './slugify'; | ||
}); | ||
it('Should slugify special strings', () => { | ||
expect(pipe.transform('http://example.com/foo')).toEqual('http-example-com-foo'); | ||
expect(pipe.transform(' http://example.com/foo ')).toEqual('http-example-com-foo'); | ||
}); | ||
}); |
@@ -9,5 +9,7 @@ import {PipeTransform, Pipe} from '@angular/core'; | ||
return GeneralHelper.isString(str) | ||
? str.toLowerCase().replace(/\s+/g, '-') | ||
? str.toLowerCase().trim() | ||
.replace(/[^\w\-]+/g, ' ') | ||
.replace(/\s+/g, '-') | ||
: str; | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
385507
408
5666
1
1031