pax_global_header00006660000000000000000000000064150575702620014523gustar00rootroot0000000000000052 comment=c51e2883f3579628f7bffd40a13070e563bcc2c6 chalk-strip-ansi-eba595a/000077500000000000000000000000001505757026200153715ustar00rootroot00000000000000chalk-strip-ansi-eba595a/.editorconfig000066400000000000000000000002571505757026200200520ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 chalk-strip-ansi-eba595a/.gitattributes000066400000000000000000000000231505757026200202570ustar00rootroot00000000000000* text=auto eol=lf chalk-strip-ansi-eba595a/.github/000077500000000000000000000000001505757026200167315ustar00rootroot00000000000000chalk-strip-ansi-eba595a/.github/funding.yml000066400000000000000000000000661505757026200211100ustar00rootroot00000000000000github: [sindresorhus, Qix-] tidelift: npm/strip-ansi chalk-strip-ansi-eba595a/.github/security.md000066400000000000000000000002631505757026200211230ustar00rootroot00000000000000# Security Policy To report a security vulnerability, please use the [Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the fix and disclosure. chalk-strip-ansi-eba595a/.github/workflows/000077500000000000000000000000001505757026200207665ustar00rootroot00000000000000chalk-strip-ansi-eba595a/.github/workflows/main.yml000066400000000000000000000006261505757026200224410ustar00rootroot00000000000000name: CI on: - push - pull_request jobs: test: name: Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest strategy: fail-fast: false matrix: node-version: - 16 steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test chalk-strip-ansi-eba595a/.gitignore000066400000000000000000000000271505757026200173600ustar00rootroot00000000000000node_modules yarn.lock chalk-strip-ansi-eba595a/.npmrc000066400000000000000000000000231505757026200165040ustar00rootroot00000000000000package-lock=false chalk-strip-ansi-eba595a/index.d.ts000066400000000000000000000005351505757026200172750ustar00rootroot00000000000000/** 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(string: string): string; chalk-strip-ansi-eba595a/index.js000066400000000000000000000007241505757026200170410ustar00rootroot00000000000000import ansiRegex from 'ansi-regex'; const regex = ansiRegex(); export default function stripAnsi(string) { if (typeof string !== 'string') { throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``); } // Even though the regex is global, we don't need to reset the `.lastIndex` // because unlike `.exec()` and `.test()`, `.replace()` does it automatically // and doing it manually has a performance penalty. return string.replace(regex, ''); } chalk-strip-ansi-eba595a/index.test-d.ts000066400000000000000000000001761505757026200202530ustar00rootroot00000000000000import {expectType} from 'tsd'; import stripAnsi from './index.js'; expectType(stripAnsi('\u001B[4mcake\u001B[0m')); chalk-strip-ansi-eba595a/license000066400000000000000000000021351505757026200167370ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (https://sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. chalk-strip-ansi-eba595a/package.json000066400000000000000000000017031505757026200176600ustar00rootroot00000000000000{ "name": "strip-ansi", "version": "7.1.2", "description": "Strip ANSI escape codes from a string", "license": "MIT", "repository": "chalk/strip-ansi", "funding": "https://github.com/chalk/strip-ansi?sponsor=1", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "type": "module", "exports": "./index.js", "types": "./index.d.ts", "sideEffects": false, "engines": { "node": ">=12" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "strip", "trim", "remove", "ansi", "styles", "color", "colour", "colors", "terminal", "console", "string", "tty", "escape", "formatting", "rgb", "256", "shell", "xterm", "log", "logging", "command-line", "text" ], "dependencies": { "ansi-regex": "^6.0.1" }, "devDependencies": { "ava": "^3.15.0", "tsd": "^0.17.0", "xo": "^0.44.0" } } chalk-strip-ansi-eba595a/readme.md000066400000000000000000000023071505757026200171520ustar00rootroot00000000000000# strip-ansi > Strip [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) from a string > [!NOTE] > Node.js has this built-in now with [`stripVTControlCharacters`](https://nodejs.org/api/util.html#utilstripvtcontrolcharactersstr). The benefit of this package is consistent behavior across Node.js versions and faster improvements. The Node.js version is actually based on this package. ## Install ```sh npm install strip-ansi ``` ## Usage ```js import stripAnsi from 'strip-ansi'; stripAnsi('\u001B[4mUnicorn\u001B[0m'); //=> 'Unicorn' stripAnsi('\u001B]8;;https://github.com\u0007Click\u001B]8;;\u0007'); //=> 'Click' ``` ## Related - [strip-ansi-cli](https://github.com/chalk/strip-ansi-cli) - CLI for this module - [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Streaming version of this module - [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes - [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes - [chalk](https://github.com/chalk/chalk) - Terminal string styling done right ## Maintainers - [Sindre Sorhus](https://github.com/sindresorhus) - [Josh Junon](https://github.com/qix-) chalk-strip-ansi-eba595a/test.js000066400000000000000000000012011505757026200167000ustar00rootroot00000000000000import test from 'ava'; import stripAnsi from './index.js'; test('strip color from string', t => { t.is(stripAnsi('\u001B[0m\u001B[4m\u001B[42m\u001B[31mfoo\u001B[39m\u001B[49m\u001B[24mfoo\u001B[0m'), 'foofoo'); }); test('strip color from ls command', t => { t.is(stripAnsi('\u001B[00;38;5;244m\u001B[m\u001B[00;38;5;33mfoo\u001B[0m'), 'foo'); }); test('strip reset;setfg;setbg;italics;strike;underline sequence from string', t => { t.is(stripAnsi('\u001B[0;33;49;3;9;4mbar\u001B[0m'), 'bar'); }); test('strip link from terminal link', t => { t.is(stripAnsi('\u001B]8;;https://github.com\u0007click\u001B]8;;\u0007'), 'click'); });