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

@crabas0npm/voluptas-ad-vel

v1.0.0

Published

[![npm](https://img.shields.io/npm/v/@crabas0npm/voluptas-ad-vel.svg)](https://npmjs.com/package/@crabas0npm/voluptas-ad-vel)

Downloads

9

Maintainers

thanhl4861thanhl4861

Keywords

setreadablestreamyamlphonetostringtagerror-handlingflagairbnbinstallerfindLastIndexObject.assignfantasy-landdeepcopycircularECMAScript 2021sharedwhatwgclidefinecachestreamsauthwalkingprotoirqgetintrinsicfiltersetterObject.entriespackage managerauthenticationcall-bindArray.prototype.filterclassnameswgetrangeerrorregexenvinvariantsyntaxstylingtoStringTagzeroshrinkwrapextendwaapi@@toStringTages2015websitetc39PromisecolumnsprogressJSON-Schemaes-abstractoptimizersequencesettingslibphonenumbermovelinewrapArray.prototype.containsvisualprotobuflintdirectorythrottleconnectBigUint64Arraylaunchbrowserimmutablejson-schema-validationoptionhashnameterminalECMAScript 2017cryptless mixinsless csscopywatcherworkereslintpluginvarcryptocharactersemojimkdirsarrayscode pointsqsgesturescommand-lineformattinghookformlazyECMAScript 2022eslint-pluginsyntaxerrorbindoutputnpmtypeofentriescodesUint16ArrayurlsrandomwatchFilegenericsweakmappolyfillES2020mime-dbgroupBymobileasyncconcurrencynegativetypescriptutilmixinsautoprefixerArrayBuffer#slicecharacterextragetdeephigher-orderpyyamlformscurlURLprotocol-buffershttpsawesomesaucelinuxbannercolourtrimStartfpredux-toolkitloggerfiledotenvsameValueZeroencryptionansiECMAScript 2020helperscall-boundflattraversepathvalidatorvalidatetypesafemochaES6serializationregexpcolorlesstypanionforEachpnpm9ES2016byteLengthfastifydefaultmapgetOwnPropertyDescriptorrmoptimistclientWeakSetartobjframeworkperformantgradients cssbrowserlistupYAMLWeakMapES2018immeruninstalltranspilemulti-packagepreserve-symlinksUnderscoredeep-copyhasOwnparseidbuffersgetoptcolorsrecursiveenvironmentrm -rfprivate dataloggingavastructuredCloneperformancelengthpackagesbytegetterhasdescriptionsliceprettyPushidleconcatMapCSSInt32ArrayoncekeysECMAScript 2015nativecss-in-jsuser-streamsindicatortrimEndECMAScript 7finddeep-cloneratelimitECMAScript 2019collection.es6readkoreanfast-deep-copyArray.prototype.findLastlimitemitjson-schema-validatorglobintrinsicES2023dependency managerunicodees2018rm -frless.jstacitjavascriptcallstreamRegExp#flagsworkspace:*passwordECMAScript 2023SymbolarraybufferargumentsprivateES8ReactiveXtoolsomitschemespeedtypees8RxbabelparentswaitconfigurablenopeObject.keysvalidfromdeepclonetddapifind-uppersistentcss nestingflatMapcheckquotepipebatchastRegExp.prototype.flagspostcsserrormimetypesquerySetstyleguidedescriptorsjestIteratoranimationdescriptorinterruptsArray.prototype.includesfunctionalreact-hook-formmodulesredactStyleSheetArrayBuffervalidationcompilerTypeScriptargumentES7matchesexebreakpostcss-pluginES2022groupECMAScript 2018fastuuidreducerstringifyshimformattyped arrayenumerablenodejses6jsonString.prototype.trimObject.definePropertystylesheetreduceESdatasymlinkswebbrowserslistefficientxtermfastclonefolderequalitymetadataaccessorgetPrototypeOfisConcatSpreadablerequestchildwatchfindLastfetchisfullwidthcensorframerbusyxsslastfullwalk

Readme

@crabas0npm/voluptas-ad-vel

npm

A JavaScript ANSI color/style management. ANSI parsing. ANSI to CSS. Small, clean, no dependencies.

npm install @crabas0npm/voluptas-ad-vel

What For

Why Another One?

Other tools lack consistency, failing to solve a simple hierarchy problem:

require ('colors') // a popular color utility

console.log (('foo'.cyan + 'bar').red)

pic

WTF?! The bar word above should be rendered in red, but it's not! That sucks. It's because ANSI codes are linear, not hierarchical (as with XML/HTML). A special kind of magic is needed to make this work. Ansicolor does that magic for you:

require ('@crabas0npm/voluptas-ad-vel').nice // .nice for unsafe String extensions

console.log (('foo'.cyan + 'bar').red)

pic

Nice!

Crash Course

Importing (as methods):

import { green, inverse, bgLightCyan, underline, dim } from '@crabas0npm/voluptas-ad-vel'
const { green, inverse, bgLightCyan, underline, dim } = require ('@crabas0npm/voluptas-ad-vel')

Usage:

console.log ('foo' + green (inverse (bgLightCyan ('bar')) + 'baz') + 'qux')
console.log (underline.bright.green ('foo' + dim.red.bgLightCyan ('bar'))) // method chaining

Importing (as object):

import { @crabas0npm/voluptas-ad-vel, ParsedSpan } from '@crabas0npm/voluptas-ad-vel' // along with type definitions
import @crabas0npm/voluptas-ad-vel from '@crabas0npm/voluptas-ad-vel'

Nice Mode (not recommended)

const ansi = require ('@crabas0npm/voluptas-ad-vel').nice

The ('@crabas0npm/voluptas-ad-vel').nice export defines styling APIs on the String prototype directly. It uses an ad-hoc DSL (sort of) for infix-style string coloring. The nice is convenient, but not safe, avoid using it in public modules, as it alters global objects, and that might cause potential hard-to-debug compatibility issues.

console.log ('foo'.red.bright + 'bar'.bgYellow.underline.dim)

Supported Styles

'foreground colors'
    .red.green.yellow.blue.magenta.cyan.white.darkGray.black
'light foreground colors'
    .lightRed.lightGreen.lightYellow.lightBlue.lightMagenta.lightCyan.lightGray
'background colors'
    .bgRed.bgGreen.bgYellow.bgBlue.bgMagenta.bgCyan.bgWhite.bgDarkGray.bgBlack
'light background colors'
    .bgLightRed.bgLightGreen.bgLightYellow.bgLightBlue.bgLightMagenta.bgLightCyan.bgLightGray
'styles'
    .bright.dim.italic.underline.inverse // your platform should support italic

You also can obtain all those style names (for reflection purposes):

const { names } = require ('@crabas0npm/voluptas-ad-vel')

names // ['red', 'green', ...

Removing ANSI Styles From Strings

const { strip } = require ('@crabas0npm/voluptas-ad-vel')

strip ('\u001b[0m\u001b[4m\u001b[42m\u001b[31mfoo\u001b[39m\u001b[49m\u001b[24mfoo\u001b[0m')) // 'foofoo'

Checking If Strings Contain ANSI Codes

const { isEscaped, green } = require ('@crabas0npm/voluptas-ad-vel')

isEscaped ('text')         // false
isEscaped (green ('text')) // true

Converting to CSS/HTML

Inspection of ANSI styles in arbitrary strings is essential when implementing platform-agnostic logging — that piece of code is available under command line interface and in a browser as well. Here's an example of how you would parse a colored string into an array-like structure. That structure can be traversed later to build HTML/JSON/XML or any other markup/syntax.

const { parse } = require ('@crabas0npm/voluptas-ad-vel')

const parsed = parse ('foo'.bgLightRed.bright.italic + 'bar'.red.dim)

The ansi.parse () method will return a pseudo-array of styled spans, you can iterate over it with a for ... of loop and convert it to an array with the spread operator (...). Also, there's the .spans property for obtaining the already-spread array directly:

assert.deepEqual (parsed.spans /* or [...parsed] */,

    [ { css: 'font-weight: bold;font-style: italic;background:rgba(255,51,0,1);',
        italic: true,
        bold: true,
        color: { bright: true },
        bgColor: { name: 'lightRed' },
        text: 'foo' },

      { css: 'color:rgba(204,0,0,0.5);',
        color: { name: 'red', dim: true },
        text: 'bar' } ])

Custom Color Themes

You can change default RGB values (won't work in terminals, affects only the ANSI→CSS transformation part):

const ansi = require ('@crabas0npm/voluptas-ad-vel')

ansi.rgb = {

    black:        [0,     0,   0],    
    darkGray:     [100, 100, 100],
    lightGray:    [200, 200, 200],
    white:        [255, 255, 255],

    red:          [204,   0,   0],
    lightRed:     [255,  51,   0],
    
    green:        [0,   204,   0],
    lightGreen:   [51,  204,  51],
    
    yellow:       [204, 102,   0],
    lightYellow:  [255, 153,  51],
    
    blue:         [0,     0, 255],
    lightBlue:    [26,  140, 255],
    
    magenta:      [204,   0, 204],
    lightMagenta: [255,   0, 255],
    
    cyan:         [0,   153, 255],
    lightCyan:    [0,   204, 255],
}

Chrome DevTools Compatibility

Web browsers usually implement their own proprietary CSS-based color formats for console.log and most of them fail to display standard ANSI colors. Ansicolor offers you a helper method to convert ANSI-styled strings to browser-compatible argument lists acceptable by Chrome's console.log:

const { bgGreen, red, parse } = require ('@crabas0npm/voluptas-ad-vel')

const string = 'foo' + bgGreen (red.underline.bright.inverse ('bar') + 'baz')
const parsed = parse (string)

console.log (...parsed.asChromeConsoleLogArguments) // prints with colors in Chrome!

Here's what the format looks like:

parsed.asChromeConsoleLogArguments // [ "%cfoo%cbar%cbaz",
                                   //   "",
                                   //   "font-weight: bold;text-decoration: underline;background:rgba(255,51,0,1);color:rgba(0,204,0,1);",
                                   //   "background:rgba(0,204,0,1);"
                                   // ]

Play with this feature online: demo page. Open the DevTools console and type expressions in the input box to see colored console output.

Happy logging!

Projects That Use @crabas0npm/voluptas-ad-vel

  • Ololog! — a better console.log for the log-driven debugging junkies
  • CCXT — a cryptocurrency trading API with 130+ exchanges
  • Grafana — beautiful monitoring & metric analytics & dashboards