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

harnocode

v2.0.0

Published

Reformat JavaScript code as an ASCII-art image

Downloads

3

Readme

Harnocode

Reformats JavaScript code to look like an ASCII-art picture of your choice. Like this:

                   const                          esprima   =
               require('esprima');            const   escodegen =
             require( 'escodegen') ;        const fs=require('fs');
           exports.harnocode=function(    code,mask,options){options=
          options||{ };const  format= {  safeConcatenation  :  true  ,
         escapeless:true,semicolons:true,renumber:true,quotes:'single'}
         ;code=escodegen.generate(esprima.parse(code),{format:format});
         const tokens=tokenize(code);const lines=splitMaskToGroups(mask
         );let  tokenIndex= 0; let groupIndex =0; let result =[ ];let
         splitStrings=options. splitStrings===undefined?false: options.
          splitStrings;let safe=options.safe===undefined?true:options.
           safe;function processMask(){return lines.map(groups=>{let
             lineResult=[ ];let  offset= 0;if( tokenIndex>=tokens .
              length)return ;groups .forEach (( group,i )=> {let
                groupWidth=group[0].length;let isBeforeNewline=i
                  ==groups.length -1;if( group.index<offset ){
                    groupWidth -= offset- group .index ; if(
                      groupWidth <= 0  ) return ; }  let
                        groupTokens=takeTokens (tokens ,
                          groupWidth , tokenIndex  , {
                            isBeforeNewline , safe ,
                              splitStrings}); let
                                groupTokensJustified
                                  = justify  (
                                    groupTokens
                                         ,

The code should stay functional after the transformation.

"Harnocode" (ukr. гарнокод) means "beautiful code" in the Ukrainian language.

Examples:

Here are functional copies of harnocode's source code formatted with itself:

Installation

$ npm install -g harnocode

Usage

Command-line:

$ harnocode ./examples/lodash.heart.js --mask masks/ubuntu.txt --split-long-lines > lodash.ubuntu.js

See

$ harnocode

for the full list of available options.

Node.js:

TODO

Converting images to masks

TODO

About

Harnocode v1 was written in ClojureScript during the DOU Hackathon on 21-22 February, 2015.

Harnocode v2 is a rewrite in a pure JavaScript. It adds support for ECMAScript 2019, npm module and a command-line tool.