Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New option to define indentation #13

Merged
merged 1 commit into from
May 28, 2020
Merged

New option to define indentation #13

merged 1 commit into from
May 28, 2020

Conversation

mkls
Copy link
Contributor

@mkls mkls commented Feb 20, 2017

I had a use case where I wanted to see the output of object-inspect indented,

Current output for inspect({a: 1, b: 2}):

{ a: 1, b: 2 }

New option would make this possible: inspect({a: 1, b: 2}, {indent: ' '}):

{
  a: 1,
  b: 2
}

Added a few test cases that show other cases about how it would work.

If you guys think this would be something useful to include then I'm happy to work on it a bit more and clean it up if needed. Opened this PR is just to test the idea and get some feedback.

Fixes #27.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it would need to handle a lot of edge cases if it's an open-ended "indent" string.

I'd think probably the best way to do this is allowing indent to be an integer > 0, or the string '\t', and treat that as N spaces, or "tabs".

I'm not convinced this is a feature worth adding, but it's totally fine to explore what it would look like in this PR.

index.js Outdated Show resolved Hide resolved
index.js Outdated Show resolved Hide resolved
@mkls
Copy link
Contributor Author

mkls commented Feb 21, 2017

I'm also not a 100% sure this is a needed feature, but I found myself missing it. I figured I'll put in a bit of extra effort to open up a PR after I implemented it, just to see if this is needed or not.

I'm not familiar with all the use cases of this module, so I'll gracefully accept if you think this is not something you want to include.

@jaredatron
Copy link

jaredatron commented Nov 8, 2018

@mkls thank you for this! Please merge! :D

@ljharb ljharb force-pushed the master branch 3 times, most recently from 95d2316 to 3ddb3e4 Compare November 11, 2019 04:12
@ljharb ljharb force-pushed the master branch 4 times, most recently from 3539b0e to 66158f9 Compare January 27, 2020 23:06
@ljharb ljharb force-pushed the master branch 3 times, most recently from e4472d3 to 42f214b Compare May 26, 2020 07:04
@ljharb ljharb removed the question label May 26, 2020
@codecov
Copy link

codecov bot commented May 26, 2020

Codecov Report

Merging #13 into master will increase coverage by 0.30%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #13      +/-   ##
==========================================
+ Coverage   97.71%   98.02%   +0.30%     
==========================================
  Files           2        2              
  Lines         219      253      +34     
  Branches       84       98      +14     
==========================================
+ Hits          214      248      +34     
  Misses          5        5              
Impacted Files Coverage Δ
index.js 98.01% <100.00%> (+0.30%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 28b9179...900d3d8. Read the comment docs.

@ljharb ljharb force-pushed the master branch 2 times, most recently from 0762b40 to 900d3d8 Compare May 28, 2020 22:14
@ljharb ljharb merged commit 900d3d8 into inspect-js:master May 28, 2020
ljharb added a commit that referenced this pull request Jun 19, 2020
 - [New] add `indent` option (#13)
 - [New] add `customInspect` option, to disable custom inspect methods
 - [New] add `maxStringLength` option
 - [Fix] do not be fooled by a function’s own `toString` method
 - [Fix] when truncating a deep array, note it as `[Array]` instead of just `[Object]`
 - [patch] indicate explicitly that anon functions are anonymous, to match node
 - [readme] fix repo URLs, remove testling
 - [meta] add `safe-publish-latest`
 - [Tests] add Date and RegExp tests
 - [Tests] add codecov
 - [actions] add automatic rebasing / merge commit blocking
 - [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `core-js`, `tape`; add `aud`; loosen the `core-js` dep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formatted output with indents?
3 participants