util: allow returning `this` from custom inspect · nodejs/node@a60ed89 · GitHub
Skip to content

Commit a60ed89

Browse files
committed
util: allow returning this from custom inspect
If a custom inspection function returned `this`, use that value for further formatting instead of going into infinite recursion. This is particularly useful when combined with `util.inspect.custom` because returning `this` from such a method makes it easy to have an `inspect()` function that is ignored by `util.inspect` without actually having to provide an alternative for custom inspection. PR-URL: #8174 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
1 parent 59714cb commit a60ed89

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

lib/util.js

Lines changed: 8 additions & 3 deletions

test/parallel/test-util-inspect.js

Lines changed: 10 additions & 0 deletions

0 commit comments

Comments
 (0)