e2ed
Version:
E2E testing framework over Playwright
20 lines (19 loc) • 733 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.cloneWithoutUndefinedProperties = void 0;
const asserts_1 = require("../asserts");
/**
* Clone object without properties that values is `undefined`.
*/
const cloneWithoutUndefinedProperties = (x) => {
const result = {};
for (const [key, value] of Object.entries(x)) {
const descriptor = Object.getOwnPropertyDescriptor(x, key);
(0, asserts_1.assertValueIsDefined)(descriptor, 'descriptor is defined', { key, x });
if (value !== undefined) {
Object.defineProperty(result, key, descriptor);
}
}
return result;
};
exports.cloneWithoutUndefinedProperties = cloneWithoutUndefinedProperties;