UNPKG

ng-jhipster

Version:

A Jhipster util library for Angular 2

26 lines (25 loc) 760 B
import { Pipe } from '@angular/core'; export var OrderByPipe = (function () { function OrderByPipe() { } OrderByPipe.prototype.transform = function (value, predicate, reverse) { value = value.slice(0).sort(function (a, b) { if (a[predicate] < b[predicate]) { return -1; } else if ([b[predicate] < a[predicate]]) { return 1; } else { return 0; } }); return reverse ? value.reverse() : value; }; OrderByPipe.decorators = [ { type: Pipe, args: [{ name: 'orderBy' },] }, ]; /** @nocollapse */ OrderByPipe.ctorParameters = function () { return []; }; return OrderByPipe; }());