mrjacobbloom / echo Goto Github PK
View Code? Open in Web Editor NEWFun with proxies. Repeats after you.
License: ISC License
Fun with proxies. Repeats after you.
License: ISC License
Should tokens just always be wrapped in a type: default
/unknown/whatever? It'd be more presentable
If first argument is a string[] & { raw: string[] }
then render as a tagged template literal
Does it do anything besides declare a global with some confusingly circular functionality? Might be nice to expose typings for options?
Can we auto-generate these? IDK if Typescript really understands what we're trying to do here
Not sure what this would look like?
Echo.options.theme = {
default: 'rgba(111, 222, 123, 1)',
/* ... */
}
Allow extension of existing theme instead of defining every token color?
Automatically calculate nearest ANSI color code? Add support for 8-bit/24-bit color? https://github.com/substack/node-x256
/* > */ Echo('foo\nbar')
/* < */ Echo('foo
bar')
Potential routes:
`
\n
/* > */ Echo('\%s').foo(1)
/* < */ Echo('color: black').foo(1%c)
Format strings that may cause issues: %o
, %O
, %d
, %i
, %s
, %f
, %c
, %.2f (etc)
Make sure fix doesn't slip into ansi mode unless it's invisible
Documentation on console formatting is pretty sparse: https://developer.mozilla.org/en-US/docs/Web/API/console#Using_string_substitutions
May have to use a zwsp or something :(
Possible plan:
Alternative is to switch a flag in every public method, and separate render() into public and private versions
Does Chrome even still eager-eval Echo? What about giving the original (internal) Echo function side effects? It should never be called. Would that prevent autocomplete as well?
Autocomplete seems to stop after a construct (potentially also a call) -- or does it? Maybe there's a way to take advantage of that?
Is it worth it to specialize for Chrome's devtools?
Right now it uses the value of Echo.render at the time of the Echo.then GET, ideally it should be grabbed at the time of apply. Maybe it could look more like
Echo.then = (...args) => Promise.prototype.then.apply(Echo.render(), args);
Right now the stringifier functions all pass through to their defaults if options.output='ToString'
. They should probably always be overridden, and options.output='ToString'
just disables automatic logging
Line 29 in 1c5cfac
Make it a type guard or whatever: https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards
: args is [TemplateStringsArray, ...any[]]
Right now the recommended way to play with it is to paste the code into your console... which is bad... consider a RunKit link as the primary recommendation as well
Could potentially use https://github.com/Marak/colors.js/blob/master/lib/system/supports-colors.js
Node has hasColors()
(11.13+) or getColorDepth()
(9.9+) https://nodejs.org/api/tty.html#tty_writestream_hascolors_count_env
Would we need to use createRequire? Can we circumvent this since new Node should be able to use Symbol.for(...)
?
Would just make the output string prettier (in a way nobody should ever see)
%
escaped in console text, not in other output modesoutput='promise'
https://www.typescriptlang.org/docs/handbook/namespaces.html
No need to muddy the global type scope if we can help it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.