Comparing version 2.0.0 to 3.0.0
24
index.js
'use strict'; | ||
const escapeStringRegexp = require('escape-string-regexp'); | ||
const platform = process.platform; | ||
const {platform} = process; | ||
@@ -65,3 +65,3 @@ const main = { | ||
const win = { | ||
const windows = { | ||
tick: 'β', | ||
@@ -126,24 +126,24 @@ cross: 'Γ', | ||
if (platform === 'linux') { | ||
// the main one doesn't look that good on Ubuntu | ||
// The main one doesn't look that good on Ubuntu | ||
main.questionMarkPrefix = '?'; | ||
} | ||
const figures = platform === 'win32' ? win : main; | ||
const figures = platform === 'win32' ? windows : main; | ||
const fn = str => { | ||
const fn = string => { | ||
if (figures === main) { | ||
return str; | ||
return string; | ||
} | ||
Object.keys(main).forEach(key => { | ||
if (main[key] === figures[key]) { | ||
return; | ||
for (const [key, value] of Object.entries(main)) { | ||
if (value === figures[key]) { | ||
continue; | ||
} | ||
str = str.replace(new RegExp(escapeStringRegexp(main[key]), 'g'), figures[key]); | ||
}); | ||
string = string.replace(new RegExp(escapeStringRegexp(value), 'g'), figures[key]); | ||
} | ||
return str; | ||
return string; | ||
}; | ||
module.exports = Object.assign(fn, figures); |
{ | ||
"name": "figures", | ||
"version": "2.0.0", | ||
"description": "Unicode symbols with Windows CMD fallbacks", | ||
"license": "MIT", | ||
"repository": "sindresorhus/figures", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava", | ||
"make": "./makefile.js" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"unicode", | ||
"cli", | ||
"cmd", | ||
"command-line", | ||
"characters", | ||
"char", | ||
"symbol", | ||
"symbols", | ||
"figure", | ||
"figures", | ||
"fallback" | ||
], | ||
"dependencies": { | ||
"escape-string-regexp": "^1.0.5" | ||
}, | ||
"devDependencies": { | ||
"ava": "*", | ||
"markdown-table": "^1.0.0", | ||
"require-uncached": "^1.0.2", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
"name": "figures", | ||
"version": "3.0.0", | ||
"description": "Unicode symbols with Windows CMD fallbacks", | ||
"license": "MIT", | ||
"repository": "sindresorhus/figures", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd", | ||
"make": "./makefile.js" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"unicode", | ||
"cli", | ||
"cmd", | ||
"command-line", | ||
"characters", | ||
"symbol", | ||
"symbols", | ||
"figure", | ||
"figures", | ||
"fallback" | ||
], | ||
"dependencies": { | ||
"escape-string-regexp": "^1.0.5" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"import-fresh": "^3.0.0", | ||
"markdown-table": "^1.1.2", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# 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) | ||
# figures [![Build Status](https://travis-ci.org/sindresorhus/figures.svg?branch=master)](https://travis-ci.org/sindresorhus/figures) | ||
@@ -15,3 +15,3 @@ > Unicode symbols with Windows CMD fallbacks | ||
``` | ||
$ npm install --save figures | ||
$ npm install figures | ||
``` | ||
@@ -39,13 +39,13 @@ | ||
### figures(input) | ||
### figures(string) | ||
Returns the input with replaced fallback unicode symbols on Windows. | ||
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 | ||
#### string | ||
Type: `string` | ||
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 OS. | ||
@@ -52,0 +52,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10843
5
212
5