jest-test-each
Version:
run parametrised tests easily [typesafe] without text tables or arrays of arrays.
28 lines (27 loc) • 755 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.merge = exports.checkObjEmpty = exports.guard = void 0;
const guard = (condition, message) => {
if (!condition) {
throw new Error('From guard: ' + message);
}
};
exports.guard = guard;
const checkObjEmpty = (obj) => {
return (JSON.stringify(obj, (k, v) => {
if (typeof v === 'function') {
return 'function';
}
if (v === undefined) {
return 'undefined';
}
return v;
}) === '[{}]');
};
exports.checkObjEmpty = checkObjEmpty;
const merge = (objs) => {
let res = {};
objs.forEach(t => (res = Object.assign(Object.assign({}, res), t)));
return res;
};
exports.merge = merge;