ngx-filter-pipe
Advanced tools
Comparing version 1.0.1 to 1.0.2
# Changelog | ||
## 1.0.2 | ||
* [[#50](https://github.com/VadimDez/ngx-filter-pipe/issues/50)] - How to call filterPipe transform from Component ? | ||
## 1.0.1 | ||
@@ -4,0 +7,0 @@ * [[#46](https://github.com/VadimDez/ngx-filter-pipe/issues/46)] - Filter by property/method on prototype chain. |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core")):"function"==typeof define&&define.amd?define(["exports","@angular/core"],t):t(e["ngx-filter-pipe"]={},e.core)}(this,function(e,t){"use strict";var r=function(e,t,r,n){var i,o=arguments.length,f=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)f=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(f=(o<3?i(f):o>3?i(t,r,f):i(t,r))||f);return o>3&&f&&Object.defineProperty(t,r,f),f};e.FilterPipe=function(){function e(){}return e.prototype.filterByString=function(e){return e&&(e=e.toLowerCase()),function(t){return!e||!!t&&-1!==(""+t).toLowerCase().indexOf(e)}},e.prototype.filterByBoolean=function(e){return function(t){return Boolean(t)===e}},e.prototype.filterByObject=function(e){var t=this;return function(r){for(var n in e)if("$or"!==n){var i=r,o=!1;do{if(i.hasOwnProperty(n)||Object.getOwnPropertyDescriptor(i,n)){o=!0;break}}while(i=Object.getPrototypeOf(i));if(!o)return!1;var f=t.getValue(r[n]),l=typeof e[n];if(!("boolean"===l?t.filterByBoolean(e[n])(f):"string"===l?t.filterByString(e[n])(f):"object"===l?t.filterByObject(e[n])(f):t.filterDefault(e[n])(f)))return!1}else if(!t.filterByOr(e.$or)(t.getValue(r)))return!1;return!0}},e.prototype.filterByOr=function(e){return function(t){for(var r=!1,n=e.length,i=Array.isArray(t)?function(r){return-1!==t.indexOf(e[r])}:function(r){return t===e[r]},o=0;o<n;o++)if(i(o)){r=!0;break}return r}},e.prototype.getValue=function(e){return"function"==typeof e?e():e},e.prototype.filterDefault=function(e){return function(t){return void 0===e||e==t}},e.prototype.isNumber=function(e){return!isNaN(parseInt(e,10))&&isFinite(e)},e.prototype.transform=function(e,t){var r=typeof t;return e?"boolean"===r?e.filter(this.filterByBoolean(t)):"string"===r?this.isNumber(t)?e.filter(this.filterDefault(t)):e.filter(this.filterByString(t)):"object"===r?e.filter(this.filterByObject(t)):"function"===r?e.filter(t):e.filter(this.filterDefault(t)):e},e}(),e.FilterPipe=r([t.Pipe({name:"filterBy",pure:!1}),t.Injectable()],e.FilterPipe);var n=function(e,t,r,n){var i,o=arguments.length,f=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)f=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(f=(o<3?i(f):o>3?i(t,r,f):i(t,r))||f);return o>3&&f&&Object.defineProperty(t,r,f),f};e.FilterPipeModule=function(){return function(){}}(),e.FilterPipeModule=n([t.NgModule({declarations:[e.FilterPipe],exports:[e.FilterPipe]})],e.FilterPipeModule),Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core")):"function"==typeof define&&define.amd?define(["exports","@angular/core"],t):t(e["ngx-filter-pipe"]={},e.core)}(this,function(e,t){"use strict";var r=function(e,t,r,n){var i,o=arguments.length,f=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)f=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(f=(o<3?i(f):o>3?i(t,r,f):i(t,r))||f);return o>3&&f&&Object.defineProperty(t,r,f),f};e.FilterPipe=function(){function e(){}return e.prototype.filterByString=function(e){return e&&(e=e.toLowerCase()),function(t){return!e||!!t&&-1!==(""+t).toLowerCase().indexOf(e)}},e.prototype.filterByBoolean=function(e){return function(t){return Boolean(t)===e}},e.prototype.filterByObject=function(e){var t=this;return function(r){for(var n in e)if("$or"!==n){var i=r,o=!1;do{if(i.hasOwnProperty(n)||Object.getOwnPropertyDescriptor(i,n)){o=!0;break}}while(i=Object.getPrototypeOf(i));if(!o)return!1;var f=t.getValue(r[n]),l=typeof e[n];if(!("boolean"===l?t.filterByBoolean(e[n])(f):"string"===l?t.filterByString(e[n])(f):"object"===l?t.filterByObject(e[n])(f):t.filterDefault(e[n])(f)))return!1}else if(!t.filterByOr(e.$or)(t.getValue(r)))return!1;return!0}},e.prototype.filterByOr=function(e){return function(t){for(var r=!1,n=e.length,i=Array.isArray(t)?function(r){return-1!==t.indexOf(e[r])}:function(r){return t===e[r]},o=0;o<n;o++)if(i(o)){r=!0;break}return r}},e.prototype.getValue=function(e){return"function"==typeof e?e():e},e.prototype.filterDefault=function(e){return function(t){return void 0===e||e==t}},e.prototype.isNumber=function(e){return!isNaN(parseInt(e,10))&&isFinite(e)},e.prototype.transform=function(e,t){var r=typeof t;return e?"boolean"===r?e.filter(this.filterByBoolean(t)):"string"===r?this.isNumber(t)?e.filter(this.filterDefault(t)):e.filter(this.filterByString(t)):"object"===r?e.filter(this.filterByObject(t)):"function"===r?e.filter(t):e.filter(this.filterDefault(t)):e},e}(),e.FilterPipe=r([t.Pipe({name:"filterBy",pure:!0}),t.Injectable()],e.FilterPipe);var n=function(e,t,r,n){var i,o=arguments.length,f=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)f=Reflect.decorate(e,t,r,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(f=(o<3?i(f):o>3?i(t,r,f):i(t,r))||f);return o>3&&f&&Object.defineProperty(t,r,f),f};e.FilterPipeModule=function(){return function(){}}(),e.FilterPipeModule=n([t.NgModule({declarations:[e.FilterPipe],providers:[e.FilterPipe],exports:[e.FilterPipe]})],e.FilterPipeModule),Object.defineProperty(e,"__esModule",{value:!0})}); |
@@ -150,3 +150,3 @@ (function (global, factory) { | ||
name: 'filterBy', | ||
pure: false | ||
pure: true | ||
}), | ||
@@ -173,2 +173,3 @@ core.Injectable() | ||
declarations: [exports.FilterPipe], | ||
providers: [exports.FilterPipe], | ||
exports: [exports.FilterPipe] | ||
@@ -175,0 +176,0 @@ }) |
@@ -16,2 +16,3 @@ "use strict"; | ||
declarations: [ngx_filter_pipe_1.FilterPipe], | ||
providers: [ngx_filter_pipe_1.FilterPipe], | ||
exports: [ngx_filter_pipe_1.FilterPipe] | ||
@@ -18,0 +19,0 @@ },] }, |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"FilterPipeModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","module":"./ngx-filter.pipe","name":"FilterPipe"}],"exports":[{"__symbolic":"reference","module":"./ngx-filter.pipe","name":"FilterPipe"}]}]}]}}},{"__symbolic":"module","version":1,"metadata":{"FilterPipeModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","module":"./ngx-filter.pipe","name":"FilterPipe"}],"exports":[{"__symbolic":"reference","module":"./ngx-filter.pipe","name":"FilterPipe"}]}]}]}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"FilterPipeModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","module":"./ngx-filter.pipe","name":"FilterPipe"}],"providers":[{"__symbolic":"reference","module":"./ngx-filter.pipe","name":"FilterPipe"}],"exports":[{"__symbolic":"reference","module":"./ngx-filter.pipe","name":"FilterPipe"}]}]}]}}},{"__symbolic":"module","version":1,"metadata":{"FilterPipeModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","module":"./ngx-filter.pipe","name":"FilterPipe"}],"providers":[{"__symbolic":"reference","module":"./ngx-filter.pipe","name":"FilterPipe"}],"exports":[{"__symbolic":"reference","module":"./ngx-filter.pipe","name":"FilterPipe"}]}]}]}}}] |
@@ -1,2 +0,6 @@ | ||
export declare class FilterPipe { | ||
/** | ||
* Created by vadimdez on 28/06/16. | ||
*/ | ||
import { PipeTransform } from '@angular/core'; | ||
export declare class FilterPipe implements PipeTransform { | ||
private filterByString(filter); | ||
@@ -3,0 +7,0 @@ private filterByBoolean(filter); |
@@ -141,3 +141,3 @@ "use strict"; | ||
name: 'filterBy', | ||
pure: false | ||
pure: true | ||
},] }, | ||
@@ -144,0 +144,0 @@ { type: core_1.Injectable }, |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"FilterPipe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Pipe"},"arguments":[{"name":"filterBy","pure":false}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"filterByString":[{"__symbolic":"method"}],"filterByBoolean":[{"__symbolic":"method"}],"filterByObject":[{"__symbolic":"method"}],"filterByOr":[{"__symbolic":"method"}],"getValue":[{"__symbolic":"method"}],"filterDefault":[{"__symbolic":"method"}],"isNumber":[{"__symbolic":"method"}],"transform":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"FilterPipe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Pipe"},"arguments":[{"name":"filterBy","pure":false}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"filterByString":[{"__symbolic":"method"}],"filterByBoolean":[{"__symbolic":"method"}],"filterByObject":[{"__symbolic":"method"}],"filterByOr":[{"__symbolic":"method"}],"getValue":[{"__symbolic":"method"}],"filterDefault":[{"__symbolic":"method"}],"isNumber":[{"__symbolic":"method"}],"transform":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"FilterPipe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Pipe"},"arguments":[{"name":"filterBy","pure":true}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"filterByString":[{"__symbolic":"method"}],"filterByBoolean":[{"__symbolic":"method"}],"filterByObject":[{"__symbolic":"method"}],"filterByOr":[{"__symbolic":"method"}],"getValue":[{"__symbolic":"method"}],"filterDefault":[{"__symbolic":"method"}],"isNumber":[{"__symbolic":"method"}],"transform":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"FilterPipe":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Pipe"},"arguments":[{"name":"filterBy","pure":true}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"filterByString":[{"__symbolic":"method"}],"filterByBoolean":[{"__symbolic":"method"}],"filterByObject":[{"__symbolic":"method"}],"filterByOr":[{"__symbolic":"method"}],"getValue":[{"__symbolic":"method"}],"filterDefault":[{"__symbolic":"method"}],"isNumber":[{"__symbolic":"method"}],"transform":[{"__symbolic":"method"}]}}}}] |
{ | ||
"name": "ngx-filter-pipe", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Angular 2+ pipeline for filtering arrays", | ||
@@ -5,0 +5,0 @@ "author": "Vadym Yatsyuk <vadym.yatsyuk@gmail.com>", |
@@ -147,2 +147,21 @@ <h1 align="center">Angular2+ Filter Pipe</h1> | ||
### Use FilterPipe in a component | ||
Inject `FilterPipe` into your component and use it: | ||
```ts | ||
class AppComponent { | ||
objects = [ | ||
{ name: 'John' }, | ||
{ name: 'Nick' }, | ||
{ name: 'Jane' } | ||
]; | ||
constructor(private filter: FilterPipe) { | ||
let result = this.filter.transform(this.objects, { name: 'J' }); | ||
console.log(result); // [{ name: 'John' }, { name: 'Jane' }] | ||
} | ||
} | ||
``` | ||
## Test | ||
@@ -149,0 +168,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34487
406
177