UNPKG

e2ed

Version:

E2E testing framework over Playwright

26 lines (25 loc) 1.04 kB
"use strict"; /* eslint-disable no-param-reassign */ Object.defineProperty(exports, "__esModule", { value: true }); exports.setCustomInspectOnFunction = void 0; const node_util_1 = require("node:util"); const asserts_1 = require("../asserts"); const getFunctionPresentationForLogs_1 = require("./getFunctionPresentationForLogs"); function getFunctionPresentationForThis() { return (0, getFunctionPresentationForLogs_1.getFunctionPresentationForLogs)(this); } /** * Set custom `node:inspect` and toJSON presentation (with function code) on function. */ const setCustomInspectOnFunction = (fn) => { (0, asserts_1.assertValueHasProperty)(fn, node_util_1.inspect.custom, { check: '`func` has `inspect.custom` property', skipCheckInRuntime: true, }); if (fn[node_util_1.inspect.custom] !== undefined) { return; } fn[node_util_1.inspect.custom] = getFunctionPresentationForThis; fn.toJSON = getFunctionPresentationForThis; }; exports.setCustomInspectOnFunction = setCustomInspectOnFunction;