agil-auth-node
Version:
Agile authentication for NodeJS
60 lines • 2.08 kB
JavaScript
;
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Utils = void 0;
var Utils = /** @class */ (function () {
function Utils() {
}
/**
* https://gist.github.com/ahtcx/0cd94e62691f539160b32ecda18af3d6
*/
Utils.merge = function (target, source) {
var e_1, _a;
try {
// Iterate through `source` properties and if an `Object` set property to merge of `target` and `source` properties
for (var _b = __values(Object.keys(source)), _c = _b.next(); !_c.done; _c = _b.next()) {
var key = _c.value;
if (source[key] instanceof Object)
Object.assign(source[key], this.merge(target[key], source[key]));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
// Join `target` and modified `source`
Object.assign(target || {}, source);
return target;
};
/**
* Object to SQL 'where' statement
*/
Utils.objectToWhereStatement = function (object) {
var where = '', values = [];
for (var key in object) {
var val = object[key];
if (where.length) {
where += " AND ";
}
where += " ".concat(key, " = ? ");
values.push(val);
}
return [where, values];
};
return Utils;
}());
exports.Utils = Utils;
//# sourceMappingURL=utils.js.map