| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d4b41f6 commit 1fbd7ac
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -121,6 +121,8 @@ const builtInObjects = new Set( | |||
| 121 | 121 | ObjectGetOwnPropertyNames(global).filter((e) => /^([A-Z][a-z]+)+$/.test(e)) | |
| 122 | 122 | ); | |
| 123 | 123 | ||
| 124 | + // These options must stay in sync with `getUserOptions`. So if any option will | ||
| 125 | + // be added or removed, `getUserOptions` must also be updated accordingly. | ||
| 124 | 126 | const inspectDefaultOptions = ObjectSeal({ | |
| 125 | 127 | showHidden: false, | |
| 126 | 128 | depth: 2, | |
@@ -176,13 +178,20 @@ const meta = [ | |||
| 176 | 178 | ]; | |
| 177 | 179 | ||
| 178 | 180 | function getUserOptions(ctx) { | |
| 179 | - const obj = { stylize: ctx.stylize }; | ||
| 180 | - for (const key of ObjectKeys(inspectDefaultOptions)) { | ||
| 181 | - obj[key] = ctx[key]; | ||
| 182 | - } | ||
| 183 | - if (ctx.userOptions === undefined) | ||
| 184 | - return obj; | ||
| 185 | - return { ...obj, ...ctx.userOptions }; | ||
| 181 | + return { | ||
| 182 | + stylize: ctx.stylize, | ||
| 183 | + showHidden: ctx.showHidden, | ||
| 184 | + depth: ctx.depth, | ||
| 185 | + colors: ctx.colors, | ||
| 186 | + customInspect: ctx.customInspect, | ||
| 187 | + showProxy: ctx.showProxy, | ||
| 188 | + maxArrayLength: ctx.maxArrayLength, | ||
| 189 | + breakLength: ctx.breakLength, | ||
| 190 | + compact: ctx.compact, | ||
| 191 | + sorted: ctx.sorted, | ||
| 192 | + getters: ctx.getters, | ||
| 193 | + ...ctx.userOptions | ||
| 194 | + }; | ||
| 186 | 195 | } | |
| 187 | 196 | ||
| 188 | 197 | /** | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -883,6 +883,10 @@ util.inspect({ hasOwnProperty: null }); | |||
| 883 | 883 | assert.strictEqual(opts.budget, undefined); | |
| 884 | 884 | assert.strictEqual(opts.indentationLvl, undefined); | |
| 885 | 885 | assert.strictEqual(opts.showHidden, false); | |
| 886 | + assert.deepStrictEqual( | ||
| 887 | + new Set(Object.keys(util.inspect.defaultOptions).concat(['stylize'])), | ||
| 888 | + new Set(Object.keys(opts)) | ||
| 889 | + ); | ||
| 886 | 890 | opts.showHidden = true; | |
| 887 | 891 | return { [util.inspect.custom]: common.mustCall((depth, opts2) => { | |
| 888 | 892 | assert.deepStrictEqual(clone, opts2); | |
@@ -909,10 +913,11 @@ util.inspect({ hasOwnProperty: null }); | |||
| 909 | 913 | } | |
| 910 | 914 | ||
| 911 | 915 | { | |
| 912 | - const subject = { [util.inspect.custom]: common.mustCall((depth) => { | ||
| 916 | + const subject = { [util.inspect.custom]: common.mustCall((depth, opts) => { | ||
| 913 | 917 | assert.strictEqual(depth, null); | |
| 918 | + assert.strictEqual(opts.compact, true); | ||
| 914 | 919 | }) }; | |
| 915 | - util.inspect(subject, { depth: null }); | ||
| 920 | + util.inspect(subject, { depth: null, compact: true }); | ||
| 916 | 921 | } | |
| 917 | 922 | ||
| 918 | 923 | { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments