npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

js-ascii

v1.0.2

Published

An ascii art parser and renderer

Downloads

5

Readme

js-ascii

Build Status npm dependencies Status devDependencies Status

(jsAscii) is a JavaScript utility library for serializing and rendering ASCII art in the browser. It takes ASCII art following the format of neofetch's ascii art, and converts it into a processable array.

The rendering engine can be used to render the arrays into various serialized formats, including HTML and most consoles. The library additionally allows the specification of custom output formats via an internal API.

Installing

via npm

npm i -S js-ascii

How to use

Node.js

Require the jsAscii module and use the api as demonstrated below:

const jsAscii = require('js-ascii');

// converts raw string art to a raw JavaScript array implementation
const formattedArt = jsAscii.convert("${c1}Hello ${c2}World");

const colorizedHTML = jsAcii.renderToHTML(formattedArt, {
	// any valid CSS color
	styles: {
		1: 'red',
		2: '#00f',
	},
});
// outputs: <span style="color:red">Hello </span><span style="color:#00f">World</span>

const colorizedConsole = jsAcii.renderToTTY(formattedArt, {
	// specific console color cold (Number) or
	// string name
	styles: {
		1: 'red',
		2: 'blue',
	}
});
// outputs: Hello World
// (colorized version logo for STDOUT/console)

Browser

If using a bundling utility, you can include the module the same way you would include the Node.js api. Otherwise, concatenated dist files can also be loaded in.

Pre-transpiled import (ES5)

If you are using browser modules (or not using babel), an ES5 friendly version can be included like so:

// standard import
import jsAscii from 'js-ascii';
import { convert, renderToHTML } from 'js-ascii';

// named imports (for improved tree shaking)
import convert from 'js-ascii/dist/lib/convert';
import renderToHTML from 'js-ascii/dist/lib/formats/html';

// full dist IFFE (for environments without bundlers)
import 'js-acii/dist/client';

Non-transpiled (ES2015+)

If you are using your own post-process transpiler, you can include the full non-transpiled implementation like so:

// standard import
import jsAscii from 'js-ascii/source';
import { convert, renderToHTML } from 'js-ascii/source';

// named imports (for improved tree shaking)
import convert from 'js-ascii/lib/convert';
import renderToHTML from 'js-ascii/lib/formats/html';

// full dist IFFE (for environments without bundlers)
import 'js-acii/dist/condensed';

API documentation

Coming soon (refer to included inline /lib documentation)

ASCII ART Editor

A simple single-page HTML application has also been included in /editor direactory of this repository.

At the bottom of the page, both of the compiled outputs will be updated as the input field changes (or when a page click occurs). Other useful functionality is shown within the editor itself.