GithubHelp home page GithubHelp logo

Comments (13)

webdiscus avatar webdiscus commented on July 28, 2024 1

Hallo @RobinTail,

Thanks for the feature request!

  1. I will check the issue with default color in the next output.
  2. 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.

RobinTail avatar RobinTail commented on July 28, 2024 1

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.

webdiscus avatar webdiscus commented on July 28, 2024 1

@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.

webdiscus avatar webdiscus commented on July 28, 2024 1

@RobinTail

the new version 3.0.0 is released with fallback to supported color space.

from ansis.

RobinTail avatar RobinTail commented on July 28, 2024 1

Awesome! I'm going to try it today, @webdiscus

from ansis.

RobinTail avatar RobinTail commented on July 28, 2024 1

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.

webdiscus avatar webdiscus commented on July 28, 2024 1

@RobinTail

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.

webdiscus avatar webdiscus commented on July 28, 2024 1

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.

RobinTail avatar RobinTail commented on July 28, 2024 1

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.

webdiscus avatar webdiscus commented on July 28, 2024 1

@RobinTail

I have create some simple tests suits using vitest bench.

I am saddened :-(

  1. 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.
    
  2. it's very very buggy and does not work stably. Using only 4 suits occurs fatal error:
    Allocation failed - JavaScript heap out of memory
    
  3. test results are false and cannot be trusted, e.g., the simple bench for chalk.red('foo') and ansis.red('foo') have results:
    chalk  7.000.000
    ansis 23.000.000 (x3 faster than chalk - this is unreal/FALSE result)
    
    To compare with the result of the 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.

RobinTail avatar RobinTail commented on July 28, 2024 1

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.

RobinTail avatar RobinTail commented on July 28, 2024

I'm glad to read it, @webdiscus , great news!
Let me know if you need any help.

from ansis.

RobinTail avatar RobinTail commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.