Skip to content

Commit

Permalink
Upgrade xo (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
ehmicky authored Jul 2, 2021
1 parent 253f966 commit 21ec344
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,18 @@ const shouldUseMain = isUnicodeSupported();
const figures = shouldUseMain ? mainSymbols : windowsSymbols;
export default figures;

const isWindowsSymbol = ([key, mainSymbol]) => figures[key] !== mainSymbol;
const getFigureRegExp = ([key, mainSymbol]) => [new RegExp(escapeStringRegexp(mainSymbol), 'g'), windowsSymbols[key]];
const isWindowsSymbol = (key, mainSymbol) => figures[key] !== mainSymbol;
const getFigureRegExp = (key, mainSymbol) => [new RegExp(escapeStringRegexp(mainSymbol), 'g'), windowsSymbols[key]];

let replacements = [];
const getReplacements = () => {
if (replacements.length !== 0) {
if (replacements.length > 0) {
return replacements;
}

replacements = Object.entries(mainSymbols)
.filter(isWindowsSymbol)
.map(getFigureRegExp);
.filter(([key, mainSymbol]) => isWindowsSymbol(key, mainSymbol))
.map(([key, mainSymbol]) => getFigureRegExp(key, mainSymbol));
return replacements;
};

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"devDependencies": {
"ava": "^3.15.0",
"tsd": "^0.17.0",
"xo": "^0.24.0"
"typescript": "^4.3.5",
"xo": "^0.40.3"
}
}
7 changes: 3 additions & 4 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import test from 'ava';
import isUnicodeSupported from 'is-unicode-supported';
// eslint-disable-next-line unicorn/import-index, import/extensions
import figures, {replaceSymbols, mainSymbols, windowsSymbols} from './index.js';

const result = (mainSymbols, windowsSymbols) => isUnicodeSupported() ? mainSymbols : windowsSymbols;

const NON_FIGURE_KEYS = new Set(['mainSymbols', 'windowsSymbols', 'replaceSymbols']);
const isFigureKey = ([key]) => !NON_FIGURE_KEYS.has(key);
const getFigure = ([, figure]) => figure;
const getFigures = () => Object.entries(figures).filter(isFigureKey).map(getFigure);
const getFigures = () => Object.entries(figures)
.filter(([key]) => !NON_FIGURE_KEYS.has(key))
.map(([, figure]) => figure);

console.log(` ${getFigures().join(' ')}\n`);

Expand Down

0 comments on commit 21ec344

Please sign in to comment.