@thiagoprz/filter-pipe
Version:
Angular Filter Pipe
68 lines (60 loc) • 2.39 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core')) :
typeof define === 'function' && define.amd ? define('@thiagoprz/filter-pipe', ['exports', '@angular/core'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.thiagoprz = global.thiagoprz || {}, global.thiagoprz['filter-pipe'] = {}), global.ng.core));
}(this, (function (exports, core) { 'use strict';
var FilterPipe = /** @class */ (function () {
function FilterPipe() {
}
/**
*
* @param items Items collection
* @param any field The field to be validated
* @param value
*/
FilterPipe.prototype.transform = function (items, field, value) {
if (!items)
return [];
if (!value || value.length == 0)
return items;
return items.filter(function (it) {
var itemValue = typeof it[field] == 'string' ? it[field].toLowerCase() : it[field];
var filterValue = typeof value == 'string' ? value.toLowerCase() : value;
if (filterValue.indexOf('!=') != -1) {
return itemValue != filterValue.replace('!=', '');
}
return itemValue == filterValue;
});
};
return FilterPipe;
}());
FilterPipe.decorators = [
{ type: core.Pipe, args: [{
name: 'filter'
},] },
{ type: core.Injectable }
];
FilterPipe.ctorParameters = function () { return []; };
var FilterPipeModule = /** @class */ (function () {
function FilterPipeModule() {
}
return FilterPipeModule;
}());
FilterPipeModule.decorators = [
{ type: core.NgModule, args: [{
declarations: [FilterPipe],
imports: [],
exports: [FilterPipe]
},] }
];
/*
* Public API Surface of fulltext-search-pipe
*/
/**
* Generated bundle index. Do not edit.
*/
exports.FilterPipe = FilterPipe;
exports.FilterPipeModule = FilterPipeModule;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=thiagoprz-filter-pipe.umd.js.map