request-mocking-protocol
Version:
A protocol for declarative mocking of HTTP requests
25 lines • 793 B
JavaScript
;
/**
* Mock response utils.
*/
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.patchObject = patchObject;
exports.wait = wait;
const set_1 = __importDefault(require("lodash/set"));
/**
* Patches object by provided set of keyPath and value pairs.
*/
function patchObject(obj, patchSchema) {
if (obj && typeof obj === 'object' && patchSchema) {
Object.keys(patchSchema).forEach((keyPath) => {
(0, set_1.default)(obj, keyPath, patchSchema[keyPath]);
});
}
}
async function wait(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
//# sourceMappingURL=utils.js.map