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

Support placeholder tokens in t.log() #1654

Open
novemberborn opened this issue Jan 25, 2018 · 2 comments
Open

Support placeholder tokens in t.log() #1654

novemberborn opened this issue Jan 25, 2018 · 2 comments

Comments

@novemberborn
Copy link
Member

t.log() is modeled after console.log(), which in Node.js uses util.format(). This function supports placeholder tokens. I couldn't quite find a maintained & ready module that would let us support the same tokens.

This is the behavior I'd expect:

Token Behavior
%s Cast the value to a string
%d Cast the value to a number
%i Parse the value as an integer
%f Parse the value as a float
%j Stringify the value as JSON, but output '[Circular]' if it contains circular references
%o Stringify using Concordance (current behavior since #1653)
%O Stringify using Concordance (current behavior since #1653)
%% Print '%'
@sindresorhus
Copy link
Member

Can't we just run it through util.format()?

@novemberborn
Copy link
Member Author

That would make the formatting inconsistent with all our other value output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants