angular2-pipes
Advanced tools
Comparing version 0.4.16 to 0.4.19
{ | ||
"name": "angular2-pipes", | ||
"version": "0.4.16", | ||
"version": "0.4.19", | ||
"author": "Dan Revah", | ||
@@ -47,2 +47,3 @@ "description": "Useful angular2 pipes", | ||
"core-js": "^2.4.1", | ||
"coveralls": "^2.11.15", | ||
"gulp-clean": "^0.3.2", | ||
@@ -49,0 +50,0 @@ "jasmine-core": "2.4.1", |
# Angular2 Pipes | ||
[![Build Status](https://travis-ci.org/danrevah/ng2-pipes.svg?branch=master)](https://travis-ci.org/danrevah/ng2-pipes) [![npm version](https://badge.fury.io/js/ng2-pipes.svg)](https://badge.fury.io/js/ng2-pipes) | ||
[![Coverage Status](https://coveralls.io/repos/github/danrevah/ng2-pipes/badge.svg?branch=master)](https://coveralls.io/github/danrevah/ng2-pipes?branch=master)[![Build Status](https://travis-ci.org/danrevah/ng2-pipes.svg?branch=master)](https://travis-ci.org/danrevah/ng2-pipes) [![npm version](https://badge.fury.io/js/ng2-pipes.svg)](https://badge.fury.io/js/ng2-pipes) | ||
@@ -10,2 +10,3 @@ > Useful pipes for Angular2. | ||
- [Installation](#installation) | ||
- [Contributing](#contributing) | ||
- [String](#String) | ||
@@ -22,2 +23,3 @@ - [repeat](#repeat) | ||
- [reverse](#reverse) | ||
- [slugify](#slugify) | ||
- [Array](#Array) | ||
@@ -215,3 +217,14 @@ - [diff](#diff) | ||
### slugify | ||
Slugify a string (lower case and add dash between words). | ||
API: `string | slugify` | ||
```html | ||
<p>{{'Foo Bar' | slugify }}</p> <!-- Output: "foo-bar" --> | ||
<p>{{'Some Text To Slugify' | slugify }}</p> <!-- Output: "some-text-to-slugify" --> | ||
``` | ||
## Array | ||
@@ -757,1 +770,33 @@ | ||
``` | ||
## Contributing | ||
* Before adding any new feature or a fix make sure to open an issue first! | ||
Make sure you have `angular-cli` & `karma` installed globally. | ||
```bash | ||
$ npm install -g angular-cli karma | ||
``` | ||
Clone the project, and install dependencies. | ||
```bash | ||
$ git clone https://github.com/danrevah/ng2-pipes.git | ||
$ npm install | ||
``` | ||
Create a new branch | ||
```bash | ||
$ git checkout -b feat/someFeature | ||
``` | ||
Add tests & make sure everything is running properly | ||
```bash | ||
$ npm test | ||
``` | ||
Commit & push, and make a pull request! | ||
import { PipeTransform } from '@angular/core'; | ||
export declare class DiffPipe implements PipeTransform { | ||
transform(arr: any[], ...args: any[]): any[]; | ||
transform(arr: any, ...args: any[]): any[]; | ||
} |
@@ -20,6 +20,7 @@ "use strict"; | ||
} | ||
return args.reduce(function (diffArr, currArr) { return diffArr.filter(function (elm) { return !~currArr.indexOf(elm); }); }, arr); | ||
return !Array.isArray(arr) ? arr : args.reduce(function (diffArr, currArr) { | ||
return diffArr.filter(function (elm) { return !~currArr.indexOf(elm); }); | ||
}, arr); | ||
}; | ||
DiffPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'diff' }), | ||
@@ -26,0 +27,0 @@ __metadata('design:paramtypes', []) |
@@ -1,10 +0,11 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'diff'}) | ||
export class DiffPipe implements PipeTransform { | ||
transform(arr: any[], ...args: any[]): any[] { | ||
return args.reduce((diffArr, currArr) => diffArr.filter(elm => !~currArr.indexOf(elm)), arr); | ||
transform(arr: any, ...args: any[]): any[] { | ||
return !Array.isArray(arr) ? arr : args.reduce((diffArr, currArr) => { | ||
return diffArr.filter(elm => !~currArr.indexOf(elm)) | ||
}, arr); | ||
} | ||
} |
@@ -19,3 +19,2 @@ "use strict"; | ||
EveryPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'every' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'every'}) | ||
@@ -5,0 +4,0 @@ export class EveryPipe implements PipeTransform { |
import { PipeTransform } from '@angular/core'; | ||
export declare class FlattenPipe implements PipeTransform { | ||
transform(array: any[], [shallow]?: any[]): any[]; | ||
transform(arr: any, shallow?: boolean): any[]; | ||
private flatten(array); | ||
} |
@@ -15,7 +15,10 @@ "use strict"; | ||
} | ||
FlattenPipe.prototype.transform = function (array, _a) { | ||
var _b = (_a === void 0 ? [] : _a)[0], shallow = _b === void 0 ? false : _b; | ||
FlattenPipe.prototype.transform = function (arr, shallow) { | ||
if (shallow === void 0) { shallow = false; } | ||
if (!Array.isArray(arr)) { | ||
return arr; | ||
} | ||
return shallow | ||
? [].concat.apply([], array) | ||
: this.flatten(array); | ||
? [].concat.apply([], arr) | ||
: this.flatten(arr); | ||
}; | ||
@@ -28,3 +31,2 @@ FlattenPipe.prototype.flatten = function (array) { | ||
FlattenPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'flatten' }), | ||
@@ -31,0 +33,0 @@ __metadata('design:paramtypes', []) |
@@ -1,17 +0,20 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'flatten'}) | ||
export class FlattenPipe implements PipeTransform { | ||
transform(array:any[], [shallow = false]:any[] = []):any[] { | ||
transform(arr: any, shallow: boolean = false): any[] { | ||
if (!Array.isArray(arr)) { | ||
return arr; | ||
} | ||
return shallow | ||
? [].concat.apply([], array) | ||
: this.flatten(array); | ||
? [].concat.apply([], arr) | ||
: this.flatten(arr); | ||
} | ||
private flatten(array:any[]): any[] { | ||
private flatten(array: any[]): any[] { | ||
return array.reduce((arr: any[], elm: any) => elm instanceof Array ? | ||
arr.concat(this.flatten(elm)) : arr.concat(elm), []); | ||
arr.concat(this.flatten(elm)) : arr.concat(elm), []); | ||
} | ||
} |
import { PipeTransform } from '@angular/core'; | ||
export declare class InitialPipe implements PipeTransform { | ||
transform(arr: any[], num?: number): any[]; | ||
transform(arr: any, num?: number): any[]; | ||
} |
@@ -17,3 +17,3 @@ "use strict"; | ||
if (num === void 0) { num = 0; } | ||
return arr instanceof Array | ||
return Array.isArray(arr) | ||
? arr.slice(0, arr.length - num) | ||
@@ -23,3 +23,2 @@ : arr; | ||
InitialPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'initial' }), | ||
@@ -26,0 +25,0 @@ __metadata('design:paramtypes', []) |
@@ -1,10 +0,8 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'initial'}) | ||
export class InitialPipe implements PipeTransform { | ||
transform(arr: any[], num: number = 0): any[] | ||
{ | ||
return arr instanceof Array | ||
transform(arr: any, num: number = 0): any[] { | ||
return Array.isArray(arr) | ||
? arr.slice(0, arr.length - num) | ||
@@ -11,0 +9,0 @@ : arr; |
import { PipeTransform } from '@angular/core'; | ||
export declare class IntersectionPipe implements PipeTransform { | ||
transform(arr: any[], ...args: any[]): any[]; | ||
transform(arr: any, ...args: any[]): any[]; | ||
} |
@@ -20,3 +20,3 @@ "use strict"; | ||
} | ||
return args.reduce(function (newArr, currArr) { | ||
return !Array.isArray(arr) ? arr : args.reduce(function (newArr, currArr) { | ||
return newArr.filter(function (elm) { return !!~currArr.indexOf(elm); }); | ||
@@ -26,3 +26,2 @@ }, arr); | ||
IntersectionPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'intersection' }), | ||
@@ -29,0 +28,0 @@ __metadata('design:paramtypes', []) |
@@ -1,12 +0,11 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'intersection'}) | ||
export class IntersectionPipe implements PipeTransform { | ||
transform(arr: any[], ...args: any[]): any[] { | ||
return args.reduce((newArr, currArr) => | ||
newArr.filter(elm => !!~currArr.indexOf(elm)) | ||
, arr); | ||
transform(arr: any, ...args: any[]): any[] { | ||
return !Array.isArray(arr) ? arr : args.reduce((newArr, currArr) => { | ||
return newArr.filter(elm => !!~currArr.indexOf(elm)) | ||
}, arr); | ||
} | ||
} |
import { PipeTransform } from '@angular/core'; | ||
export declare class PluckPipe implements PipeTransform { | ||
transform(arr: any[], map: string): any[]; | ||
transform(arr: any, map: string): any[]; | ||
} |
@@ -18,7 +18,6 @@ "use strict"; | ||
return Array.isArray(arr) | ||
? arr.map(function (e) { return helpers_1.extractProperty(e, map); }) | ||
? arr.map(function (e) { return helpers_1.default.extractDeepPropertyByMapKey(e, map); }) | ||
: arr; | ||
}; | ||
PluckPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'pluck' }), | ||
@@ -25,0 +24,0 @@ __metadata('design:paramtypes', []) |
@@ -1,13 +0,12 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {extractProperty} from '../helpers'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers'; | ||
@Injectable() | ||
@Pipe({name: 'pluck'}) | ||
export class PluckPipe implements PipeTransform { | ||
transform(arr: any[], map: string): any[] { | ||
transform(arr: any, map: string): any[] { | ||
return Array.isArray(arr) | ||
? arr.map(e => extractProperty(e, map)) | ||
? arr.map(e => GeneralHelper.extractDeepPropertyByMapKey(e, map)) | ||
: arr; | ||
} | ||
} |
import { PipeTransform } from '@angular/core'; | ||
export declare class ReversePipe implements PipeTransform { | ||
transform(value: string): string; | ||
transform(value: any[]): any[]; | ||
transform(value: any): any; | ||
} |
@@ -19,3 +19,3 @@ "use strict"; | ||
} | ||
if (value instanceof Array) { | ||
if (Array.isArray(value)) { | ||
return value.reverse(); | ||
@@ -26,3 +26,2 @@ } | ||
ReversePipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'reverse' }), | ||
@@ -29,0 +28,0 @@ __metadata('design:paramtypes', []) |
@@ -1,10 +0,7 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'reverse'}) | ||
export class ReversePipe implements PipeTransform { | ||
transform(value:string):string; | ||
transform(value:any[]):any[]; | ||
transform(value: string | any[]): any | ||
transform(value: any): any | ||
{ | ||
@@ -14,3 +11,3 @@ if (typeof value === 'string') { | ||
} | ||
if (value instanceof Array) { | ||
if (Array.isArray(value)) { | ||
return value.reverse(); | ||
@@ -17,0 +14,0 @@ } |
import { PipeTransform } from '@angular/core'; | ||
export declare class SamplePipe implements PipeTransform { | ||
transform(arr: any[], len?: number): any[]; | ||
transform(arr: any, len?: number): any[]; | ||
} |
@@ -28,3 +28,2 @@ "use strict"; | ||
SamplePipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'sample' }), | ||
@@ -31,0 +30,0 @@ __metadata('design:paramtypes', []) |
@@ -1,8 +0,7 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'sample'}) | ||
export class SamplePipe implements PipeTransform { | ||
transform(arr: any[], len: number = 1): any[] { | ||
transform(arr: any, len: number = 1): any[] { | ||
if (!Array.isArray(arr)) { | ||
@@ -9,0 +8,0 @@ return arr; |
import { PipeTransform } from '@angular/core'; | ||
export declare class ShufflePipe implements PipeTransform { | ||
transform(arr: any[]): any[]; | ||
transform(arr: any): any[]; | ||
} |
@@ -30,3 +30,2 @@ "use strict"; | ||
ShufflePipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'shuffle' }), | ||
@@ -33,0 +32,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'shuffle'}) | ||
@@ -9,3 +8,3 @@ export class ShufflePipe implements PipeTransform { | ||
// https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle | ||
transform(arr: any[]): any[] { | ||
transform(arr: any): any[] { | ||
if (!Array.isArray(arr)) { | ||
@@ -12,0 +11,0 @@ return arr; |
import { PipeTransform } from '@angular/core'; | ||
export declare class SomePipe implements PipeTransform { | ||
transform(arr: any[], predicate: (value: any, index: number, array: any[]) => boolean): boolean; | ||
transform(arr: any, predicate: (value: any, index: number, array: any[]) => boolean): boolean; | ||
} |
@@ -19,3 +19,2 @@ "use strict"; | ||
SomePipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'some' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,10 +0,9 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'some'}) | ||
export class SomePipe implements PipeTransform { | ||
transform(arr: any[], predicate: (value: any, index: number, array: any[]) => boolean): boolean { | ||
transform(arr: any, predicate: (value: any, index: number, array: any[]) => boolean): boolean { | ||
return Array.isArray(arr) ? arr.some(predicate) : arr; | ||
} | ||
} |
import { PipeTransform } from '@angular/core'; | ||
export declare class TailPipe implements PipeTransform { | ||
transform(arr: any[], num?: number): any[]; | ||
transform(arr: any, num?: number): any[]; | ||
} |
@@ -17,8 +17,5 @@ "use strict"; | ||
if (num === void 0) { num = 0; } | ||
return arr instanceof Array | ||
? arr.slice(num) | ||
: arr; | ||
return Array.isArray(arr) ? arr.slice(num) : arr; | ||
}; | ||
TailPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'tail' }), | ||
@@ -25,0 +22,0 @@ __metadata('design:paramtypes', []) |
@@ -1,13 +0,9 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'tail'}) | ||
export class TailPipe implements PipeTransform { | ||
transform(arr: any[], num: number = 0): any[] | ||
{ | ||
return arr instanceof Array | ||
? arr.slice(num) | ||
: arr; | ||
transform(arr: any, num: number = 0): any[] { | ||
return Array.isArray(arr) ? arr.slice(num) : arr; | ||
} | ||
} |
import { PipeTransform } from '@angular/core'; | ||
export declare class TrurthifyPipe implements PipeTransform { | ||
transform(arr: any[]): any[]; | ||
transform(arr: any): any[]; | ||
} |
@@ -16,6 +16,7 @@ "use strict"; | ||
TrurthifyPipe.prototype.transform = function (arr) { | ||
return arr.filter(function (elm) { return !!elm; }); | ||
return Array.isArray(arr) | ||
? arr.filter(function (elm) { return !!elm; }) | ||
: arr; | ||
}; | ||
TrurthifyPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'truthify' }), | ||
@@ -22,0 +23,0 @@ __metadata('design:paramtypes', []) |
@@ -1,10 +0,11 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'truthify'}) | ||
export class TrurthifyPipe implements PipeTransform { | ||
transform(arr:any[]):any[] { | ||
return arr.filter(elm => !!elm); | ||
transform(arr: any): any[] { | ||
return Array.isArray(arr) | ||
? arr.filter(elm => !!elm) | ||
: arr; | ||
} | ||
} |
import { PipeTransform } from '@angular/core'; | ||
export declare class UnionPipe implements PipeTransform { | ||
transform(arr: any[], args?: any[]): any[]; | ||
transform(arr: any, args?: any[]): any[]; | ||
} |
@@ -17,12 +17,14 @@ "use strict"; | ||
if (args === void 0) { args = []; } | ||
return args.reduce(function (newArr, currArr) { | ||
return newArr.concat(currArr.reduce(function (noDupArr, curr) { | ||
return ((!~noDupArr.indexOf(curr) && !~newArr.indexOf(curr)) | ||
? noDupArr.push(curr) | ||
: noDupArr, noDupArr); | ||
}, [])); | ||
}, arr); | ||
return (!Array.isArray(arr) || !Array.isArray(args)) | ||
? arr | ||
: args.reduce(function (newArr, currArr) { | ||
return newArr.concat(currArr.reduce(function (noDupArr, curr) { | ||
if (!~noDupArr.indexOf(curr) && !~newArr.indexOf(curr)) { | ||
noDupArr.push(curr); | ||
} | ||
return noDupArr; | ||
}, [])); | ||
}, arr); | ||
}; | ||
UnionPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'union' }), | ||
@@ -29,0 +31,0 @@ __metadata('design:paramtypes', []) |
@@ -1,16 +0,18 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'union'}) | ||
export class UnionPipe implements PipeTransform { | ||
transform(arr:any[], args:any[] = []):any[] { | ||
return args.reduce((newArr, currArr) => | ||
newArr.concat(currArr.reduce((noDupArr, curr) => | ||
((!~noDupArr.indexOf(curr) && !~newArr.indexOf(curr)) | ||
? noDupArr.push(curr) | ||
: noDupArr, noDupArr) | ||
, []) | ||
), arr); | ||
transform(arr: any, args: any[] = []): any[] { | ||
return (!Array.isArray(arr) || !Array.isArray(args)) | ||
? arr | ||
: args.reduce((newArr, currArr) => { | ||
return newArr.concat(currArr.reduce((noDupArr, curr) => { | ||
if (!~noDupArr.indexOf(curr) && !~newArr.indexOf(curr)) { | ||
noDupArr.push(curr); | ||
} | ||
return noDupArr; | ||
}, [])); | ||
}, arr); | ||
} | ||
} |
import { PipeTransform } from '@angular/core'; | ||
export declare class UniquePipe implements PipeTransform { | ||
transform(arr: any[]): any[]; | ||
transform(arr: any): any[]; | ||
} |
@@ -16,6 +16,7 @@ "use strict"; | ||
UniquePipe.prototype.transform = function (arr) { | ||
return arr.filter(function (elm, index) { return arr.indexOf(elm) === index; }); | ||
return Array.isArray(arr) | ||
? arr.filter(function (elm, index) { return arr.indexOf(elm) === index; }) | ||
: arr; | ||
}; | ||
UniquePipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'unique' }), | ||
@@ -22,0 +23,0 @@ __metadata('design:paramtypes', []) |
@@ -1,10 +0,11 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'unique'}) | ||
export class UniquePipe implements PipeTransform { | ||
transform(arr:any[]):any[] { | ||
return arr.filter((elm, index) => arr.indexOf(elm) === index); | ||
transform(arr: any): any[] { | ||
return Array.isArray(arr) | ||
? arr.filter((elm, index) => arr.indexOf(elm) === index) | ||
: arr; | ||
} | ||
} |
import { PipeTransform } from '@angular/core'; | ||
export declare class WithoutPipe implements PipeTransform { | ||
transform(arr: any[], args?: any[]): any[]; | ||
transform(arr: any, args?: any[]): any[]; | ||
} |
@@ -17,6 +17,7 @@ "use strict"; | ||
if (args === void 0) { args = []; } | ||
return arr.filter(function (elm) { return !~args.indexOf(elm); }); | ||
return Array.isArray(arr) | ||
? arr.filter(function (elm) { return !~args.indexOf(elm); }) | ||
: arr; | ||
}; | ||
WithoutPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'without' }), | ||
@@ -23,0 +24,0 @@ __metadata('design:paramtypes', []) |
@@ -1,10 +0,11 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'without'}) | ||
export class WithoutPipe implements PipeTransform { | ||
transform(arr:any[], args:any[] = []):any[] { | ||
return arr.filter(elm => !~args.indexOf(elm)); | ||
transform(arr: any, args: any[] = []): any[] { | ||
return Array.isArray(arr) | ||
? arr.filter(elm => !~args.indexOf(elm)) | ||
: arr; | ||
} | ||
} |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsArrayPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isArray' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isArray'}) | ||
@@ -5,0 +4,0 @@ export class IsArrayPipe implements PipeTransform { |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsDefinedPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isDefined' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isDefined'}) | ||
@@ -5,0 +4,0 @@ export class IsDefinedPipe implements PipeTransform { |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsEqualToPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isEqualTo' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isEqualTo'}) | ||
@@ -5,0 +4,0 @@ export class IsEqualToPipe implements PipeTransform { |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsFunctionPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isFunction' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isFunction'}) | ||
@@ -5,0 +4,0 @@ export class IsFunctionPipe implements PipeTransform { |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsGreaterEqualThanPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isGreaterEqualThan' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isGreaterEqualThan'}) | ||
@@ -5,0 +4,0 @@ export class IsGreaterEqualThanPipe implements PipeTransform { |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsGreaterThanPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isGreaterThan' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isGreaterThan'}) | ||
@@ -5,0 +4,0 @@ export class IsGreaterThanPipe implements PipeTransform { |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsIdenticalToPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isIdenticalTo' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isIdenticalTo'}) | ||
@@ -5,0 +4,0 @@ export class IsIdenticalToPipe implements PipeTransform { |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsLessEqualThanPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isLessEqualThan' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isLessEqualThan'}) | ||
@@ -5,0 +4,0 @@ export class IsLessEqualThanPipe implements PipeTransform { |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsLessThanPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isLessThan' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isLessThan'}) | ||
@@ -5,0 +4,0 @@ export class IsLessThanPipe implements PipeTransform { |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsNotEqualToPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isNotEqualTo' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isNotEqualTo'}) | ||
@@ -5,0 +4,0 @@ export class IsNotEqualToPipe implements PipeTransform { |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsNotIdenticalToPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isNotIdenticalTo' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isNotIdenticalTo'}) | ||
@@ -5,0 +4,0 @@ export class IsNotIdenticalToPipe implements PipeTransform { |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsNullPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isNull' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isNull'}) | ||
@@ -5,0 +4,0 @@ export class IsNullPipe implements PipeTransform { |
@@ -12,2 +12,3 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var IsNumberPipe = (function () { | ||
@@ -17,6 +18,5 @@ function IsNumberPipe() { | ||
IsNumberPipe.prototype.transform = function (value) { | ||
return typeof value === 'number'; | ||
return helpers_1.default.isNumber(value); | ||
}; | ||
IsNumberPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isNumber' }), | ||
@@ -23,0 +23,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,4 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'isNumber'}) | ||
@@ -8,4 +8,4 @@ export class IsNumberPipe implements PipeTransform { | ||
transform(value: any): boolean { | ||
return typeof value === 'number'; | ||
return GeneralHelper.isNumber(value); | ||
} | ||
} |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsObjectPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isObject' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isObject'}) | ||
@@ -5,0 +4,0 @@ export class IsObjectPipe implements PipeTransform { |
@@ -19,3 +19,2 @@ "use strict"; | ||
IsStringPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isString' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'isString'}) | ||
@@ -5,0 +4,0 @@ export class IsStringPipe implements PipeTransform { |
@@ -12,2 +12,3 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var IsUndefinedPipe = (function () { | ||
@@ -17,6 +18,5 @@ function IsUndefinedPipe() { | ||
IsUndefinedPipe.prototype.transform = function (value) { | ||
return typeof value === 'undefined'; | ||
return helpers_1.default.isUndefined(value); | ||
}; | ||
IsUndefinedPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'isUndefined' }), | ||
@@ -23,0 +23,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,4 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'isUndefined'}) | ||
@@ -8,4 +8,4 @@ export class IsUndefinedPipe implements PipeTransform { | ||
transform(value: any): boolean { | ||
return typeof value === 'undefined'; | ||
return GeneralHelper.isUndefined(value); | ||
} | ||
} |
@@ -1,4 +0,7 @@ | ||
export declare function isUndefined(value: any): boolean; | ||
export declare function isNumber(value: any): boolean; | ||
export declare function isNumberFinite(value: any): boolean; | ||
export declare function extractProperty(obj: any, map: string): any; | ||
export default class GeneralHelper { | ||
static isUndefined(value: any): boolean; | ||
static isNumber(value: any): boolean; | ||
static isString(value: any): boolean; | ||
static isNumberFinite(value: any): boolean; | ||
static extractDeepPropertyByMapKey(obj: Object, map: string): any; | ||
} |
"use strict"; | ||
function isUndefined(value) { | ||
return typeof value === 'undefined'; | ||
} | ||
exports.isUndefined = isUndefined; | ||
function isNumber(value) { | ||
return typeof value === 'number'; | ||
} | ||
exports.isNumber = isNumber; | ||
function isNumberFinite(value) { | ||
return isNumber(value) && isFinite(value); | ||
} | ||
exports.isNumberFinite = isNumberFinite; | ||
function extractProperty(obj, map) { | ||
var keys = map.split('.'); | ||
var key = keys.shift(); | ||
return keys.length > 0 && !isUndefined(obj[key]) | ||
? extractProperty(obj[key], keys.join('.')) | ||
: obj[key]; | ||
} | ||
exports.extractProperty = extractProperty; | ||
var GeneralHelper = (function () { | ||
function GeneralHelper() { | ||
} | ||
GeneralHelper.isUndefined = function (value) { | ||
return typeof value === 'undefined'; | ||
}; | ||
GeneralHelper.isNumber = function (value) { | ||
return typeof value === 'number'; | ||
}; | ||
GeneralHelper.isString = function (value) { | ||
return typeof value === 'string'; | ||
}; | ||
GeneralHelper.isNumberFinite = function (value) { | ||
return GeneralHelper.isNumber(value) && isFinite(value); | ||
}; | ||
GeneralHelper.extractDeepPropertyByMapKey = function (obj, map) { | ||
var keys = map.split('.'); | ||
var key = keys.shift(); | ||
var prop = obj[key]; | ||
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) { | ||
var key_1 = keys_1[_i]; | ||
if (GeneralHelper.isUndefined(prop[key_1])) { | ||
return prop[key_1]; | ||
} | ||
prop = prop[key_1]; | ||
} | ||
return prop; | ||
}; | ||
return GeneralHelper; | ||
}()); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = GeneralHelper; | ||
//# sourceMappingURL=helpers.js.map |
export function isUndefined(value) { | ||
return typeof value === 'undefined'; | ||
} | ||
export default class GeneralHelper { | ||
static isUndefined(value) { | ||
return typeof value === 'undefined'; | ||
} | ||
export function isNumber(value: any) { | ||
return typeof value === 'number'; | ||
} | ||
static isNumber(value: any) { | ||
return typeof value === 'number'; | ||
} | ||
export function isNumberFinite(value: any) { | ||
return isNumber(value) && isFinite(value); | ||
} | ||
static isString(value: any) { | ||
return typeof value === 'string'; | ||
} | ||
export function extractProperty(obj: any, map: string) { | ||
const keys = map.split('.'); | ||
const key = keys.shift(); | ||
static isNumberFinite(value: any) { | ||
return GeneralHelper.isNumber(value) && isFinite(value); | ||
} | ||
return keys.length > 0 && !isUndefined(obj[key]) | ||
? extractProperty(obj[key], keys.join('.')) | ||
: obj[key]; | ||
static extractDeepPropertyByMapKey(obj: Object, map: string) { | ||
const keys = map.split('.'); | ||
const key = keys.shift(); | ||
let prop = obj[key]; | ||
for (let key of keys) { | ||
if (GeneralHelper.isUndefined(prop[key])) { | ||
return prop[key]; | ||
} | ||
prop = prop[key]; | ||
} | ||
return prop; | ||
} | ||
} |
@@ -1,1 +0,2 @@ | ||
export * from './helpers'; | ||
import GeneralHelper from './helpers'; | ||
export default GeneralHelper; |
"use strict"; | ||
function __export(m) { | ||
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; | ||
} | ||
__export(require('./helpers')); | ||
var helpers_1 = require('./helpers'); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = helpers_1.default; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,2 @@ | ||
export * from './helpers'; | ||
import GeneralHelper from './helpers'; | ||
export default GeneralHelper; |
@@ -12,3 +12,3 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var BytesPipe = (function () { | ||
@@ -18,3 +18,3 @@ function BytesPipe() { | ||
BytesPipe.prototype.transform = function (value) { | ||
if (!helpers_1.isNumberFinite(value)) { | ||
if (!helpers_1.default.isNumberFinite(value)) { | ||
return NaN; | ||
@@ -33,3 +33,2 @@ } | ||
BytesPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'bytes' }), | ||
@@ -36,0 +35,0 @@ __metadata('design:paramtypes', []) |
@@ -1,5 +0,4 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {isNumberFinite} from '../helpers'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'bytes'}) | ||
@@ -9,7 +8,7 @@ export class BytesPipe implements PipeTransform { | ||
transform(value: number): string | number { | ||
if (!isNumberFinite(value)) { | ||
if (!GeneralHelper.isNumberFinite(value)) { | ||
return NaN; | ||
} | ||
const dictionary: Array<any> = [ | ||
const dictionary: Array<{max: number, type: string}> = [ | ||
{ max: 1e3, type: 'B' }, | ||
@@ -16,0 +15,0 @@ { max: 1e6, type: 'KB' }, |
@@ -24,3 +24,2 @@ "use strict"; | ||
CeilPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'ceil' }), | ||
@@ -27,0 +26,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'ceil'}) | ||
@@ -5,0 +4,0 @@ export class CeilPipe implements PipeTransform { |
@@ -12,3 +12,3 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var DegreesPipe = (function () { | ||
@@ -18,3 +18,3 @@ function DegreesPipe() { | ||
DegreesPipe.prototype.transform = function (radians) { | ||
if (!helpers_1.isNumberFinite(radians)) { | ||
if (!helpers_1.default.isNumberFinite(radians)) { | ||
return NaN; | ||
@@ -25,3 +25,2 @@ } | ||
DegreesPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'degrees' }), | ||
@@ -28,0 +27,0 @@ __metadata('design:paramtypes', []) |
@@ -1,5 +0,4 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {isNumberFinite} from '../helpers'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'degrees'}) | ||
@@ -9,3 +8,3 @@ export class DegreesPipe implements PipeTransform { | ||
transform(radians: number): number { | ||
if (!isNumberFinite(radians)) { | ||
if (!GeneralHelper.isNumberFinite(radians)) { | ||
return NaN; | ||
@@ -12,0 +11,0 @@ } |
@@ -24,3 +24,2 @@ "use strict"; | ||
FloorPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'floor' }), | ||
@@ -27,0 +26,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'floor'}) | ||
@@ -5,0 +4,0 @@ export class FloorPipe implements PipeTransform { |
@@ -21,3 +21,2 @@ "use strict"; | ||
MaxPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'max' }), | ||
@@ -24,0 +23,0 @@ __metadata('design:paramtypes', []) |
@@ -1,8 +0,7 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'max'}) | ||
export class MaxPipe implements PipeTransform { | ||
transform(arr: number[]):number|number[] { | ||
transform(arr: number[]): number|number[] { | ||
return Array.isArray(arr) | ||
@@ -9,0 +8,0 @@ ? Math.max(...arr) |
@@ -21,3 +21,2 @@ "use strict"; | ||
MinPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'min' }), | ||
@@ -24,0 +23,0 @@ __metadata('design:paramtypes', []) |
@@ -1,8 +0,7 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'min'}) | ||
export class MinPipe implements PipeTransform { | ||
transform(arr: number[]):number|number[] { | ||
transform(arr: number[]): number|number[] { | ||
return Array.isArray(arr) | ||
@@ -9,0 +8,0 @@ ? Math.min(...arr) |
import { PipeTransform } from '@angular/core'; | ||
export declare class PercentagePipe implements PipeTransform { | ||
transform(num: number, total?: number, floor?: boolean): number; | ||
transform(num: any, total?: number, floor?: boolean): number; | ||
} |
@@ -25,3 +25,2 @@ "use strict"; | ||
PercentagePipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'percentage' }), | ||
@@ -28,0 +27,0 @@ __metadata('design:paramtypes', []) |
@@ -1,8 +0,7 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'percentage'}) | ||
export class PercentagePipe implements PipeTransform { | ||
transform(num: number, total: number = 100, floor: boolean = false): number { | ||
transform(num: any, total: number = 100, floor: boolean = false): number { | ||
if (isNaN(num)) { | ||
@@ -9,0 +8,0 @@ return num; |
@@ -20,3 +20,2 @@ "use strict"; | ||
PowerPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'pow' }), | ||
@@ -23,0 +22,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'pow'}) | ||
@@ -5,0 +4,0 @@ export class PowerPipe implements PipeTransform { |
@@ -12,3 +12,3 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var RadiansPipe = (function () { | ||
@@ -18,3 +18,3 @@ function RadiansPipe() { | ||
RadiansPipe.prototype.transform = function (degrees) { | ||
if (!helpers_1.isNumberFinite(degrees)) { | ||
if (!helpers_1.default.isNumberFinite(degrees)) { | ||
return NaN; | ||
@@ -25,3 +25,2 @@ } | ||
RadiansPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'radians' }), | ||
@@ -28,0 +27,0 @@ __metadata('design:paramtypes', []) |
@@ -1,5 +0,4 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {isNumberFinite} from '../helpers'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'radians'}) | ||
@@ -9,3 +8,3 @@ export class RadiansPipe implements PipeTransform { | ||
transform(degrees: number): number { | ||
if (!isNumberFinite(degrees)) { | ||
if (!GeneralHelper.isNumberFinite(degrees)) { | ||
return NaN; | ||
@@ -12,0 +11,0 @@ } |
@@ -24,3 +24,2 @@ "use strict"; | ||
RoundPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'round' }), | ||
@@ -27,0 +26,0 @@ __metadata('design:paramtypes', []) |
@@ -1,8 +0,7 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'round'}) | ||
export class RoundPipe implements PipeTransform { | ||
transform(num: number, precision: number = 0):number { | ||
transform(num: number, precision: number = 0): number { | ||
if (precision <= 0) { | ||
@@ -9,0 +8,0 @@ return Math.round(num); |
@@ -19,3 +19,2 @@ "use strict"; | ||
SqrtPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'sqrt' }), | ||
@@ -22,0 +21,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'sqrt'}) | ||
@@ -5,0 +4,0 @@ export class SqrtPipe implements PipeTransform { |
@@ -21,3 +21,2 @@ "use strict"; | ||
SumPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'sum' }), | ||
@@ -24,0 +23,0 @@ __metadata('design:paramtypes', []) |
@@ -1,8 +0,7 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'sum'}) | ||
export class SumPipe implements PipeTransform { | ||
transform(arr: number[]):number|number[] { | ||
transform(arr: number[]): number|number[] { | ||
return !Array.isArray(arr) | ||
@@ -9,0 +8,0 @@ ? arr |
@@ -14,1 +14,2 @@ import { UcWordsPipe } from './ucwords'; | ||
export * from './ucfirst'; | ||
export * from './slugify'; |
@@ -24,5 +24,6 @@ "use strict"; | ||
var ucfirst_1 = require('./ucfirst'); | ||
var slugify_1 = require('./slugify'); | ||
exports.STRING_PIPES = [ | ||
ltrim_1.LeftTrimPipe, repeat_1.RepeatPipe, rtrim_1.RightTrimPipe, scan_1.ScanPipe, shorten_1.ShortenPipe, | ||
strip_tags_1.StripTagsPipe, trim_1.TrimPipe, ucfirst_1.UcFirstPipe, ucwords_1.UcWordsPipe | ||
strip_tags_1.StripTagsPipe, trim_1.TrimPipe, ucfirst_1.UcFirstPipe, ucwords_1.UcWordsPipe, slugify_1.SlugifyPipe | ||
]; | ||
@@ -52,3 +53,4 @@ var NgStringPipesModule = (function () { | ||
__export(require('./ucfirst')); | ||
__export(require('./slugify')); | ||
//# sourceMappingURL=index.js.map |
@@ -11,6 +11,7 @@ import {NgModule} from '@angular/core'; | ||
import {UcFirstPipe} from './ucfirst'; | ||
import {SlugifyPipe} from './slugify'; | ||
export const STRING_PIPES = [ | ||
LeftTrimPipe, RepeatPipe, RightTrimPipe, ScanPipe, ShortenPipe, | ||
StripTagsPipe, TrimPipe, UcFirstPipe, UcWordsPipe | ||
StripTagsPipe, TrimPipe, UcFirstPipe, UcWordsPipe, SlugifyPipe | ||
]; | ||
@@ -34,1 +35,2 @@ | ||
export * from './ucfirst'; | ||
export * from './slugify'; |
@@ -12,2 +12,3 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var LeftTrimPipe = (function () { | ||
@@ -18,6 +19,7 @@ function LeftTrimPipe() { | ||
if (chars === void 0) { chars = '\\s'; } | ||
return text.replace(new RegExp("^[" + chars + "]+"), ''); | ||
return helpers_1.default.isString(text) | ||
? text.replace(new RegExp("^[" + chars + "]+"), '') | ||
: text; | ||
}; | ||
LeftTrimPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'ltrim' }), | ||
@@ -24,0 +26,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,4 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'ltrim'}) | ||
@@ -8,4 +8,6 @@ export class LeftTrimPipe implements PipeTransform { | ||
transform(text: string, chars: string = '\\s'): string { | ||
return text.replace(new RegExp(`^[${chars}]+`), ''); | ||
return GeneralHelper.isString(text) | ||
? text.replace(new RegExp(`^[${chars}]+`), '') | ||
: text; | ||
} | ||
} |
import { PipeTransform } from '@angular/core'; | ||
export declare class RepeatPipe implements PipeTransform { | ||
transform(str: string, [n, separator]?: any[]): string; | ||
transform(str: string, n?: number, separator?: string): string; | ||
private repeat(str, n, separator); | ||
} |
@@ -12,18 +12,20 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var RepeatPipe = (function () { | ||
function RepeatPipe() { | ||
} | ||
RepeatPipe.prototype.transform = function (str, _a) { | ||
var _b = _a === void 0 ? [] : _a, _c = _b[0], n = _c === void 0 ? 1 : _c, _d = _b[1], separator = _d === void 0 ? '' : _d; | ||
var times = ~~n; | ||
if (times <= 0) { | ||
RepeatPipe.prototype.transform = function (str, n, separator) { | ||
if (n === void 0) { n = 1; } | ||
if (separator === void 0) { separator = ''; } | ||
if (n <= 0) { | ||
throw new RangeError(); | ||
} | ||
return times == 1 ? str : this.repeat(str, times - 1, separator); | ||
return n == 1 ? str : this.repeat(str, n - 1, separator); | ||
}; | ||
RepeatPipe.prototype.repeat = function (str, n, separator) { | ||
return n == 0 ? str : (str + separator + this.repeat(str, n - 1, separator)); | ||
return helpers_1.default.isString(str) | ||
? (n == 0 ? str : (str + separator + this.repeat(str, n - 1, separator))) | ||
: str; | ||
}; | ||
RepeatPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'repeat' }), | ||
@@ -30,0 +32,0 @@ __metadata('design:paramtypes', []) |
@@ -1,18 +0,19 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'repeat'}) | ||
export class RepeatPipe implements PipeTransform { | ||
transform(str:string, [n = 1, separator = '']: any[] = []):string { | ||
let times: number = ~~n; | ||
if (times <= 0) { | ||
transform(str: string, n: number = 1, separator: string = ''): string { | ||
if (n <= 0) { | ||
throw new RangeError(); | ||
} | ||
return times == 1 ? str : this.repeat(str, times - 1, separator); | ||
return n == 1 ? str : this.repeat(str, n - 1, separator); | ||
} | ||
private repeat(str: string, n: number, separator: string): string { | ||
return n == 0 ? str : (str + separator + this.repeat(str, n - 1, separator)); | ||
return GeneralHelper.isString(str) | ||
? (n == 0 ? str : (str + separator + this.repeat(str, n - 1, separator))) | ||
: str; | ||
} | ||
} |
@@ -12,2 +12,3 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var RightTrimPipe = (function () { | ||
@@ -18,6 +19,7 @@ function RightTrimPipe() { | ||
if (chars === void 0) { chars = '\\s'; } | ||
return text.replace(new RegExp("[" + chars + "]+$"), ''); | ||
return helpers_1.default.isString(text) | ||
? text.replace(new RegExp("[" + chars + "]+$"), '') | ||
: text; | ||
}; | ||
RightTrimPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'rtrim' }), | ||
@@ -24,0 +26,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,4 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'rtrim'}) | ||
@@ -8,4 +8,6 @@ export class RightTrimPipe implements PipeTransform { | ||
transform(text: string, chars: string = '\\s'): string { | ||
return text.replace(new RegExp(`[${chars}]+$`), ''); | ||
return GeneralHelper.isString(text) | ||
? text.replace(new RegExp(`[${chars}]+$`), '') | ||
: text; | ||
} | ||
} |
@@ -12,2 +12,3 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var ScanPipe = (function () { | ||
@@ -18,8 +19,7 @@ function ScanPipe() { | ||
if (args === void 0) { args = []; } | ||
return text.replace(/\{(\d+)}/g, function (match, index) { | ||
return typeof (args[index]) !== 'undefined' ? args[index] : match; | ||
}); | ||
return helpers_1.default.isString(text) | ||
? text.replace(/\{(\d+)}/g, function (match, index) { return typeof (args[index]) !== 'undefined' ? args[index] : match; }) | ||
: text; | ||
}; | ||
ScanPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'scan' }), | ||
@@ -26,0 +26,0 @@ __metadata('design:paramtypes', []) |
@@ -1,11 +0,12 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'scan'}) | ||
export class ScanPipe implements PipeTransform { | ||
transform(text:string, args: string[] = []):string { | ||
return text.replace(/\{(\d+)}/g, (match, index) => | ||
typeof (args[index]) !== 'undefined' ? args[index] : match); | ||
transform(text: string, args: string[] = []): string { | ||
return GeneralHelper.isString(text) | ||
? text.replace(/\{(\d+)}/g, (match, index) => typeof (args[index]) !== 'undefined' ? args[index] : match) | ||
: text; | ||
} | ||
} |
import { PipeTransform } from '@angular/core'; | ||
export declare class ShortenPipe implements PipeTransform { | ||
transform(text: string, length?: number, suffix?: string, wordBreak?: boolean): string; | ||
transform(text: any, length?: number, suffix?: string, wordBreak?: boolean): string; | ||
} |
@@ -12,2 +12,3 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var ShortenPipe = (function () { | ||
@@ -20,11 +21,16 @@ function ShortenPipe() { | ||
if (wordBreak === void 0) { wordBreak = true; } | ||
return (text.length > length) | ||
? (wordBreak | ||
? (text.slice(0, length) + suffix) | ||
: (!!~text.indexOf(' ', length) | ||
? (text.slice(0, text.indexOf(' ', length)) + suffix) | ||
: text)) : text; | ||
if (!helpers_1.default.isString(text)) { | ||
return text; | ||
} | ||
if (text.length > length) { | ||
if (wordBreak) { | ||
return text.slice(0, length) + suffix; | ||
} | ||
if (!!~text.indexOf(' ', length)) { | ||
return text.slice(0, text.indexOf(' ', length)) + suffix; | ||
} | ||
} | ||
return text; | ||
}; | ||
ShortenPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'shorten' }), | ||
@@ -31,0 +37,0 @@ __metadata('design:paramtypes', []) |
@@ -1,17 +0,22 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'shorten'}) | ||
export class ShortenPipe implements PipeTransform { | ||
transform(text: string, length: number = 0, suffix: string = '', wordBreak: boolean = true): string { | ||
return (text.length > length) | ||
? (wordBreak | ||
? (text.slice(0, length) + suffix) | ||
: (!!~text.indexOf(' ', length) | ||
? (text.slice(0, text.indexOf(' ', length)) + suffix) | ||
: text | ||
) | ||
) : text; | ||
transform(text: any, length: number = 0, suffix: string = '', wordBreak: boolean = true): string { | ||
if (!GeneralHelper.isString(text)) { | ||
return text; | ||
} | ||
if (text.length > length) { | ||
if (wordBreak) { | ||
return text.slice(0, length) + suffix; | ||
} | ||
if (!!~text.indexOf(' ', length)) { | ||
return text.slice(0, text.indexOf(' ', length)) + suffix; | ||
} | ||
} | ||
return text; | ||
} | ||
} |
@@ -25,3 +25,2 @@ "use strict"; | ||
StripTagsPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'stripTags' }), | ||
@@ -28,0 +27,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,3 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
@Injectable() | ||
@Pipe({name: 'stripTags'}) | ||
@@ -5,0 +4,0 @@ export class StripTagsPipe implements PipeTransform { |
@@ -12,2 +12,3 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var TrimPipe = (function () { | ||
@@ -18,6 +19,5 @@ function TrimPipe() { | ||
if (chars === void 0) { chars = '\\s'; } | ||
return text.replace(new RegExp("^[" + chars + "]+|[" + chars + "]+$", 'g'), ''); | ||
return helpers_1.default.isString(text) ? text.replace(new RegExp("^[" + chars + "]+|[" + chars + "]+$", 'g'), '') : text; | ||
}; | ||
TrimPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'trim' }), | ||
@@ -24,0 +24,0 @@ __metadata('design:paramtypes', []) |
@@ -1,4 +0,4 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'trim'}) | ||
@@ -8,6 +8,6 @@ export class TrimPipe implements PipeTransform { | ||
transform(text: string, chars: string = '\\s'): string { | ||
return text.replace(new RegExp( | ||
return GeneralHelper.isString(text) ? text.replace(new RegExp( | ||
`^[${chars}]+|[${chars}]+$`, 'g' | ||
), ''); | ||
), '') : text; | ||
} | ||
} |
@@ -12,2 +12,3 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var UcFirstPipe = (function () { | ||
@@ -17,6 +18,7 @@ function UcFirstPipe() { | ||
UcFirstPipe.prototype.transform = function (text) { | ||
return text.slice(0, 1).toUpperCase() + text.slice(1); | ||
return helpers_1.default.isString(text) | ||
? (text.slice(0, 1).toUpperCase() + text.slice(1)) | ||
: text; | ||
}; | ||
UcFirstPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'ucfirst' }), | ||
@@ -23,0 +25,0 @@ __metadata('design:paramtypes', []) |
@@ -1,10 +0,12 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'ucfirst'}) | ||
export class UcFirstPipe implements PipeTransform { | ||
transform(text:string):string { | ||
return text.slice(0, 1).toUpperCase() + text.slice(1); | ||
transform(text: string):string { | ||
return GeneralHelper.isString(text) | ||
? (text.slice(0, 1).toUpperCase() + text.slice(1)) | ||
: text; | ||
} | ||
} |
@@ -12,2 +12,3 @@ "use strict"; | ||
var core_1 = require('@angular/core'); | ||
var helpers_1 = require('../helpers/helpers'); | ||
var UcWordsPipe = (function () { | ||
@@ -17,8 +18,9 @@ function UcWordsPipe() { | ||
UcWordsPipe.prototype.transform = function (text) { | ||
return text.split(' ') | ||
.map(function (sub) { return sub.slice(0, 1).toUpperCase() + sub.slice(1); }) | ||
.join(' '); | ||
return helpers_1.default.isString(text) | ||
? text.split(' ') | ||
.map(function (sub) { return sub.slice(0, 1).toUpperCase() + sub.slice(1); }) | ||
.join(' ') | ||
: text; | ||
}; | ||
UcWordsPipe = __decorate([ | ||
core_1.Injectable(), | ||
core_1.Pipe({ name: 'ucwords' }), | ||
@@ -25,0 +27,0 @@ __metadata('design:paramtypes', []) |
@@ -1,12 +0,14 @@ | ||
import {PipeTransform, Pipe, Injectable} from '@angular/core'; | ||
import {PipeTransform, Pipe} from '@angular/core'; | ||
import GeneralHelper from '../helpers/helpers'; | ||
@Injectable() | ||
@Pipe({name: 'ucwords'}) | ||
export class UcWordsPipe implements PipeTransform { | ||
transform(text:string):string { | ||
return text.split(' ') | ||
.map(sub => sub.slice(0,1).toUpperCase() + sub.slice(1)) | ||
.join(' '); | ||
transform(text: string): string { | ||
return GeneralHelper.isString(text) | ||
? text.split(' ') | ||
.map(sub => sub.slice(0, 1).toUpperCase() + sub.slice(1)) | ||
.join(' ') | ||
: text; | ||
} | ||
} |
@@ -16,3 +16,3 @@ "use strict"; | ||
// Then we find all the tests. | ||
var context = require.context('../test/', true, /\.spec\.ts/); | ||
var context = require.context('./', true, /\.spec\.ts/); | ||
// And load the modules. | ||
@@ -19,0 +19,0 @@ context.keys().map(context); |
@@ -28,3 +28,3 @@ import './polyfills.ts'; | ||
// Then we find all the tests. | ||
let context = require.context('../test/', true, /\.spec\.ts/); | ||
let context = require.context('./', true, /\.spec\.ts/); | ||
// And load the modules. | ||
@@ -31,0 +31,0 @@ context.keys().map(context); |
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
249190
319
4170
799
30