e2ed
Version:
E2E testing framework over Playwright
19 lines (18 loc) • 592 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseMaybeEmptyValueAsJson = void 0;
/**
* Parses maybe empty value (`undefined`, empty string or empty buffer) as JSON.
*/
const parseMaybeEmptyValueAsJson = (value) => {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (!value) {
return undefined;
}
const stringValue = String(value);
if (stringValue === '') {
return undefined;
}
return JSON.parse(stringValue);
};
exports.parseMaybeEmptyValueAsJson = parseMaybeEmptyValueAsJson;