Comments (13)
Hallo @RobinTail,
Thanks for the feature request!
- I will check the issue with default color in the next output.
- Yes, it is very important to have a fallback for a terminal supported 256 colors only.
I will implement it in the next version.
Grüß aus Köln
from ansis.
Yes, it is very important to have a fallback for a terminal supported 256 colors only.
I will implement it in the next version.
Thank you, @webdiscus
Ideally it should have fallbacks down to the minimal supported palette.
True color —> 256 colors —> 16 colors —> no colors.
For example, doing hex("#5BCEFA")
in environment having 16 colors only, it should fall back approximately to cyan
.
from ansis.
@RobinTail
I have implemented the detection of color spaces: truecolor, 256 colors, 16 colors, mono.
The fallback truecolor —> 256 colors —> 16 colors —> no colors
works too.
I'm by testing and refactoring.
from ansis.
the new version 3.0.0
is released with fallback to supported color space.
from ansis.
Awesome! I'm going to try it today, @webdiscus
from ansis.
Dear @webdiscus ,
It works perfectly! Thank you so much for all the effort you applied to this feature and your attention to details.
I highly appreciate that you measured the performance and updated documentation.
Fallbacks, named imports, CommonJS compatibility — everything works well.
I tested it in iTerm, Terminal of MacOS and GitHub CI.
from ansis.
Thank You for the very useful feature request!
This makes the library even better.
I have invested a time to optimize performance and size for the new features.
New features adds in bundle only ~600 bytes and the code bundle is still < 4 KB.
from ansis.
vitest now also has benchmarking tools: https://vitest.dev/api/#bench
Thanks @RobinTail for the info.
Yes, I know, and I will switch the benchmark to vitest/bench, but in next step. First I wanted to release the feature and then optimize the benchmark.
Vitest is a very cool tools. This allow to test ESM modules "out of the box". Jest doesn't work with ESM in JetBrains IDEA, so I switched to vitest.
from ansis.
New features adds in bundle only ~600 bytes and the code bundle is still < 4 KB.
That's a great result, @webdiscus !
I highly appreciate your passion.
I think the issue is resolved, so I'm going to close it.
Thank you so much for all the support :)
from ansis.
I have create some simple tests suits using vitest bench.
I am saddened :-(
- it's still very raw and is not yet released:
Benchmarking is an experimental feature. Breaking changes might not follow SemVer, please pin Vitest's version when using it.
- it's very very buggy and does not work stably. Using only 4 suits occurs
fatal error
:Allocation failed - JavaScript heap out of memory
- test results are false and
cannot be trusted
, e.g., the simple bench forchalk.red('foo')
andansis.red('foo')
have results:To compare with the result of thechalk 7.000.000 ansis 23.000.000 (x3 faster than chalk - this is unreal/FALSE result)
benchmark
:chalk 73.000.000 ansis 69.000.000 (this is TRUE result)
So, we cannot trust the results of the vitest bench
.
We need to wait until the first release appears.
from ansis.
Alright, you seem to made a deep research on that topic.
Perhaps it's not yet ready for the project of your scale.
Regarding the accuracy of the measurements.
I think it's different because vitest
runs the tests against the transformed code (using esbuild and rollup under the hood). Perhaps it does that transformation differently for ansis
and chalk
.
I hope it will get better. Thanks for letting me know, @webdiscus
from ansis.
I'm glad to read it, @webdiscus , great news!
Let me know if you need any help.
from ansis.
By the way, @webdiscus
I noticed you also switched to vitest, and I'd like to inform you that vitest now also has benchmarking tools:
https://vitest.dev/api/#bench
So that you can have a single dependency both for testing and benchmarking.
I use it myself and I like how it works.
from ansis.
Related Issues (8)
- [Feature Request] British English (Gray & Grey) HOT 3
- Doesn't work in Next.js middleware (Edge functions) HOT 19
- Color detection when using PM2 HOT 7
- [BUG] 1.3.5 seems broken HOT 10
- [FEATURE REQUEST] Expose `supportsColor` or similar HOT 7
- [Suggestions] Improving types and expose colours as named exports HOT 10
- [BUG] 1.5.0 missing exports main HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansis.