Skip to content

Hex colors, regular expressions, holes, symbols, BigInt, one-line mode#28

Open
StoneCypher wants to merge 5 commits intoJavascipt:masterfrom
StoneCypher:master
Open

Hex colors, regular expressions, holes, symbols, BigInt, one-line mode#28
StoneCypher wants to merge 5 commits intoJavascipt:masterfrom
StoneCypher:master

Conversation

@StoneCypher
Copy link

@StoneCypher StoneCypher commented Jan 6, 2026

Previously, if you tried to

jsome('blue')('hello')

things would succeed, but if you tried to

jsome('#0000ff')('hello')

the library would crash, unable to find a member function of chalk called #0000ff.

This patch modifies caller behavior interpreting the color to check for a seven character string leading with a hash sign, and defers that to chalk.hex instead of a chalk member function by name, to add truecolor support to your library.

Screenshot 2026-01-05 at 4 38 45 PM

Separately, the display of regular expressions was buggy. They were converted to strings in the pass-through, then displayed as objects because of a bug in reference.

image

They now display as expected.

image

This includes deep in container trees.

image

Separately, holes used to be displayed as rather weird objects.

image

I wasn't really sure whether I wanted to add this. After all, this is a JSON formatter, and holes don't exist in JSON. Then again, you format undefined, and that also doesn't exist in JSON, ... so.

They're a newly added color type, they default to dark gray, and they now say <empty>, similar but not identical to the language.

image

At which point, how could I proceed without handling Symbols?

The library crashed when exposed to Symbols, because they don't have a .toString().

image

So I re-wired the guts a little. Now they display their .description field.

image

And if I didn't do Bignum I'd just be a quitter.

image

This is now repaired:

image

This also works as a member:

image

Finally, for some use cases I needed a one-line mode.

image

With one-line enabled:

image

Thanks for the library!

@StoneCypher StoneCypher changed the title Add support for hex colors by looking for seven-char strings leading with # and passing them to chalk.hex() Add support for hex colors, repair regular expressions Jan 6, 2026
@StoneCypher StoneCypher changed the title Add support for hex colors, repair regular expressions Hex colors, regular expressions, holes, symbols, BigInt, one-line mode Jan 6, 2026
@StoneCypher
Copy link
Author

@Javascipt - please enjoy.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant