Comments (7)
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.
it is possible, but:
- my be a name collision when used a function with the same name in your (or others projects), because this is a "common" name
- 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.
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.
@RobinTail can the issue be closed?
from ansis.
@webdiscus wow, thanks a lot for the quick implementation 😍 👍
Gruß aus Berlin nach Köln
from ansis.
@RobinTail can the issue be closed?
Yes, sure, @webdiscus
from ansis.
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)
- [Feature Request] British English (Gray & Grey) HOT 3
- [BUG] 1.3.5 seems broken HOT 10
- [Suggestions] Improving types and expose colours as named exports HOT 10
- [BUG] 1.5.0 missing exports main HOT 10
- Doesn't work in Next.js middleware (Edge functions) HOT 19
- [FEATURE REQUEST] Fallbacks when true color or ANSI 256 is not supported HOT 13
- Color detection when using PM2 HOT 7
- isSupported returns true when redirecting stdout on windows HOT 4
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.