|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | function requireUtil() {
|
|---|
| 2 | try {
|
|---|
| 3 | // eslint-disable-next-line no-restricted-modules
|
|---|
| 4 | return require("util");
|
|---|
| 5 | } catch (e) {
|
|---|
| 6 | return null;
|
|---|
| 7 | }
|
|---|
| 8 | }
|
|---|
| 9 |
|
|---|
| 10 | // for v10.12.0+
|
|---|
| 11 | function lookupCustomInspectSymbol() {
|
|---|
| 12 | return Symbol.for("nodejs.util.inspect.custom");
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | // for older node environments
|
|---|
| 16 | function tryReadingCustomSymbolFromUtilInspect(options) {
|
|---|
| 17 | const _requireUtil = options.requireUtil || requireUtil;
|
|---|
| 18 | const util = _requireUtil();
|
|---|
| 19 | return util ? util.inspect.custom : null;
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | exports.getUtilInspect = function getUtilInspect(fallback, options = {}) {
|
|---|
| 23 | const _requireUtil = options.requireUtil || requireUtil;
|
|---|
| 24 | const util = _requireUtil();
|
|---|
| 25 | return function inspect(value, showHidden, depth) {
|
|---|
| 26 | return util ? util.inspect(value, showHidden, depth) : fallback(value);
|
|---|
| 27 | };
|
|---|
| 28 | };
|
|---|
| 29 |
|
|---|
| 30 | exports.getCustomInspectSymbol = function getCustomInspectSymbol(options = {}) {
|
|---|
| 31 | const _lookupCustomInspectSymbol =
|
|---|
| 32 | options.lookupCustomInspectSymbol || lookupCustomInspectSymbol;
|
|---|
| 33 |
|
|---|
| 34 | // get custom inspect symbol for node environments
|
|---|
| 35 | return (
|
|---|
| 36 | _lookupCustomInspectSymbol() ||
|
|---|
| 37 | tryReadingCustomSymbolFromUtilInspect(options)
|
|---|
| 38 | );
|
|---|
| 39 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.