From f26f7fe2287b44d3092c75a8dc3f7722282773d0 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 4 Oct 2019 18:27:52 +0700 Subject: [PATCH] Meta tweaks --- fixtures/view-codes.js | 18 +++++++++--------- index.test-d.ts | 2 +- package.json | 4 ++-- readme.md | 4 +++- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/fixtures/view-codes.js b/fixtures/view-codes.js index a921899..9837a5c 100644 --- a/fixtures/view-codes.js +++ b/fixtures/view-codes.js @@ -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}`) { @@ -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'); diff --git a/index.test-d.ts b/index.test-d.ts index 77fed65..20a68a4 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,5 +1,5 @@ import {expectType} from 'tsd'; -import ansiRegex from '.'; +import ansiRegex = require('.'); expectType(ansiRegex()); expectType(ansiRegex({onlyFirst: true})); diff --git a/package.json b/package.json index 0717ee9..c75e62c 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/readme.md b/readme.md index 1c8abb4..3c2b77c 100644 --- a/readme.md +++ b/readme.md @@ -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`