courtbot-engine
Version:
An engine for courtbot-like functionality to be included in city/county services sites.
47 lines (38 loc) • 1.76 kB
JavaScript
;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = function () {
var _optionArray = [];
var _optionObject = {};
// Parse arguments
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
args.forEach(function (arg) {
// add primitives to array
if (typeof arg === 'string' || typeof arg === 'boolean' || typeof arg === 'number' || (typeof arg === 'undefined' ? 'undefined' : _typeof(arg)) === 'symbol') {
_optionArray.push(arg);
}
// Add arrays
else if (Array.isArray(arg)) {
_optionArray = _optionArray.concat((0, _utils.scrubArray)(arg));
}
// merge additional objects, overwriting existing keys
else if (Object.prototype.toString.call(arg) === '[object Object]') {
Object.assign(_optionObject, (0, _utils.scrubObject)(arg));
}
// ignore everything else
// The other typeof responses: hostobject, functions and undefined, could cause problems
});
// merge _optionArray into _optionObject
// if any of the keys in _optionObject are numbers that correspond to indices of _optionArray,
// they will be overwritten
Object.assign(_optionObject, _optionArray);
return Object.assign({
path: "/courtbot", //deprecated
dbUrl: process.env.DATABASE_URL || "postgres://postgres:postgres@localhost:5432/courtbotdb"
}, _optionObject);
};
var _utils = require('./utils');