Comments (22)
I wonder if
ansi
is a good name for it. ANSI escape code is not the only spec from ANSI org. What names do other langauges' standard libraries use?
On second thought, using "ansi" in the filename may have two negative effects:
- To beginners, it might not be recognizable.
- To those who know ANSI escape codes, it might be misleading, possibly implying that the module also implements control sequences such as cursor movement.
std/cli/styles.ts
might be better.
from deno_std.
I talked with Yoshiya, and we're in favour of merging std/console
into std/cli
and deprecating std/console
. We'll make sure to get back to you about the other points.
from deno_std.
I've updated item 4 with a new suggestion to deprecate std/fmt
.
from deno_std.
Alternatively, we can have printf() use console.log() instead of Deno.stdout for greater compatibility with other runtimes.
I don't think it's good idea to use console.log
for printf
as it can't print \n
by default. I think we should use process.stdout.write
if we try to make it node compatible.
from deno_std.
Move
std/fmt/bytes.ts
tostd/bytes
it feels a bit confusing to me. The APIs in
std/bytes
operate with Uint8Arrays, butstd/fmt/bytes
works with byte numbers, not byte data itself.
True. I was misled by the names. It might make more sense to move bytes.ts
(then renamed to byte_format.ts
or something) to std/number
, which doesn't exist. Now is it worth creating a std/number
? Go doesn't have a number
or integer
module. Lodash does have a number
module with 3 functions: clamp, inRange and random.
Move
std/fmt/duration.ts
tostd/datetime
Doesn't sound a good idea to me as it's highly likely that we deprecate
std/datetime
entirely after Temporal got stable.
We could move it so that it's easier to deprecate everything together in the future because duration.ts
will probably be deprecated too in favor of Temporal.Duration.toLocaleString().
I'm still inclined to pursue the deprecation of fmt
in favor of moving formatting functions to the modules that handle the specific datatype (number, date, string, JSON etc). I don't really know Go, but I'm guessing Go's fmt
is mostly about manipulating mutable strings and byte sequences in a memory-efficient way (which is not trivial in compiled, low level languages), like Java's StringBuilder. It doesn't translate so directly to the JS world. Most of those functions would fit well into std/text
, while others could be ported to std/cli
and std/bytes
.
from deno_std.
I agree with moving and renaming to std/cli/ansi.ts
.
Months ago I was looking for a function to add colors to the terminal. I looked first in cli
and then in console
. I couldn't find anything and thought std didn't have it. I was surprised to find it in fmt
.
from deno_std.
fmt/colors
are largely accepted/used by the community for years (See https://github.com/search?q=fmt%2Fcolors.ts+language%3ATypeScript&type=code&l=TypeScript ), and this is the first report of that kind.
That's probably because std/cli
and std/console
didn't exist before. Once we created them, std/fmt/colors
looked out of place.
I understand that breaking changes like that always bring some nuisance, but in this case I think it makes so much sense users will understand and not be so bothered. Maybe they even like it because they'll be able to import everything from cli
instead of importing a bit from console
, a bit from fmt
and a bit from cli
.
from deno_std.
That's probably because std/cli and std/console didn't exist before. Once we created them, std/fmt/colors looked out of place.
Sounds a fair point.
from deno_std.
Agreed. "Styles" is more specific and descriptive of what it does.
from deno_std.
I agree with 1-3, am unsure about 4, and disagree with 5, as std/text_search
narrows down the purpose of that module too much.
from deno_std.
I'm in favour of moving fmt/colors
to std/cli
, as it's for colours in the terminal. WDYT, @kt3k?
from deno_std.
The new suggestions make a lot of sense to me. However, the printf()
makes it seem like std/fmt/printf
should be moved to std/cli
instead of std/text
. I think printf()
is redundant, as you can just use sprintf()
with console.log()
and it achieves the same effect.
I suggest deprecating printf()
in favour of using sprintf()
with console.log()
. That way, we can move std/fmt/printf
to std/text/sprintf
. @kt3k, WDYT?
from deno_std.
printf
just sounds familiar and looks good to keep. Only providing sprintf
without providing printf
feels strange to me.
from deno_std.
Alternatively, we can have printf()
use console.log()
instead of Deno.stdout
for greater compatibility with other runtimes. @kt3k, WDYT about the other 3 suggestions? I like them.
from deno_std.
Move std/fmt/bytes.ts to std/bytes
Not sure about this, but it feels a bit confusing to me. The APIs in std/bytes
operate with Uint8Array
s, but std/fmt/bytes
works with byte numbers, not byte data itself.
Move std/fmt/colors.ts to std/cli (item 2)
I'm not sure about this. We need more feedback from the community and core team.
Move std/fmt/duration.ts to std/datetime
Doesn't sound a good idea to me as it's highly likely that we deprecate std/datetime
entirely after Temporal got stable.
from deno_std.
I want to focus on std/fmt/colors.ts
. Its renaming to std/cli/colors.ts
is misleading because the module takes care of more than colors. For example, it has bold()
and italic()
, which are not colors. I suggest we move it to std/cli/ansi.ts
. Moving to std/cli
makes a lot sense to me, as these functions are entirely oriented to terminal output.
from deno_std.
Google Chrome supports ANSI escape code in the console.
Maybe this is not specific to terminal
from deno_std.
I use the words terminal and console interchangeably (perhaps, I shouldn't). Even still, that's more to my point of moving it to std/cli
.
from deno_std.
Months ago I was looking for a function to add colors to the terminal. I looked first in cli and then in console. I couldn't find anything and thought std didn't have it. I was surprised to find it in fmt.
I don't see strong enough motivation for moving it. fmt/colors
are largely accepted/used by the community for years (See https://github.com/search?q=fmt%2Fcolors.ts+language%3ATypeScript&type=code&l=TypeScript ) , and this is the first report of that kind.
from deno_std.
Moving std/fmt/colors.ts
to std/cli/ansi.ts
is worth the breaking change at v1 because:
- The module is solely oriented for the console.
std/fmt
is not an obvious location for the module. - Having a filename,
colors.ts
is misleading because it does much more than that. E.g., italic and bold styling.
Having it be std/fmt/colors.ts
makes no sense.
from deno_std.
I wonder if ansi
is a good name for it. ANSI escape code is not the only spec from ANSI org. What names do other langauges' standard libraries use?
from deno_std.
Having it be std/fmt/colors.ts makes no sense.
It's widely accepted in the Deno ecosystem ( https://github.com/search?q=fmt%2Fcolors.ts+language%3ATypeScript&type=code&l=TypeScript ) and that argument ('fmt/colors is confusing') is quite new.
Also this issue doesn't seem getting enough attention from the community.
from deno_std.
Related Issues (20)
- suggestion: move `std/fmt/colors` to `std/cli/styles` HOT 2
- suggestion: add interactive prompts to `@std/cli` HOT 5
- [feature request(collections)] add `invert` HOT 4
- todo: investigate use of `CAN_NOT_DISPLAY` constant
- proposal: Introduce the Brotli Compression Algorithm HOT 2
- assertStrictEquals(-0, +0) should not throw HOT 5
- proposal: stabilize `std/assert` HOT 1
- new package contribution can't pass `Validate PR title` check
- deno-docs references `[email protected]`, which doesn't exist HOT 1
- proposal: stabilize `std/media-types`
- to-do: answer remaining frequently asked questions HOT 1
- bug: flaky `Spinner.color` test
- Is devcontainer settings useful?
- proposal: stabilize `std/internal` HOT 3
- proposal: stabilize `std/uuid`
- [feature request(collections)] option to merge `undefined` in `deepMerge` HOT 4
- Feature request (async): limit() to limit a function concurrency HOT 10
- suggestion: update "Releases" documentation
- tracking: improve doc checker tools HOT 1
- bug: `Spinner constructor accepts interval` test is flaky HOT 2
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 deno_std.