ansi-regex
Advanced tools
Comparing version 2.1.1 to 3.0.0
10
index.js
'use strict'; | ||
module.exports = function () { | ||
return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g; | ||
module.exports = () => { | ||
const pattern = [ | ||
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)', | ||
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))' | ||
].join('|'); | ||
return new RegExp(pattern, 'g'); | ||
}; |
{ | ||
"name": "ansi-regex", | ||
"version": "2.1.1", | ||
"version": "3.0.0", | ||
"description": "Regular expression for matching ANSI escape codes", | ||
@@ -12,12 +12,7 @@ "license": "MIT", | ||
}, | ||
"maintainers": [ | ||
"Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)", | ||
"Joshua Appelman <jappelman@xebia.com> (jbnicolai.com)", | ||
"JD Ballard <i.am.qix@gmail.com> (github.com/qix-)" | ||
], | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava --verbose", | ||
"test": "xo && ava", | ||
"view-supported": "node fixtures/view-codes.js" | ||
@@ -56,11 +51,5 @@ }, | ||
"devDependencies": { | ||
"ava": "0.17.0", | ||
"xo": "0.16.0" | ||
}, | ||
"xo": { | ||
"rules": { | ||
"guard-for-in": 0, | ||
"no-loop-func": 0 | ||
} | ||
"ava": "*", | ||
"xo": "*" | ||
} | ||
} |
# ansi-regex [![Build Status](https://travis-ci.org/chalk/ansi-regex.svg?branch=master)](https://travis-ci.org/chalk/ansi-regex) | ||
> Regular expression for matching [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) | ||
> Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) | ||
@@ -9,3 +9,3 @@ | ||
``` | ||
$ npm install --save ansi-regex | ||
$ npm install ansi-regex | ||
``` | ||
@@ -19,3 +19,3 @@ | ||
ansiRegex().test('\u001b[4mcake\u001b[0m'); | ||
ansiRegex().test('\u001B[4mcake\u001B[0m'); | ||
//=> true | ||
@@ -26,6 +26,7 @@ | ||
'\u001b[4mcake\u001b[0m'.match(ansiRegex()); | ||
//=> ['\u001b[4m', '\u001b[0m'] | ||
'\u001B[4mcake\u001B[0m'.match(ansiRegex()); | ||
//=> ['\u001B[4m', '\u001B[0m'] | ||
``` | ||
## FAQ | ||
@@ -35,3 +36,3 @@ | ||
Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. If I recall correctly, we test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them. | ||
Some of the codes we run as a test are codes that we acquired finding various lists of non-standard or manufacturer specific codes. We test for both standard and non-standard codes, as most of them follow the same or similar format and can be safely matched in strings without the risk of removing actual string content. There are a few non-standard control codes that do not follow the traditional format (i.e. they end in numbers) thus forcing us to exclude them from the test because we cannot reliably match them. | ||
@@ -41,4 +42,10 @@ On the historical side, those ECMA standards were established in the early 90's whereas the VT100, for example, was designed in the mid/late 70's. At that point in time, control codes were still pretty ungoverned and engineers used them for a multitude of things, namely to activate hardware ports that may have been proprietary. Somewhere else you see a similar 'anarchy' of codes is in the x86 architecture for processors; there are a ton of "interrupts" that can mean different things on certain brands of processors, most of which have been phased out. | ||
## Maintainers | ||
- [Sindre Sorhus](https://github.com/sindresorhus) | ||
- [Josh Junon](https://github.com/qix-) | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
8
47
1
4021