w-ng5
Version:
Angular Generic Filters to *ngFor
3 lines (2 loc) • 1.64 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("w-ng5",["exports","@angular/core"],t):t(e["w-ng5"]={},e.ng.core)}(this,function(e,t){"use strict";var r=function(){function e(){}return e.prototype.transform=function(e,t){return t instanceof Array?this.checkComplexType(e,t):this.checkSimpleType(e,t)},e.prototype.checkSimpleType=function(e,t){return e&&t?e.filter(function(e){return-1!==e.toString().toLowerCase().indexOf(t.toString().toLowerCase())}):e},e.prototype.checkComplexType=function(e,o){var n=this;if(!e||!o||0===o.length)return e;var i=[];return e.forEach(function(t){var r=!1;o.forEach(function(e){r=r||n.checkValue(t,e)}),r&&i.push(t)}),i},e.prototype.checkValue=function(e,t){return!(t&&t.field&&t.value&&""!==t.value)||(this.existDot(t.field)?this.parseValue(e,t.value,t.field):!!e[t.field]&&-1!==e[t.field].toString().toLowerCase().indexOf(t.value.toString().toLowerCase()))},e.prototype.parseValue=function(e,t,r){var o=r.split(".");return this.existFieldValue(e,t,o,0)},e.prototype.existDot=function(e){return-1<e.indexOf(".")},e.prototype.existFieldValue=function(e,t,r,o){var n=e[r[o]];return o===r.length-1?!!n&&-1!==n.toString().toLowerCase().indexOf(t.toString().toLowerCase()):!!n&&this.existFieldValue(n,t,r,++o)},e}();r.decorators=[{type:t.Pipe,args:[{name:"filter",pure:!0}]}];var o=function(){};o.decorators=[{type:t.NgModule,args:[{declarations:[r],exports:[r],providers:[r]}]}],e.FilterPipe=r,e.PipesModule=o,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=w-ng5.umd.min.js.map