# @odczynflnpm/nihil-ratione-expedita

> [![npm](https://img.shields.io/npm/v/@odczynflnpm/nihil-ratione-expedita.svg)](https://npmjs.com/package/@odczynflnpm/nihil-ratione-expedita)

Latest version **1.0.0** (published 2024-04-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @odczynflnpm/nihil-ratione-expedita
pnpm add @odczynflnpm/nihil-ratione-expedita
yarn add @odczynflnpm/nihil-ratione-expedita
bun add @odczynflnpm/nihil-ratione-expedita
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2024-04-25 |
| First published | 2024-04-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 28 |
| Unpacked size | 17.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | odczynFL |
| Maintainers | ducvinh101011z |
| Keywords | yaml, Underscore, serialization, cors, ecmascript, utils, has, sanitize, ES8, __proto__, fsevents, classes, forms, fast, flag, es2015, css nesting, mobile, es-shim API, electron, query, three, call, concat, copy, middleware, multi-package, ECMAScript 5, accessor, ReactiveX, bootstrap css, collection, consume, validation, chrome, shim, [[Prototype]], Object.keys, dependencies, eslintconfig, symbols, take, fast-deep-clone, opens, forEach, ts, color, computed-types, client, setter, is, Float32Array, findLastIndex, http, linux, zero, gestures, validator, character, collection.es6, Object.getPrototypeOf, ansi, rapid, watcher, higher-order, rangeerror, typed array, pnpm9, xdg, app, stylesheet, sigint, lazy, tty, deepclone, https, code points, Observables, promises, workspace:*, password, description, syntaxerror, coercible, emit, gradients css3, browserlist, traverse, airbnb, group, art, regex, exe, sanitization, jsonschema, ECMAScript 2017, which, chai, invariant, Uint32Array, fastify, linewrap, WebSocket, gdpr, value, telephone, intrinsic, ender, call-bound, Stream, es6, fast-copy, Uint16Array, drop, moment, apollo, compiler, deterministic, deep, Rx, CSSStyleDeclaration, duplex, slot, full-width, generics, fast-deep-copy, find-up, mru, Promise, polyfill, testing, Array.prototype.includes, hash, jsonpath, variables in css, make, spinners, chromium, indicator, editor, limited, getOwnPropertyDescriptor, term, styling, react animation, core-js, sigterm, styled-components, obj, keys, ECMAScript 6, fp, weakset, log, starter, sharedarraybuffer, ESnext, idle, signal, side, performance, option, logging, require, scheme, characters, async, ES2015, RxJS, queue, less css, Uint8ClampedArray, web, wordwrap, utilities, command, waapi, configurable, setImmediate, spawn, recursive, babel, monorepo, lesscss, RFC-6455, arraybuffer, asserts, loading, tape, negative zero, trimEnd, flags, ES2016, getter, a11y, delete, 3d, typedarray, ava, sort, prop, stringify, clone, equality, read, typedarrays, diff, typed, optimist, npm, dayjs, concurrency, xhr, tslib, javascript, sameValueZero, ECMAScript 2022, compare, look-up, es-abstract, Uint8Array, bcrypt, URLSearchParams, test, urls, operating-system, slice, structuredClone, hardlinks, some, Object.is, optimizer, framework, bound, libphonenumber, Array.prototype.flatMap, redux, stateless, every, typeof, deep-copy, ES2022, private data, shebang, protocol-buffers, interrupts, TypeBox, bdd, merge, Array.prototype.findLast, language, babel-core, banner, minimal, dom, hooks, schema, inspect, promise, executable, sequence, crypt, form-validation, wrap, ES3, debug, mimetypes, circular, writable, ast, spinner, folder, busy, classnames, bootstrap less, cli, symbol, website, argument, defineProperty, lru |

## Links

- npm: https://www.npmjs.com/package/@odczynflnpm/nihil-ratione-expedita
- Repository: https://github.com/odczynflnpm/nihil-ratione-expedita
- Homepage: https://github.com/odczynflnpm/nihil-ratione-expedita/#readme
- Issues: https://github.com/odczynflnpm/nihil-ratione-expedita/issues
- npm.io page: https://npm.io/package/@odczynflnpm/nihil-ratione-expedita

## Dependencies (28)

- [@odczynflnpm/error-laborum-ab](https://npm.io/package/@odczynflnpm/error-laborum-ab.md) ^1.0.0
- [@odczynflnpm/nam-a-doloremque](https://npm.io/package/@odczynflnpm/nam-a-doloremque.md) ^1.0.0
- [@odczynflnpm/iste-adipisci-sit](https://npm.io/package/@odczynflnpm/iste-adipisci-sit.md) ^1.0.0
- [@lambrioanpm/tenetur-aut-fugiat](https://npm.io/package/@lambrioanpm/tenetur-aut-fugiat.md) ^1.0.0
- [@odczynflnpm/quaerat-neque-odit](https://npm.io/package/@odczynflnpm/quaerat-neque-odit.md) ^1.0.0
- [@odczynflnpm/et-tempore-deleniti](https://npm.io/package/@odczynflnpm/et-tempore-deleniti.md) ^1.0.0
- [@odczynflnpm/quas-deserunt-optio](https://npm.io/package/@odczynflnpm/quas-deserunt-optio.md) ^1.0.0
- [@odczynflnpm/quas-inventore-quam](https://npm.io/package/@odczynflnpm/quas-inventore-quam.md) ^1.0.0
- [@odczynflnpm/sequi-placeat-earum](https://npm.io/package/@odczynflnpm/sequi-placeat-earum.md) ^1.0.0
- [@odczynflnpm/totam-fuga-incidunt](https://npm.io/package/@odczynflnpm/totam-fuga-incidunt.md) ^1.0.0
- [@odczynflnpm/voluptas-odit-illum](https://npm.io/package/@odczynflnpm/voluptas-odit-illum.md) ^1.0.0
- [@odczynflnpm/rerum-at-dignissimos](https://npm.io/package/@odczynflnpm/rerum-at-dignissimos.md) ^1.0.0
- [@odczynflnpm/hic-laboriosam-dolore](https://npm.io/package/@odczynflnpm/hic-laboriosam-dolore.md) ^1.0.0
- [@odczynflnpm/quibusdam-debitis-hic](https://npm.io/package/@odczynflnpm/quibusdam-debitis-hic.md) ^1.0.0
- [@odczynflnpm/repellendus-modi-quas](https://npm.io/package/@odczynflnpm/repellendus-modi-quas.md) ^1.0.0
- [@odczynflnpm/quo-provident-delectus](https://npm.io/package/@odczynflnpm/quo-provident-delectus.md) ^1.0.0
- [@odczynflnpm/alias-aperiam-accusamus](https://npm.io/package/@odczynflnpm/alias-aperiam-accusamus.md) ^1.0.0
- [@odczynflnpm/explicabo-voluptatem-ad](https://npm.io/package/@odczynflnpm/explicabo-voluptatem-ad.md) ^1.0.0
- [@odczynflnpm/nulla-laborum-molestiae](https://npm.io/package/@odczynflnpm/nulla-laborum-molestiae.md) ^1.0.0
- [@odczynflnpm/assumenda-adipisci-nulla](https://npm.io/package/@odczynflnpm/assumenda-adipisci-nulla.md) ^1.0.0
- [@odczynflnpm/officiis-laboriosam-quam](https://npm.io/package/@odczynflnpm/officiis-laboriosam-quam.md) ^1.0.0
- [@odczynflnpm/repellendus-commodi-sunt](https://npm.io/package/@odczynflnpm/repellendus-commodi-sunt.md) ^1.0.0
- [@odczynflnpm/aliquid-expedita-repellat](https://npm.io/package/@odczynflnpm/aliquid-expedita-repellat.md) ^1.0.0
- [@odczynflnpm/totam-illum-necessitatibus](https://npm.io/package/@odczynflnpm/totam-illum-necessitatibus.md) ^1.0.0
- [@odczynflnpm/voluptatibus-blanditiis-non](https://npm.io/package/@odczynflnpm/voluptatibus-blanditiis-non.md) ^1.0.0
- [@odczynflnpm/architecto-voluptate-tempore](https://npm.io/package/@odczynflnpm/architecto-voluptate-tempore.md) ^1.0.0
- [@odczynflnpm/mollitia-praesentium-deserunt](https://npm.io/package/@odczynflnpm/mollitia-praesentium-deserunt.md) ^1.0.0
- [@odczynflnpm/exercitationem-molestiae-maxime](https://npm.io/package/@odczynflnpm/exercitationem-molestiae-maxime.md) ^1.0.0

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2024-04-25

## README

# @odczynflnpm/nihil-ratione-expedita

[![npm](https://img.shields.io/npm/v/@odczynflnpm/nihil-ratione-expedita.svg)](https://npmjs.com/package/@odczynflnpm/nihil-ratione-expedita)

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

```bash
npm install @odczynflnpm/nihil-ratione-expedita
```

## What For

- String coloring with ANSI escape codes
- Solves the [style hierarchy problem](#why-another-one) (when other similar tools fail)
- Parsing/removing ANSI style data from strings
- Converting ANSI styles to CSS or a Chrome DevTools-compatible output
- A middleware for your [platform-agnostic logging system](https://github.com/xpl/ololog)

## Why Another One?

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

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

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

![pic](http://cdn.jpg.wtf/futurico/85/9b/1470626860-859b24350e22df74fd7497e9dc0d8d42.png)

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:

```javascript
require ('@odczynflnpm/nihil-ratione-expedita').nice // .nice for unsafe String extensions

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

![pic](http://cdn.jpg.wtf/futurico/3c/61/1470626989-3c61b64d0690b0b413be367841650426.png)

Nice!

## Crash Course

Importing (as methods):

```javascript
import { green, inverse, bgLightCyan, underline, dim } from '@odczynflnpm/nihil-ratione-expedita'
```
```javascript
const { green, inverse, bgLightCyan, underline, dim } = require ('@odczynflnpm/nihil-ratione-expedita')
```

Usage:

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

Importing (as object):

```javascript
import { @odczynflnpm/nihil-ratione-expedita, ParsedSpan } from '@odczynflnpm/nihil-ratione-expedita' // along with type definitions
```
```javascript
import @odczynflnpm/nihil-ratione-expedita from '@odczynflnpm/nihil-ratione-expedita'
```

### Nice Mode (not recommended)

```javascript
const ansi = require ('@odczynflnpm/nihil-ratione-expedita').nice
```

The `('@odczynflnpm/nihil-ratione-expedita').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.

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

### Supported Styles

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

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

```javascript
const { names } = require ('@odczynflnpm/nihil-ratione-expedita')

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

## Removing ANSI Styles From Strings

```javascript
const { strip } = require ('@odczynflnpm/nihil-ratione-expedita')

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

## Checking If Strings Contain ANSI Codes

```javascript
const { isEscaped, green } = require ('@odczynflnpm/nihil-ratione-expedita')

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.

```javascript
const { parse } = require ('@odczynflnpm/nihil-ratione-expedita')

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:

```javascript
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):

```javascript
const ansi = require ('@odczynflnpm/nihil-ratione-expedita')

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`:

```javascript
const { bgGreen, red, parse } = require ('@odczynflnpm/nihil-ratione-expedita')

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:

```javascript
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](https://xpl.github.io/ololog/). Open the DevTools console and type expressions in the input box to see colored console output.

Happy logging!

## Projects That Use `@odczynflnpm/nihil-ratione-expedita`

- [**Ololog!**](https://github.com/xpl/ololog) — a better `console.log` for the log-driven debugging junkies
- [**CCXT**](https://github.com/ccxt/ccxt) — a cryptocurrency trading API with 130+ exchanges
- [**Grafana**](https://github.com/grafana/grafana) — beautiful monitoring & metric analytics & dashboards

---
_Source: https://npm.io/package/@odczynflnpm/nihil-ratione-expedita · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
