sindresorhus / ansi-escapes

ANSI escape codes for manipulating the terminal
MIT License
494 stars 44 forks source link

Provide named exports, fixes #27 #37

Closed broofa closed 6 months ago

broofa commented 6 months ago

[Deleted previous description.]

Adds support for named exports. This is achieved by declaring all functions and constants as named exports, first, and then using them to compose the default object API.

All that other guff about ava and xo, etc... has been reverted. 😄

Fixes #27

sindresorhus commented 6 months ago

It's generally best to focus on the issue at hand and not cramp in lots of unrelated changes. I'm using XO and AVA in all my projects and I don't plan to remove them here. I also prefer keeping the default export to not break backwards compatibility, but also because I think it's a better API.

broofa commented 6 months ago

@sindresorhus : Reverted all changes not essential to #27 . If you could take another look, that'd be great. If you're still not interested, go ahead and close I suppose. Cheers!

sindresorhus commented 6 months ago

You can use this trick to avoid having to specify the named exports manually for the default export: https://github.com/sindresorhus/query-string/blob/main/index.js

sindresorhus commented 6 months ago

You can use this trick to avoid having to specify the named exports manually for the default export: sindresorhus/query-string@main/index.js

Also for index.d.ts

broofa commented 6 months ago

@sindresorhus Updated the .d.ts file to use the same index/base pattern. Note that this uses the "`export as default from '...'" pattern for the default export inindex.d.ts. This was the only pattern that seemed to keep both TypeScript (in VSCode) from complaining, and also satisfytsd` in the unit test.

sindresorhus commented 6 months ago

Thanks :)