From 81cd3cc7591ff32a19e4a7cb4bed40c9e8adbde3 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Mon, 18 Mar 2019 15:44:40 +0700 Subject: [PATCH] Meta tweaks --- index.d.ts | 15 +++++++++++++-- index.js | 2 +- index.test-d.ts | 2 +- package.json | 2 +- readme.md | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/index.d.ts b/index.d.ts index 55394b7..44e954d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,4 +1,15 @@ /** -Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). +Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string. + +@example +``` +import stripAnsi from 'strip-ansi'; + +stripAnsi('\u001B[4mUnicorn\u001B[0m'); +//=> 'Unicorn' + +stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007'); +//=> 'Click' +``` */ -export default function stripAnsi(str: string): string; +export default function stripAnsi(string: string): string; diff --git a/index.js b/index.js index 2d6ebcc..9788c96 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,7 @@ 'use strict'; const ansiRegex = require('ansi-regex'); -const stripAnsi = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input; +const stripAnsi = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string; module.exports = stripAnsi; module.exports.default = stripAnsi; diff --git a/index.test-d.ts b/index.test-d.ts index 29d4f66..55698d7 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,4 +1,4 @@ import {expectType} from 'tsd-check'; import stripAnsi from '.'; -expectType(stripAnsi('\u001b[4mcake\u001b[0m')); +expectType(stripAnsi('\u001B[4mcake\u001B[0m')); diff --git a/package.json b/package.json index 3be60ac..a69312c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "strip-ansi", "version": "5.1.0", - "description": "Strip ANSI escape codes", + "description": "Strip ANSI escape codes from a string", "license": "MIT", "repository": "chalk/strip-ansi", "author": { diff --git a/readme.md b/readme.md index c7f3df8..8681fe8 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # strip-ansi [![Build Status](https://travis-ci.org/chalk/strip-ansi.svg?branch=master)](https://travis-ci.org/chalk/strip-ansi) -> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) +> Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string ---