Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Oct 4, 2019
1 parent e77ea17 commit f26f7fe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
18 changes: 9 additions & 9 deletions fixtures/view-codes.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
'use strict';
const ansiRegex = require('..');
const ansiCodes = require('./ansi-codes');
const ansiRegex = require('..');

const allCodes = {};
const supported = [];
const unsupported = [];

function addCodesToTest(codes) {
for (const code of Object.keys(codes)) {
allCodes[code] = codes[code];
for (const [key, value] of Object.entries(codes)) {
allCodes[key] = value;
}
}

function identifySupportedCodes() {
let codeSupport = {};

for (const code of Object.keys(allCodes)) {
for (const [code, value] of Object.keys(allCodes)) {
codeSupport = {
code,
matches: `\u001B${code}`.match(ansiRegex()),
description: allCodes[code][0]
description: value[0]
};

if (codeSupport.matches !== null && codeSupport.matches[0] === `\u001B${code}`) {
Expand All @@ -34,15 +34,15 @@ function displaySupport() {
process.stdout.write('\u001B[32m');

console.log('SUPPORTED');
for (const el of supported) {
console.log(el);
for (const element of supported) {
console.log(element);
}

process.stdout.write('\u001B[31m');
console.log('UNSUPPORTED');

for (const el of unsupported) {
console.log(el);
for (const element of unsupported) {
console.log(element);
}

process.stdout.write('\u001B[0m');
Expand Down
2 changes: 1 addition & 1 deletion index.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {expectType} from 'tsd';
import ansiRegex from '.';
import ansiRegex = require('.');

expectType<RegExp>(ansiRegex());
expectType<RegExp>(ansiRegex({onlyFirst: true}));
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"pattern"
],
"devDependencies": {
"ava": "^1.4.1",
"ava": "^2.4.0",
"tsd": "^0.9.0",
"xo": "^0.24.0"
"xo": "^0.25.3"
}
}
4 changes: 3 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ ansiRegex().test('cake');

## API

### ansiRegex([options])
### ansiRegex(options?)

Returns a regex for matching ANSI escape codes.

#### options

Type: `object`

##### onlyFirst

Type: `boolean`<br>
Expand Down

0 comments on commit f26f7fe

Please sign in to comment.