Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

figures

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

figures - npm Package Compare versions

Comparing version 3.2.0 to 4.0.0

255

index.d.ts
declare const figureSet: {
readonly tick: string;
readonly info: string;
readonly warning: string;
readonly cross: string;
readonly star: string;
readonly square: string;
readonly squareSmall: string;
readonly squareSmallFilled: string;
readonly play: string;
readonly squareDarkShade: string;
readonly squareMediumShade: string;
readonly squareLightShade: string;
readonly squareTop: string;
readonly squareBottom: string;
readonly squareLeft: string;
readonly squareRight: string;
readonly squareCenter: string;
readonly circle: string;

@@ -17,10 +25,26 @@ readonly circleFilled: string;

readonly circleQuestionMark: string;
readonly radioOn: string;
readonly radioOff: string;
readonly checkboxOn: string;
readonly checkboxOff: string;
readonly checkboxCircleOn: string;
readonly checkboxCircleOff: string;
readonly questionMarkPrefix: string;
readonly bullet: string;
readonly dot: string;
readonly line: string;
readonly ellipsis: string;
readonly pointer: string;
readonly pointerSmall: string;
readonly info: string;
readonly warning: string;
readonly triangleUp: string;
readonly triangleUpSmall: string;
readonly triangleUpOutline: string;
readonly triangleDown: string;
readonly triangleDownSmall: string;
readonly triangleLeft: string;
readonly triangleLeftSmall: string;
readonly triangleRight: string;
readonly triangleRightSmall: string;
readonly lozenge: string;
readonly lozengeOutline: string;
readonly home: string;
readonly hamburger: string;

@@ -30,2 +54,6 @@ readonly smiley: string;

readonly heart: string;
readonly star: string;
readonly play: string;
readonly musicNote: string;
readonly musicNoteBeamed: string;
readonly nodejs: string;

@@ -36,9 +64,20 @@ readonly arrowUp: string;

readonly arrowRight: string;
readonly radioOn: string;
readonly radioOff: string;
readonly checkboxOn: string;
readonly checkboxOff: string;
readonly checkboxCircleOn: string;
readonly checkboxCircleOff: string;
readonly questionMarkPrefix: string;
readonly arrowLeftRight: string;
readonly arrowUpDown: string;
readonly almostEqual: string;
readonly notEqual: string;
readonly lessOrEqual: string;
readonly greaterOrEqual: string;
readonly identical: string;
readonly infinity: string;
readonly subscriptZero: string;
readonly subscriptOne: string;
readonly subscriptTwo: string;
readonly subscriptThree: string;
readonly subscriptFour: string;
readonly subscriptFive: string;
readonly subscriptSix: string;
readonly subscriptSeven: string;
readonly subscriptEight: string;
readonly subscriptNine: string;
readonly oneHalf: string;

@@ -62,39 +101,173 @@ readonly oneThird: string;

readonly sevenEighth: string;
}
readonly line: string;
readonly lineBold: string;
readonly lineDouble: string;
readonly lineDashed0: string;
readonly lineDashed1: string;
readonly lineDashed2: string;
readonly lineDashed3: string;
readonly lineDashed4: string;
readonly lineDashed5: string;
readonly lineDashed6: string;
readonly lineDashed7: string;
readonly lineDashed8: string;
readonly lineDashed9: string;
readonly lineDashed10: string;
readonly lineDashed11: string;
readonly lineDashed12: string;
readonly lineDashed13: string;
readonly lineDashed14: string;
readonly lineDashed15: string;
readonly lineVertical: string;
readonly lineVerticalBold: string;
readonly lineVerticalDouble: string;
readonly lineVerticalDashed0: string;
readonly lineVerticalDashed1: string;
readonly lineVerticalDashed2: string;
readonly lineVerticalDashed3: string;
readonly lineVerticalDashed4: string;
readonly lineVerticalDashed5: string;
readonly lineVerticalDashed6: string;
readonly lineVerticalDashed7: string;
readonly lineVerticalDashed8: string;
readonly lineVerticalDashed9: string;
readonly lineVerticalDashed10: string;
readonly lineVerticalDashed11: string;
readonly lineDownLeft: string;
readonly lineDownLeftArc: string;
readonly lineDownBoldLeftBold: string;
readonly lineDownBoldLeft: string;
readonly lineDownLeftBold: string;
readonly lineDownDoubleLeftDouble: string;
readonly lineDownDoubleLeft: string;
readonly lineDownLeftDouble: string;
readonly lineDownRight: string;
readonly lineDownRightArc: string;
readonly lineDownBoldRightBold: string;
readonly lineDownBoldRight: string;
readonly lineDownRightBold: string;
readonly lineDownDoubleRightDouble: string;
readonly lineDownDoubleRight: string;
readonly lineDownRightDouble: string;
readonly lineUpLeft: string;
readonly lineUpLeftArc: string;
readonly lineUpBoldLeftBold: string;
readonly lineUpBoldLeft: string;
readonly lineUpLeftBold: string;
readonly lineUpDoubleLeftDouble: string;
readonly lineUpDoubleLeft: string;
readonly lineUpLeftDouble: string;
readonly lineUpRight: string;
readonly lineUpRightArc: string;
readonly lineUpBoldRightBold: string;
readonly lineUpBoldRight: string;
readonly lineUpRightBold: string;
readonly lineUpDoubleRightDouble: string;
readonly lineUpDoubleRight: string;
readonly lineUpRightDouble: string;
readonly lineUpDownLeft: string;
readonly lineUpBoldDownBoldLeftBold: string;
readonly lineUpBoldDownBoldLeft: string;
readonly lineUpDownLeftBold: string;
readonly lineUpBoldDownLeftBold: string;
readonly lineUpDownBoldLeftBold: string;
readonly lineUpDownBoldLeft: string;
readonly lineUpBoldDownLeft: string;
readonly lineUpDoubleDownDoubleLeftDouble: string;
readonly lineUpDoubleDownDoubleLeft: string;
readonly lineUpDownLeftDouble: string;
readonly lineUpDownRight: string;
readonly lineUpBoldDownBoldRightBold: string;
readonly lineUpBoldDownBoldRight: string;
readonly lineUpDownRightBold: string;
readonly lineUpBoldDownRightBold: string;
readonly lineUpDownBoldRightBold: string;
readonly lineUpDownBoldRight: string;
readonly lineUpBoldDownRight: string;
readonly lineUpDoubleDownDoubleRightDouble: string;
readonly lineUpDoubleDownDoubleRight: string;
readonly lineUpDownRightDouble: string;
readonly lineDownLeftRight: string;
readonly lineDownBoldLeftBoldRightBold: string;
readonly lineDownLeftBoldRightBold: string;
readonly lineDownBoldLeftRight: string;
readonly lineDownBoldLeftBoldRight: string;
readonly lineDownBoldLeftRightBold: string;
readonly lineDownLeftRightBold: string;
readonly lineDownLeftBoldRight: string;
readonly lineDownDoubleLeftDoubleRightDouble: string;
readonly lineDownDoubleLeftRight: string;
readonly lineDownLeftDoubleRightDouble: string;
readonly lineUpLeftRight: string;
readonly lineUpBoldLeftBoldRightBold: string;
readonly lineUpLeftBoldRightBold: string;
readonly lineUpBoldLeftRight: string;
readonly lineUpBoldLeftBoldRight: string;
readonly lineUpBoldLeftRightBold: string;
readonly lineUpLeftRightBold: string;
readonly lineUpLeftBoldRight: string;
readonly lineUpDoubleLeftDoubleRightDouble: string;
readonly lineUpDoubleLeftRight: string;
readonly lineUpLeftDoubleRightDouble: string;
readonly lineUpDownLeftRight: string;
readonly lineUpBoldDownBoldLeftBoldRightBold: string;
readonly lineUpDownBoldLeftBoldRightBold: string;
readonly lineUpBoldDownLeftBoldRightBold: string;
readonly lineUpBoldDownBoldLeftRightBold: string;
readonly lineUpBoldDownBoldLeftBoldRight: string;
readonly lineUpBoldDownLeftRight: string;
readonly lineUpDownBoldLeftRight: string;
readonly lineUpDownLeftBoldRight: string;
readonly lineUpDownLeftRightBold: string;
readonly lineUpBoldDownBoldLeftRight: string;
readonly lineUpDownLeftBoldRightBold: string;
readonly lineUpBoldDownLeftBoldRight: string;
readonly lineUpBoldDownLeftRightBold: string;
readonly lineUpDownBoldLeftBoldRight: string;
readonly lineUpDownBoldLeftRightBold: string;
readonly lineUpDoubleDownDoubleLeftDoubleRightDouble: string;
readonly lineUpDoubleDownDoubleLeftRight: string;
readonly lineUpDownLeftDoubleRightDouble: string;
readonly lineCross: string;
readonly lineBackslash: string;
readonly lineSlash: string;
};
type FigureSet = typeof figureSet
type FigureSet = typeof figureSet;
declare const figures: {
/**
Replace Unicode symbols depending on the OS.
/**
Symbols to use when the terminal supports Unicode symbols.
*/
export const mainSymbols: FigureSet;
@param string - String where the Unicode symbols will be replaced with fallback symbols depending on the OS.
@returns The input with replaced fallback Unicode symbols on Windows.
/**
Symbols to use when the terminal does not support Unicode symbols.
*/
export const fallbackSymbols: FigureSet;
@example
```
import figures = require('figures');
/**
Symbols to use on any terminal.
*/
export default figureSet;
console.log(figures('✔︎ check'));
// On non-Windows OSes: ✔︎ check
// On Windows: √ check
/**
Replace Unicode symbols depending on the terminal.
console.log(figures.tick);
// On non-Windows OSes: ✔︎
// On Windows: √
```
*/
(string: string): string;
@param string - String where the Unicode symbols will be replaced with fallback symbols depending on the terminal.
@returns The input with replaced fallback Unicode symbols.
/**
Symbols to use when not running on Windows.
*/
readonly main: FigureSet;
@example
```
import figures, {replaceSymbols} from 'figures';
/**
Symbols to use when running on Windows.
*/
readonly windows: FigureSet;
} & FigureSet;
console.log(replaceSymbols('✔︎ check'));
// On terminals with Unicode symbols: ✔︎ check
// On other terminals: √ check
export = figures;
console.log(figures.tick);
// On terminals with Unicode symbols: ✔︎
// On other terminals: √
```
*/
export function replaceSymbols(string: string): string;

356

index.js

@@ -1,35 +0,30 @@

'use strict';
const escapeStringRegexp = require('escape-string-regexp');
import escapeStringRegexp from 'escape-string-regexp';
import isUnicodeSupported from 'is-unicode-supported';
const {platform} = process;
const main = {
tick: '✔',
cross: '✖',
star: '★',
square: '▇',
squareSmall: '◻',
squareSmallFilled: '◼',
play: '▶',
circle: '◯',
circleFilled: '◉',
circleDotted: '◌',
circleDouble: '◎',
circleCircle: 'ⓞ',
circleCross: 'ⓧ',
circlePipe: 'Ⓘ',
circleQuestionMark: '?⃝',
const common = {
square: '█',
squareDarkShade: '▓',
squareMediumShade: '▒',
squareLightShade: '░',
squareTop: '▀',
squareBottom: '▄',
squareLeft: '▌',
squareRight: '▐',
squareCenter: '■',
bullet: '●',
dot: '․',
line: '─',
ellipsis: '…',
pointer: '❯',
pointerSmall: '›',
info: 'ℹ',
warning: '⚠',
hamburger: '☰',
smiley: '㋡',
mustache: '෴',
triangleUp: '▲',
triangleUpSmall: '▴',
triangleDown: '▼',
triangleDownSmall: '▾',
triangleLeftSmall: '◂',
triangleRightSmall: '▸',
home: '⌂',
heart: '♥',
nodejs: '⬢',
musicNote: '♪',
musicNoteBeamed: '♫',
arrowUp: '↑',

@@ -39,9 +34,20 @@ arrowDown: '↓',

arrowRight: '→',
radioOn: '◉',
radioOff: '◯',
checkboxOn: '☒',
checkboxOff: '☐',
checkboxCircleOn: 'ⓧ',
checkboxCircleOff: 'Ⓘ',
questionMarkPrefix: '?⃝',
arrowLeftRight: '↔',
arrowUpDown: '↕',
almostEqual: '≈',
notEqual: '≠',
lessOrEqual: '≤',
greaterOrEqual: '≥',
identical: '≡',
infinity: '∞',
subscriptZero: '₀',
subscriptOne: '₁',
subscriptTwo: '₂',
subscriptThree: '₃',
subscriptFour: '₄',
subscriptFive: '₅',
subscriptSix: '₆',
subscriptSeven: '₇',
subscriptEight: '₈',
subscriptNine: '₉',
oneHalf: '½',

@@ -52,6 +58,3 @@ oneThird: '⅓',

oneSixth: '⅙',
oneSeventh: '⅐',
oneEighth: '⅛',
oneNinth: '⅑',
oneTenth: '⅒',
twoThirds: '⅔',

@@ -65,13 +68,195 @@ twoFifths: '⅖',

fiveEighths: '⅝',
sevenEighths: '⅞'
sevenEighths: '⅞',
line: '─',
lineBold: '━',
lineDouble: '═',
lineDashed0: '┄',
lineDashed1: '┅',
lineDashed2: '┈',
lineDashed3: '┉',
lineDashed4: '╌',
lineDashed5: '╍',
lineDashed6: '╴',
lineDashed7: '╶',
lineDashed8: '╸',
lineDashed9: '╺',
lineDashed10: '╼',
lineDashed11: '╾',
lineDashed12: '−',
lineDashed13: '–',
lineDashed14: '‐',
lineDashed15: '⁃',
lineVertical: '│',
lineVerticalBold: '┃',
lineVerticalDouble: '║',
lineVerticalDashed0: '┆',
lineVerticalDashed1: '┇',
lineVerticalDashed2: '┊',
lineVerticalDashed3: '┋',
lineVerticalDashed4: '╎',
lineVerticalDashed5: '╏',
lineVerticalDashed6: '╵',
lineVerticalDashed7: '╷',
lineVerticalDashed8: '╹',
lineVerticalDashed9: '╻',
lineVerticalDashed10: '╽',
lineVerticalDashed11: '╿',
lineDownLeft: '┐',
lineDownLeftArc: '╮',
lineDownBoldLeftBold: '┓',
lineDownBoldLeft: '┒',
lineDownLeftBold: '┑',
lineDownDoubleLeftDouble: '╗',
lineDownDoubleLeft: '╖',
lineDownLeftDouble: '╕',
lineDownRight: '┌',
lineDownRightArc: '╭',
lineDownBoldRightBold: '┏',
lineDownBoldRight: '┎',
lineDownRightBold: '┍',
lineDownDoubleRightDouble: '╔',
lineDownDoubleRight: '╓',
lineDownRightDouble: '╒',
lineUpLeft: '┘',
lineUpLeftArc: '╯',
lineUpBoldLeftBold: '┛',
lineUpBoldLeft: '┚',
lineUpLeftBold: '┙',
lineUpDoubleLeftDouble: '╝',
lineUpDoubleLeft: '╜',
lineUpLeftDouble: '╛',
lineUpRight: '└',
lineUpRightArc: '╰',
lineUpBoldRightBold: '┗',
lineUpBoldRight: '┖',
lineUpRightBold: '┕',
lineUpDoubleRightDouble: '╚',
lineUpDoubleRight: '╙',
lineUpRightDouble: '╘',
lineUpDownLeft: '┤',
lineUpBoldDownBoldLeftBold: '┫',
lineUpBoldDownBoldLeft: '┨',
lineUpDownLeftBold: '┥',
lineUpBoldDownLeftBold: '┩',
lineUpDownBoldLeftBold: '┪',
lineUpDownBoldLeft: '┧',
lineUpBoldDownLeft: '┦',
lineUpDoubleDownDoubleLeftDouble: '╣',
lineUpDoubleDownDoubleLeft: '╢',
lineUpDownLeftDouble: '╡',
lineUpDownRight: '├',
lineUpBoldDownBoldRightBold: '┣',
lineUpBoldDownBoldRight: '┠',
lineUpDownRightBold: '┝',
lineUpBoldDownRightBold: '┡',
lineUpDownBoldRightBold: '┢',
lineUpDownBoldRight: '┟',
lineUpBoldDownRight: '┞',
lineUpDoubleDownDoubleRightDouble: '╠',
lineUpDoubleDownDoubleRight: '╟',
lineUpDownRightDouble: '╞',
lineDownLeftRight: '┬',
lineDownBoldLeftBoldRightBold: '┳',
lineDownLeftBoldRightBold: '┯',
lineDownBoldLeftRight: '┰',
lineDownBoldLeftBoldRight: '┱',
lineDownBoldLeftRightBold: '┲',
lineDownLeftRightBold: '┮',
lineDownLeftBoldRight: '┭',
lineDownDoubleLeftDoubleRightDouble: '╦',
lineDownDoubleLeftRight: '╥',
lineDownLeftDoubleRightDouble: '╤',
lineUpLeftRight: '┴',
lineUpBoldLeftBoldRightBold: '┻',
lineUpLeftBoldRightBold: '┷',
lineUpBoldLeftRight: '┸',
lineUpBoldLeftBoldRight: '┹',
lineUpBoldLeftRightBold: '┺',
lineUpLeftRightBold: '┶',
lineUpLeftBoldRight: '┵',
lineUpDoubleLeftDoubleRightDouble: '╩',
lineUpDoubleLeftRight: '╨',
lineUpLeftDoubleRightDouble: '╧',
lineUpDownLeftRight: '┼',
lineUpBoldDownBoldLeftBoldRightBold: '╋',
lineUpDownBoldLeftBoldRightBold: '╈',
lineUpBoldDownLeftBoldRightBold: '╇',
lineUpBoldDownBoldLeftRightBold: '╊',
lineUpBoldDownBoldLeftBoldRight: '╉',
lineUpBoldDownLeftRight: '╀',
lineUpDownBoldLeftRight: '╁',
lineUpDownLeftBoldRight: '┽',
lineUpDownLeftRightBold: '┾',
lineUpBoldDownBoldLeftRight: '╂',
lineUpDownLeftBoldRightBold: '┿',
lineUpBoldDownLeftBoldRight: '╃',
lineUpBoldDownLeftRightBold: '╄',
lineUpDownBoldLeftBoldRight: '╅',
lineUpDownBoldLeftRightBold: '╆',
lineUpDoubleDownDoubleLeftDoubleRightDouble: '╬',
lineUpDoubleDownDoubleLeftRight: '╫',
lineUpDownLeftDoubleRightDouble: '╪',
lineCross: '╳',
lineBackslash: '╲',
lineSlash: '╱'
};
const windows = {
export const mainSymbols = {
...common,
// The main symbols for those do not look that good on Ubuntu.
...(
platform === 'linux' ?
{
circleQuestionMark: '?⃝',
questionMarkPrefix: '?⃝'
} :
{
circleQuestionMark: '?',
questionMarkPrefix: '?'
}
),
tick: '✔',
info: 'ℹ',
warning: '⚠',
cross: '✖',
squareSmall: '◻',
squareSmallFilled: '◼',
circle: '◯',
circleFilled: '◉',
circleDotted: '◌',
circleDouble: '◎',
circleCircle: 'ⓞ',
circleCross: 'ⓧ',
circlePipe: 'Ⓘ',
radioOn: '◉',
radioOff: '◯',
checkboxOn: '☒',
checkboxOff: '☐',
checkboxCircleOn: 'ⓧ',
checkboxCircleOff: 'Ⓘ',
pointer: '❯',
triangleUpOutline: '△',
triangleLeft: '◀',
triangleRight: '▶',
lozenge: '◆',
lozengeOutline: '◇',
hamburger: '☰',
smiley: '㋡',
mustache: '෴',
star: '★',
play: '▶',
nodejs: '⬢',
oneSeventh: '⅐',
oneNinth: '⅑',
oneTenth: '⅒'
};
export const fallbackSymbols = {
...common,
tick: '√',
info: 'i',
warning: '‼',
cross: '×',
star: '*',
square: '█',
squareSmall: '[ ]',
squareSmallFilled: '[█]',
play: '►',
squareSmall: '□',
squareSmallFilled: '■',
circle: '( )',

@@ -85,19 +270,2 @@ circleFilled: '(*)',

circleQuestionMark: '(?)',
bullet: '*',
dot: '.',
line: '─',
ellipsis: '...',
pointer: '>',
pointerSmall: '»',
info: 'i',
warning: '‼',
hamburger: '≡',
smiley: '☺',
mustache: '┌─┐',
heart: main.heart,
nodejs: '♦',
arrowUp: main.arrowUp,
arrowDown: main.arrowDown,
arrowLeft: main.arrowLeft,
arrowRight: main.arrowRight,
radioOn: '(*)',

@@ -110,47 +278,49 @@ radioOff: '( )',

questionMarkPrefix: '?',
oneHalf: '1/2',
oneThird: '1/3',
oneQuarter: '1/4',
oneFifth: '1/5',
oneSixth: '1/6',
pointer: '>',
triangleUpOutline: '∆',
triangleLeft: '◄',
triangleRight: '►',
lozenge: '♦',
lozengeOutline: '◊',
hamburger: '≡',
smiley: '☺',
mustache: '┌─┐',
star: '✶',
play: '►',
nodejs: '♦',
oneSeventh: '1/7',
oneEighth: '1/8',
oneNinth: '1/9',
oneTenth: '1/10',
twoThirds: '2/3',
twoFifths: '2/5',
threeQuarters: '3/4',
threeFifths: '3/5',
threeEighths: '3/8',
fourFifths: '4/5',
fiveSixths: '5/6',
fiveEighths: '5/8',
sevenEighths: '7/8'
oneTenth: '1/10'
};
if (platform === 'linux') {
// The main one doesn't look that good on Ubuntu.
main.questionMarkPrefix = '?';
}
const shouldUseMain = isUnicodeSupported();
const figures = shouldUseMain ? mainSymbols : fallbackSymbols;
export default figures;
const figures = platform === 'win32' ? windows : main;
const isFallbackSymbol = (key, mainSymbol) => fallbackSymbols[key] !== mainSymbol;
const getFigureRegExp = (key, mainSymbol) => [new RegExp(escapeStringRegexp(mainSymbol), 'g'), fallbackSymbols[key]];
const fn = string => {
if (figures === main) {
return string;
let replacements = [];
const getReplacements = () => {
if (replacements.length > 0) {
return replacements;
}
for (const [key, value] of Object.entries(main)) {
if (value === figures[key]) {
continue;
}
replacements = Object.entries(mainSymbols)
.filter(([key, mainSymbol]) => isFallbackSymbol(key, mainSymbol))
.map(([key, mainSymbol]) => getFigureRegExp(key, mainSymbol));
return replacements;
};
string = string.replace(new RegExp(escapeStringRegexp(value), 'g'), figures[key]);
// On terminals which do not support Unicode symbols, substitute them to other symbols
export const replaceSymbols = string => {
if (shouldUseMain) {
return string;
}
for (const [figureRegExp, fallbackSymbol] of getReplacements()) {
string = string.replace(figureRegExp, fallbackSymbol);
}
return string;
};
module.exports = Object.assign(fn, figures);
module.exports.main = main;
module.exports.windows = windows;
{
"name": "figures",
"version": "3.2.0",
"description": "Unicode symbols with Windows CMD fallbacks",
"version": "4.0.0",
"description": "Unicode symbols with fallbacks for older terminals",
"license": "MIT",

@@ -13,8 +13,9 @@ "repository": "sindresorhus/figures",

},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=12"
},
"scripts": {
"test": "xo && ava && tsd",
"make": "./makefile.js"
"test": "xo && ava && tsd"
},

@@ -38,10 +39,11 @@ "files": [

"dependencies": {
"escape-string-regexp": "^1.0.5"
"escape-string-regexp": "^5.0.0",
"is-unicode-supported": "^1.0.0"
},
"devDependencies": {
"ava": "^1.4.1",
"markdown-table": "^1.1.2",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^3.15.0",
"tsd": "^0.17.0",
"typescript": "^4.3.5",
"xo": "^0.40.3"
}
}

@@ -1,4 +0,4 @@

# figures [![Build Status](https://travis-ci.org/sindresorhus/figures.svg?branch=master)](https://travis-ci.org/sindresorhus/figures)
# figures
> Unicode symbols with Windows CMD fallbacks
> Unicode symbols with fallbacks for older terminals

@@ -9,3 +9,3 @@ [![](screenshot.png)](index.js)

Windows CMD only supports a [limited character set](http://en.wikipedia.org/wiki/Code_page_437).
Terminals such as Windows Console Host (and CMD) only support a [limited character set](http://en.wikipedia.org/wiki/Code_page_437).

@@ -20,20 +20,18 @@ ## Install

See the [source](index.js) for supported symbols.
```js
const figures = require('figures');
import figures, {replaceSymbols, mainSymbols, fallbackSymbols} from 'figures';
console.log(figures('✔︎ check'));
// On non-Windows OSes: ✔︎ check
// On Windows: √ check
console.log(figures.tick);
// On non-Windows OSes: ✔︎
// On Windows: √
// On terminals with Unicode symbols: ✔︎
// On other terminals: √
console.log(figures.main.tick);
// On all OSes: ✔︎
console.log(figures.mainSymbols.tick);
// On all terminals: ✔︎
console.log(figures.windows.tick);
// On all OSes: √
console.log(figures.fallbackSymbols.tick);
// On all terminal: √
console.log(figures.replaceSymbols('✔︎ check'));
// On terminals with Unicode symbols: ✔︎ check
// On other terminals: √ check
```

@@ -43,8 +41,22 @@

### figures(string)
### figures (default export)
Returns the input with replaced fallback Unicode symbols on Windows.
Type: `object`
All the below [figures](#figures) are attached to the main export as shown in the example above.
Symbols to use on any terminal.
### mainSymbols
Symbols to use when the terminal supports Unicode symbols.
### fallbackSymbols
Symbols to use when the terminal does not support Unicode symbols.
### replaceSymbols(string)
Returns the input with replaced fallback Unicode symbols on older terminals.
All the below [figures](#figures) are attached to the default export as shown in the example above.
#### string

@@ -54,76 +66,254 @@

String where the Unicode symbols will be replaced with fallback symbols depending on the OS.
String where the Unicode symbols will be replaced with fallback symbols depending on the terminal.
### figures.main
Symbols to use when not running on Windows.
## Figures
### figures.windows
`Fallback` characters are only shown when they differ from the `Main` ones.
Symbols to use when running on Windows.
| Name | Main | Fallback |
| ------------------------------------------- | :--: | :------: |
| tick | `✔` | `√` |
| info | `ℹ` | `i` |
| warning | `⚠` | `‼` |
| cross | `✖` | `×` |
| square | `█` | |
| squareSmall | `◻` | `□` |
| squareSmallFilled | `◼` | `■` |
| squareDarkShade | `▓` | |
| squareMediumShade | `▒` | |
| squareLightShade | `░` | |
| squareTop | `▀` | |
| squareBottom | `▄` | |
| squareLeft | `▌` | |
| squareRight | `▐` | |
| squareCenter | `■` | |
| circle | `◯` | `( )` |
| circleFilled | `◉` | `(*)` |
| circleDotted | `◌` | `( )` |
| circleDouble | `◎` | `( )` |
| circleCircle | `ⓞ` | `(○)` |
| circleCross | `ⓧ` | `(×)` |
| circlePipe | `Ⓘ` | `(│)` |
| circleQuestionMark | `?⃝ ` | `(?)` |
| radioOn | `◉` | `(*)` |
| radioOff | `◯` | `( )` |
| checkboxOn | `☒` | `[×]` |
| checkboxOff | `☐` | `[ ]` |
| checkboxCircleOn | `ⓧ` | `(×)` |
| checkboxCircleOff | `Ⓘ` | `( )` |
| questionMarkPrefix | `?⃝ ` | `?` |
| bullet | `●` | |
| dot | `․` | |
| ellipsis | `…` | |
| pointer | `❯` | `>` |
| pointerSmall | `›` | `›` |
| triangleUp | `▲` | |
| triangleUpSmall | `▴` | |
| triangleUpOutline | `△` | `∆` |
| triangleDown | `▼` | |
| triangleDownSmall | `▾` | |
| triangleLeft | `◀` | `◄` |
| triangleLeftSmall | `◂` | |
| triangleRight | `▶` | `►` |
| triangleRightSmall | `▸` | |
| lozenge | `◆` | `♦` |
| lozengeOutline | `◇` | `◊` |
| home | `⌂` | |
| hamburger | `☰` | `≡` |
| smiley | `㋡` | `☺` |
| mustache | `෴` | `┌─┐` |
| heart | `♥` | |
| star | `★` | `✶` |
| play | `▶` | `►` |
| musicNote | `♪` | |
| musicNoteBeamed | `♫` | |
| nodejs | `⬢` | `♦` |
| arrowUp | `↑` | |
| arrowDown | `↓` | |
| arrowLeft | `←` | |
| arrowRight | `→` | |
| arrowLeftRight | `↔` | |
| arrowUpDown | `↕` | |
| almostEqual | `≈` | |
| notEqual | `≠` | |
| lessOrEqual | `≤` | |
| greaterOrEqual | `≥` | |
| identical | `≡` | |
| infinity | `∞` | |
| subscriptZero | `₀` | |
| subscriptOne | `₁` | |
| subscriptTwo | `₂` | |
| subscriptThree | `₃` | |
| subscriptFour | `₄` | |
| subscriptFive | `₅` | |
| subscriptSix | `₆` | |
| subscriptSeven | `₇` | |
| subscriptEight | `₈` | |
| subscriptNine | `₉` | |
| oneHalf | `½` | |
| oneThird | `⅓` | |
| oneQuarter | `¼` | |
| oneFifth | `⅕` | |
| oneSixth | `⅙` | |
| oneSeventh | `⅐` | `1/7` |
| oneEighth | `⅛` | |
| oneNinth | `⅑` | `1/9` |
| oneTenth | `⅒` | `1/10` |
| twoThirds | `⅔` | |
| twoFifths | `⅖` | |
| threeQuarters | `¾` | |
| threeFifths | `⅗` | |
| threeEighths | `⅜` | |
| fourFifths | `⅘` | |
| fiveSixths | `⅚` | |
| fiveEighths | `⅝` | |
| sevenEighths | `⅞` | |
| line | `─` | |
| lineBold | `━` | |
| lineDouble | `═` | |
| lineDashed0 | `┄` | |
| lineDashed1 | `┅` | |
| lineDashed2 | `┈` | |
| lineDashed3 | `┉` | |
| lineDashed4 | `╌` | |
| lineDashed5 | `╍` | |
| lineDashed6 | `╴` | |
| lineDashed7 | `╶` | |
| lineDashed8 | `╸` | |
| lineDashed9 | `╺` | |
| lineDashed10 | `╼` | |
| lineDashed11 | `╾` | |
| lineDashed12 | `−` | |
| lineDashed13 | `–` | |
| lineDashed14 | `‐` | |
| lineDashed15 | `⁃` | |
| lineVertical | `│` | |
| lineVerticalBold | `┃` | |
| lineVerticalDouble | `║` | |
| lineVerticalDashed0 | `┆` | |
| lineVerticalDashed1 | `┇` | |
| lineVerticalDashed2 | `┊` | |
| lineVerticalDashed3 | `┋` | |
| lineVerticalDashed4 | `╎` | |
| lineVerticalDashed5 | `╏` | |
| lineVerticalDashed6 | `╵` | |
| lineVerticalDashed7 | `╷` | |
| lineVerticalDashed8 | `╹` | |
| lineVerticalDashed9 | `╻` | |
| lineVerticalDashed10 | `╽` | |
| lineVerticalDashed11 | `╿` | |
| lineDownLeft | `┐` | |
| lineDownLeftArc | `╮` | |
| lineDownBoldLeftBold | `┓` | |
| lineDownBoldLeft | `┒` | |
| lineDownLeftBold | `┑` | |
| lineDownDoubleLeftDouble | `╗` | |
| lineDownDoubleLeft | `╖` | |
| lineDownLeftDouble | `╕` | |
| lineDownRight | `┌` | |
| lineDownRightArc | `╭` | |
| lineDownBoldRightBold | `┏` | |
| lineDownBoldRight | `┎` | |
| lineDownRightBold | `┍` | |
| lineDownDoubleRightDouble | `╔` | |
| lineDownDoubleRight | `╓` | |
| lineDownRightDouble | `╒` | |
| lineUpLeft | `┘` | |
| lineUpLeftArc | `╯` | |
| lineUpBoldLeftBold | `┛` | |
| lineUpBoldLeft | `┚` | |
| lineUpLeftBold | `┙` | |
| lineUpDoubleLeftDouble | `╝` | |
| lineUpDoubleLeft | `╜` | |
| lineUpLeftDouble | `╛` | |
| lineUpRight | `└` | |
| lineUpRightArc | `╰` | |
| lineUpBoldRightBold | `┗` | |
| lineUpBoldRight | `┖` | |
| lineUpRightBold | `┕` | |
| lineUpDoubleRightDouble | `╚` | |
| lineUpDoubleRight | `╙` | |
| lineUpRightDouble | `╘` | |
| lineUpDownLeft | `┤` | |
| lineUpBoldDownBoldLeftBold | `┫` | |
| lineUpBoldDownBoldLeft | `┨` | |
| lineUpDownLeftBold | `┥` | |
| lineUpBoldDownLeftBold | `┩` | |
| lineUpDownBoldLeftBold | `┪` | |
| lineUpDownBoldLeft | `┧` | |
| lineUpBoldDownLeft | `┦` | |
| lineUpDoubleDownDoubleLeftDouble | `╣` | |
| lineUpDoubleDownDoubleLeft | `╢` | |
| lineUpDownLeftDouble | `╡` | |
| lineUpDownRight | `├` | |
| lineUpBoldDownBoldRightBold | `┣` | |
| lineUpBoldDownBoldRight | `┠` | |
| lineUpDownRightBold | `┝` | |
| lineUpBoldDownRightBold | `┡` | |
| lineUpDownBoldRightBold | `┢` | |
| lineUpDownBoldRight | `┟` | |
| lineUpBoldDownRight | `┞` | |
| lineUpDoubleDownDoubleRightDouble | `╠` | |
| lineUpDoubleDownDoubleRight | `╟` | |
| lineUpDownRightDouble | `╞` | |
| lineDownLeftRight | `┬` | |
| lineDownBoldLeftBoldRightBold | `┳` | |
| lineDownLeftBoldRightBold | `┯` | |
| lineDownBoldLeftRight | `┰` | |
| lineDownBoldLeftBoldRight | `┱` | |
| lineDownBoldLeftRightBold | `┲` | |
| lineDownLeftRightBold | `┮` | |
| lineDownLeftBoldRight | `┭` | |
| lineDownDoubleLeftDoubleRightDouble | `╦` | |
| lineDownDoubleLeftRight | `╥` | |
| lineDownLeftDoubleRightDouble | `╤` | |
| lineUpLeftRight | `┴` | |
| lineUpBoldLeftBoldRightBold | `┻` | |
| lineUpLeftBoldRightBold | `┷` | |
| lineUpBoldLeftRight | `┸` | |
| lineUpBoldLeftBoldRight | `┹` | |
| lineUpBoldLeftRightBold | `┺` | |
| lineUpLeftRightBold | `┶` | |
| lineUpLeftBoldRight | `┵` | |
| lineUpDoubleLeftDoubleRightDouble | `╩` | |
| lineUpDoubleLeftRight | `╨` | |
| lineUpLeftDoubleRightDouble | `╧` | |
| lineUpDownLeftRight | `┼` | |
| lineUpBoldDownBoldLeftBoldRightBold | `╋` | |
| lineUpDownBoldLeftBoldRightBold | `╈` | |
| lineUpBoldDownLeftBoldRightBold | `╇` | |
| lineUpBoldDownBoldLeftRightBold | `╊` | |
| lineUpBoldDownBoldLeftBoldRight | `╉` | |
| lineUpBoldDownLeftRight | `╀` | |
| lineUpDownBoldLeftRight | `╁` | |
| lineUpDownLeftBoldRight | `┽` | |
| lineUpDownLeftRightBold | `┾` | |
| lineUpBoldDownBoldLeftRight | `╂` | |
| lineUpDownLeftBoldRightBold | `┿` | |
| lineUpBoldDownLeftBoldRight | `╃` | |
| lineUpBoldDownLeftRightBold | `╄` | |
| lineUpDownBoldLeftBoldRight | `╅` | |
| lineUpDownBoldLeftRightBold | `╆` | |
| lineUpDoubleDownDoubleLeftDoubleRightDouble | `╬` | |
| lineUpDoubleDownDoubleLeftRight | `╫` | |
| lineUpDownLeftDoubleRightDouble | `╪` | |
| lineCross | `╳` | |
| lineBackslash | `╲` | |
| lineSlash | `╱` | |
## Other characters
## Figures
If you cannot find the character you're looking for in the table above, please look at this full list of [cross-platform terminal characters](https://github.com/ehmicky/cross-platform-terminal-characters).
| Name | Non-Windows | Windows |
| ------------------ | :---------: | :-----: |
| tick | ✔ | √ |
| cross | ✖ | × |
| star | ★ | * |
| square | ▇ | █ |
| squareSmall | ◻ | [ ] |
| squareSmallFilled | ◼ | [█] |
| play | ▶ | ► |
| circle | ◯ | ( ) |
| circleFilled | ◉ | (*) |
| circleDotted | ◌ | ( ) |
| circleDouble | ◎ | ( ) |
| circleCircle | ⓞ | (○) |
| circleCross | ⓧ | (×) |
| circlePipe | Ⓘ | (│) |
| circleQuestionMark | ?⃝ | (?) |
| bullet | ● | * |
| dot | ․ | . |
| line | ─ | ─ |
| ellipsis | … | ... |
| pointer | ❯ | > |
| pointerSmall | › | » |
| info | ℹ | i |
| warning | ⚠ | ‼ |
| hamburger | ☰ | ≡ |
| smiley | ㋡ | ☺ |
| mustache | ෴ | ┌─┐ |
| heart | ♥ | ♥ |
| nodejs | ⬢ | ♦ |
| arrowUp | ↑ | ↑ |
| arrowDown | ↓ | ↓ |
| arrowLeft | ← | ← |
| arrowRight | → | → |
| radioOn | ◉ | (*) |
| radioOff | ◯ | ( ) |
| checkboxOn | ☒ | [×] |
| checkboxOff | ☐ | [ ] |
| checkboxCircleOn | ⓧ | (×) |
| checkboxCircleOff | Ⓘ | ( ) |
| questionMarkPrefix | ?⃝ | ? |
| oneHalf | ½ | 1/2 |
| oneThird | ⅓ | 1/3 |
| oneQuarter | ¼ | 1/4 |
| oneFifth | ⅕ | 1/5 |
| oneSixth | ⅙ | 1/6 |
| oneSeventh | ⅐ | 1/7 |
| oneEighth | ⅛ | 1/8 |
| oneNinth | ⅑ | 1/9 |
| oneTenth | ⅒ | 1/10 |
| twoThirds | ⅔ | 2/3 |
| twoFifths | ⅖ | 2/5 |
| threeQuarters | ¾ | 3/4 |
| threeFifths | ⅗ | 3/5 |
| threeEighths | ⅜ | 3/8 |
| fourFifths | ⅘ | 4/5 |
| fiveSixths | ⅚ | 5/6 |
| fiveEighths | ⅝ | 5/8 |
| sevenEighths | ⅞ | 7/8 |
## Unsupported terminals
The following terminals are not officially supported:
- xterm
- Linux Terminal (kernel)
- cmder
They can display most but not all of the symbols listed above.
## Related

@@ -130,0 +320,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc