baasic-sdk-javascript
Version:
JavaScript SDK provides core functionality for building web and mobile applications on [Baasic](http://www.baasic.com/).
78 lines (77 loc) • 2.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var inversify_1 = require("inversify");
var Utility = /** @class */ (function () {
function Utility() {
}
/**
* Order an array by specified order type.
* @param values of T type
* @param orderType property name
* @returns ordered array.
*/
Utility.prototype.OrderByArray = function (values, orderType) {
return values.sort(function (a, b) {
if (a[orderType] < b[orderType]) {
return -1;
}
if (a[orderType] > b[orderType]) {
return 1;
}
return 0;
});
};
/**
* Checks if provided value is javascript object.
* @param value any given value
* @returns true if provided value is object, otherwise false.
*/
Utility.prototype.isObject = function (value) {
return value !== null && typeof value === 'object';
};
Utility.prototype.isUndefined = function (value) {
return typeof value === 'undefined';
};
/**
* Copies properties from source object to destination object.
* @param dstObj destination object
* @param srcObj source object
* @returns destination object with new properties from source object.
*/
Utility.prototype.extend = function (dstObj) {
var srcObj = [];
for (var _i = 1; _i < arguments.length; _i++) {
srcObj[_i - 1] = arguments[_i];
}
var newObj = dstObj;
for (var _a = 0, srcObj_1 = srcObj; _a < srcObj_1.length; _a++) {
var obj = srcObj_1[_a];
for (var key in obj) {
//copy all the fields
newObj[key] = obj[key];
}
}
return newObj;
};
/**
* Copies properties from source object to destination object.
* @param dstObj destination object
* @param srcObj source object
* @returns destination object with new properties from source object.
*/
Utility.prototype.extendAs = function (dstObj) {
var srcObj = [];
for (var _i = 1; _i < arguments.length; _i++) {
srcObj[_i - 1] = arguments[_i];
}
srcObj.unshift(dstObj);
return this.extend.apply(this, srcObj);
};
Utility = tslib_1.__decorate([
inversify_1.injectable(),
tslib_1.__metadata("design:paramtypes", [])
], Utility);
return Utility;
}());
exports.Utility = Utility;