GithubHelp home page GithubHelp logo

Comments (7)

webdiscus avatar webdiscus commented on July 28, 2024 1

Hallo @berstend,

thanks for the feature request.

In the v3.2.0 is added the isSupported() method that returns a boolean value.
Returning the support level value (0..3) does not make sense.

import ansis, { green } from 'ansis';

console.log(green`Color output: `, ansis.isSupported());

Grüß aus Köln

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024 1

@RobinTail

it is possible, but:

  1. my be a name collision when used a function with the same name in your (or others projects), because this is a "common" name
  2. the named export is designed for ANSI colors and styles only, not for lib functions. This is a conscious separation.

If you wan't export the additional ansis instance, you can create one:

import { Ansis, blue, green, hex, red } from "ansis"; // <= you exports already the Ansis "class"

const ansis = new Ansis(); // <= create new instance
const color = ansis.isSupported();

Also, technically no problem, but it' not logically. I wan't mix pure ANSI names with lib functions.
E.g. the lib have the ansis.strip() method (remove ANSI codes) under ansis scope. The same works with ansis.isSupported().

from ansis.

RobinTail avatar RobinTail commented on July 28, 2024 1

I've got your point, @webdiscus , thank you.

Yes, the naming is very generic. If it was available as named export I'd most likely rename it in-place during import.

import { isSupported as isColorSupported } from "ansis"; 

But I'm okay with your vision and the suggested solution.
Thank you.

from ansis.

webdiscus avatar webdiscus commented on July 28, 2024 1

@RobinTail can the issue be closed?

from ansis.

berstend avatar berstend commented on July 28, 2024 1

@webdiscus wow, thanks a lot for the quick implementation 😍 👍

Gruß aus Berlin nach Köln

from ansis.

RobinTail avatar RobinTail commented on July 28, 2024 1

@RobinTail can the issue be closed?

Yes, sure, @webdiscus

from ansis.

RobinTail avatar RobinTail commented on July 28, 2024

can it have a named export or is that problematic, @webdiscus ?

import { isSupported } from "ansis"; // this is not available in 3.2.0

from ansis.

Related Issues (9)

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.