figures
Advanced tools
Comparing version 1.6.0 to 1.7.0
22
index.js
'use strict'; | ||
var objectAssign = require('object-assign'); | ||
var escapeStringRegexp = require('escape-string-regexp'); | ||
var platform = process.platform; | ||
@@ -127,2 +129,20 @@ | ||
module.exports = platform === 'win32' ? win : main; | ||
var figures = platform === 'win32' ? win : main; | ||
var fn = function (str) { | ||
if (figures === main) { | ||
return str; | ||
} | ||
Object.keys(main).forEach(function (key) { | ||
if (main[key] === figures[key]) { | ||
return; | ||
} | ||
str = str.replace(new RegExp(escapeStringRegexp(main[key]), 'g'), figures[key]); | ||
}); | ||
return str; | ||
}; | ||
module.exports = objectAssign(fn, figures); |
{ | ||
"name": "figures", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "Unicode symbols with Windows CMD fallbacks", | ||
@@ -16,3 +16,4 @@ "license": "MIT", | ||
"scripts": { | ||
"test": "xo && ava" | ||
"test": "xo && ava", | ||
"make": "./makefile.js" | ||
}, | ||
@@ -35,6 +36,12 @@ "files": [ | ||
], | ||
"dependencies": { | ||
"escape-string-regexp": "^1.0.5", | ||
"object-assign": "^4.1.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"markdown-table": "^0.4.0", | ||
"require-uncached": "^1.0.2", | ||
"xo": "*" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# figures [![Build Status](https://travis-ci.org/sindresorhus/figures.svg?branch=master)](https://travis-ci.org/sindresorhus/figures) | ||
# figures [![Build Status: Linux](https://travis-ci.org/sindresorhus/figures.svg?branch=master)](https://travis-ci.org/sindresorhus/figures) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/mb743hl70269be3r/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/figures/branch/master) | ||
@@ -26,2 +26,6 @@ > Unicode symbols with Windows CMD fallbacks | ||
console.log(figures('βοΈ check')); | ||
// On real OSes: βοΈ check | ||
// On Windows: β check | ||
console.log(figures.tick); | ||
@@ -33,4 +37,81 @@ // On real OSes: βοΈ | ||
## API | ||
### figures(input) | ||
Returns the input with replaced fallback unicode symbols on Windows. | ||
All the below [figures](#figures) are attached to the main export as shown in the example above. | ||
#### input | ||
Type: `string` | ||
String where the unicode symbols will be replaced with fallback symbols depending on the OS. | ||
## Figures | ||
| Name | Real OSes | 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 | β₯ | β₯ | | ||
| 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 | | ||
## License | ||
MIT Β© [Sindre Sorhus](http://sindresorhus.com) | ||
MIT Β© [Sindre Sorhus](https://sindresorhus.com) |
8827
138
116
2
4
+ Addedescape-string-regexp@^1.0.5
+ Addedobject-assign@^4.1.0
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedobject-assign@4.1.1(transitive)