UNPKG

@thiagoprz/filter-pipe

Version:
54 lines (48 loc) 1.39 kB
import { Pipe, Injectable, NgModule } from '@angular/core'; class FilterPipe { constructor() { } /** * * @param items Items collection * @param any field The field to be validated * @param value */ transform(items, field, value) { if (!items) return []; if (!value || value.length == 0) return items; return items.filter((it) => { const itemValue = typeof it[field] == 'string' ? it[field].toLowerCase() : it[field]; const filterValue = typeof value == 'string' ? value.toLowerCase() : value; if (filterValue.indexOf('!=') != -1) { return itemValue != filterValue.replace('!=', ''); } return itemValue == filterValue; }); } } FilterPipe.decorators = [ { type: Pipe, args: [{ name: 'filter' },] }, { type: Injectable } ]; FilterPipe.ctorParameters = () => []; class FilterPipeModule { } FilterPipeModule.decorators = [ { type: NgModule, args: [{ declarations: [FilterPipe], imports: [], exports: [FilterPipe] },] } ]; /* * Public API Surface of fulltext-search-pipe */ /** * Generated bundle index. Do not edit. */ export { FilterPipe, FilterPipeModule }; //# sourceMappingURL=thiagoprz-filter-pipe.js.map