Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
_ _ _
(_)(_) | |
__ _ ___ ___ _ _ ______ __ _ _ __ | |_
/ _` |/ __| / __|| || ||______| / _` || '__|| __|
| (_| |\__ \| (__ | || | | (_| || | | |_
\__,_||___/ \___||_||_| \__,_||_| \__|
Images, fonts, tables, ansi styles and compositing in Node.js & the browser. 100% JS. (What is ASCII-Art?)
In the beginning there was colors.js but in the fine tradition of vendors calling out a problem they have the solution to, chalk was introduced. In that same vein, I offer ascii-art
as an update, expansion and generalization of MooAsciiArt and at the same time it can replace your existing ansi colors library.
It features support for Images, Styles, Tables, Graphs and Figlet Fonts as well as handling multi-line joining and compositing automatically.
String.prototype
usage. No __proto__
usage. No BS.
| ||
In Code
|
CLI
or (Beta):
|
Web
|
All chains in | ||
Callback
|
Promise
|
Await
|
Add ANSI styles to a string and return the result.
Change "Some Text" to be formatted with ansi codes for | ||
JS
|
CL
|
Web
|
Styles are: italic, bold, underline, |framed|, |encircled|, overline, blink and inverse . And available colors are:
Colors
Color defaults to 8 bit (most compatible), to enable other modes set booleans in the options:
is256
: compute the color using 256colors, as defined by ansi256. Note that full color output may need to tune the difference method to obtain optimal results.isTrueColor
: do not constrain color and directly output RGB to the console.Color Tables may be found in the style documentation
Render a string using a figlet font and add that to the buffer. There is a batch version of this function which does not chain and takes an array( .strings()
).
Change "Some Text" to be formatted using the | ||
JS
|
CL
|
Web
|
Outputs
______ _
| _ \ | |
| | | | ___ _ __ ___ ___ | |
| | | | / _ \| '_ ` _ \ / _ \ | |
| |/ / | __/| | | | | || (_) ||_|
|___/ \___||_| |_| |_| \___/ (_)
If you use UTF fonts(Which are part of your system fonts) your output looks more like:
or by using u:<utf font name>
where the font names are: default
, script
, script+bold
, gothic
, gothic+bold
, serif+bold+italic
, serif+bold
, serif+italic
, monospace
, sansserif
, sansserif+bold+italic
, sansserif+bold
, sansserif+italic
, doublestrike
Check out the documentation for more examples!
Create an image from the passed image and append that to the buffer
This takes | ||
JS
|
CL
|
Web
|
There are some options that are available which are not in the image core, they are:
lineart
: A boolean option which outputs lineart using block characters (which may be colored with stroke
and customized with threshold
(0-255)).
stipple
: A boolean option which outputs lineart using braille characters (which may be colored with stroke
and customized with threshold
(0-255)).
posterize
: Use stipple on top of colored backgrounds to retain as much detail as possible.
blended
: Use posterize with both lineart and braille at relative thresholds to each other.
Downsampling and detail lossBecause of the resolution downsampling from the original dimensions to the destination width, some finer details may be lost. Plan accordingly. Here's an example of some sequential art in 256 color (primarily greyscale): | ||
Example
| ||
JS
|
CL
|
Web
|
Color ModesMultiple output modes are available including 4bit, 8bit, 32bit (equivalent to 24bit). 16bit color was intentionally excluded, as there is no direct terminal support and the cost of including color definitions for such a large set would not be justified. It would be feasible to implement as an optional import, should the need exist. The following example takes Anecdotally, the default distance function only covers ~1/3 of the samples we've done, but we support many methods( | |||
img |
4
|
8
|
32
|
JS |
4
|
8
|
32
|
CL |
4
|
8
|
32
|
Web |
4
|
8
|
32
|
Check out the documentation for more examples!
Generate a table from the passed data, with support for many styles and append that to the buffer
Render a table for with the provided data given the provided options | ||
JS
|
CL
|
Web
|
Check out the documentation for more examples!
Render a graph for with the provided data given the provided options | ||
JS
|
CL
|
Web
|
Check out the documentation for more examples!
Fetch a graphic from a remote source and append it to the current buffer, which is not enabled by default. You must add a request
compatible library by either setting the ENV variable ASCII_ART_REQUEST_MODULE
or by setting it manually with art.setRequest(requestModule)
Fetch artwork from the requested source using the preconfigured request library. | ||
JS
|
CL
|
Web
|
Often I use this in conjunction with an image backdrop, for example to superimpose bones on the earth:
We also support combining all these nifty elements you've made into a single composition, via a few functions available on the chains (.lines()
, .overlay()
, .border()
, .strip()
and .join()
). Maybe I've got A BBS wall I want to have some dynamic info on.. I could make that with this
Check out the documentation for detailed examples!
If you're a chalk user, just use var chalk = require('ascii-art/kaolin');
in place of your existing chalk
references (Much of color.js, too... since chalk is a subset of colors.js). No migration needed, keep using the wacky syntax you are used to(In this mode, refer to their docs, not mine).
Users of ascii-table will also note that interface is supported via require('ascii-art').Table
, though our solution is ansi-aware, lazy rendering and better at sizing columns.
I may support the other colors stuff (extras & themes) eventually, but it's currently a low priority.
.artwork()
In the root directory run:
npm run test
which runs the test suite directly. In order to test it in Chrome try:
npm run browser-test
In order to run the chalk test, use:
npm run chalk-test
.artwork()
is currently non-functional while we enable an open-plugin standard, which will arrive shortly. When it does, you'll be able to plug any number of fetch solutions in, which hopefully matches whatever you currently bundle..toPromise()
is now deprecated in favor of .completed()
and will be removed when 3.x arrivesHow to dev : the simple version
ascii-art
git clone git@github.com:<YOUR GITHUB USERNAME>/ascii-art.git
cd ascii-art
./test/dev_setup.sh
(this will install a number of dependencies in the parent directory)How to dev : a better version
ascii-art-image
, ascii-art-ansi
, ascii-art-braille
, ascii-art-docs
, ascii-art-font
, ascii-art-utf
, ascii-art-graph
, ascii-art-table
), along with the root module.git clone git@github.com:<YOUR GITHUB USERNAME>/ascii-art.git
cd ascii-art
./dev_setup.sh <YOUR GITHUB USERNAME>
After setup, run npm test
to make sure everything is working correctly.
Note various modern editions of npm nuke links each time package-lock.json
is written (which, depending on your settings, may be every new dependency you add). This can be remedied by executing npx module-auto-link -c 'npm-auto-link'
in the module in question, which will restore it's links.
Please make sure to run the tests before submitting a patch and report any rough edges. Thanks!
Enjoy,
-Abbey Hawk Sparrow
FAQs
Ansi codes, figlet fonts, and ascii art. 100% JS
The npm package ascii-art receives a total of 600 weekly downloads. As such, ascii-art popularity was classified as not popular.
We found that ascii-art demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.