@chustasoft/cs-common
Version:
Common utilities for JavaScript projects equivalents to ChustaSoft CommonNET project
20 lines (19 loc) • 690 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const __1 = require("..");
if (!Array.prototype.orderBy) {
Array.prototype.orderBy = function (property, sortingType = __1.SortingType.ASCENDING) {
switch (sortingType) {
case __1.SortingType.ASCENDING:
return this.sort((a, b) => (a[property] > b[property] ? 1 : -1));
case __1.SortingType.DESCENDING:
return this.sort((a, b) => (a[property] < b[property] ? 1 : -1));
}
};
}
if (!Array.prototype.remove) {
Array.prototype.remove = function (element) {
this.splice(this.indexOf(element), 1);
return this;
};
}