ansi-regex 5.0.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ansi-regex might be problematic. Click here for more details.

package/index.d.ts CHANGED
@@ -1,12 +1,10 @@
1
- declare namespace ansiRegex {
2
- interface Options {
3
- /**
4
- Match only the first ANSI escape.
5
-
6
- @default false
7
- */
8
- onlyFirst: boolean;
9
- }
1
+ export interface Options {
2
+ /**
3
+ Match only the first ANSI escape.
4
+
5
+ @default false
6
+ */
7
+ readonly onlyFirst: boolean;
10
8
  }
11
9
 
12
10
  /**
@@ -14,7 +12,7 @@ Regular expression for matching ANSI escape codes.
14
12
 
15
13
  @example
16
14
  ```
17
- import ansiRegex = require('ansi-regex');
15
+ import ansiRegex from 'ansi-regex';
18
16
 
19
17
  ansiRegex().test('\u001B[4mcake\u001B[0m');
20
18
  //=> true
@@ -32,6 +30,4 @@ ansiRegex().test('cake');
32
30
  //=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
33
31
  ```
34
32
  */
35
- declare function ansiRegex(options?: ansiRegex.Options): RegExp;
36
-
37
- export = ansiRegex;
33
+ export default function ansiRegex(options?: Options): RegExp;
package/index.js CHANGED
@@ -1,10 +1,8 @@
1
- 'use strict';
2
-
3
- module.exports = ({onlyFirst = false} = {}) => {
1
+ export default function ansiRegex({onlyFirst = false} = {}) {
4
2
  const pattern = [
5
- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
3
+ '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
6
4
  '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
7
5
  ].join('|');
8
6
 
9
7
  return new RegExp(pattern, onlyFirst ? undefined : 'g');
10
- };
8
+ }
package/license CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3
+ Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
4
4
 
5
5
  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:
6
6
 
package/package.json CHANGED
@@ -1,16 +1,19 @@
1
1
  {
2
2
  "name": "ansi-regex",
3
- "version": "5.0.1",
3
+ "version": "6.0.0",
4
4
  "description": "Regular expression for matching ANSI escape codes",
5
5
  "license": "MIT",
6
6
  "repository": "chalk/ansi-regex",
7
+ "funding": "https://github.com/chalk/ansi-regex?sponsor=1",
7
8
  "author": {
8
9
  "name": "Sindre Sorhus",
9
10
  "email": "sindresorhus@gmail.com",
10
- "url": "sindresorhus.com"
11
+ "url": "https://sindresorhus.com"
11
12
  },
13
+ "type": "module",
14
+ "exports": "./index.js",
12
15
  "engines": {
13
- "node": ">=8"
16
+ "node": ">=12"
14
17
  },
15
18
  "scripts": {
16
19
  "test": "xo && ava && tsd",
@@ -48,8 +51,8 @@
48
51
  "pattern"
49
52
  ],
50
53
  "devDependencies": {
51
- "ava": "^2.4.0",
52
- "tsd": "^0.9.0",
53
- "xo": "^0.25.3"
54
+ "ava": "^3.15.0",
55
+ "tsd": "^0.14.0",
56
+ "xo": "^0.38.2"
54
57
  }
55
58
  }
package/readme.md CHANGED
@@ -2,18 +2,16 @@
2
2
 
3
3
  > Regular expression for matching [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code)
4
4
 
5
-
6
5
  ## Install
7
6
 
8
7
  ```
9
8
  $ npm install ansi-regex
10
9
  ```
11
10
 
12
-
13
11
  ## Usage
14
12
 
15
13
  ```js
16
- const ansiRegex = require('ansi-regex');
14
+ import ansiRegex from 'ansi-regex';
17
15
 
18
16
  ansiRegex().test('\u001B[4mcake\u001B[0m');
19
17
  //=> true
@@ -31,7 +29,6 @@ ansiRegex().test('cake');
31
29
  //=> ['\u001B]8;;https://github.com\u0007', '\u001B]8;;\u0007']
32
30
  ```
33
31
 
34
-
35
32
  ## API
36
33
 
37
34
  ### ansiRegex(options?)
@@ -44,12 +41,11 @@ Type: `object`
44
41
 
45
42
  ##### onlyFirst
46
43
 
47
- Type: `boolean`<br>
44
+ Type: `boolean`\
48
45
  Default: `false` *(Matches any ANSI escape codes in a string)*
49
46
 
50
47
  Match only the first ANSI escape.
51
48
 
52
-
53
49
  ## FAQ
54
50
 
55
51
  ### Why do you test for codes not in the ECMA 48 standard?
@@ -58,13 +54,11 @@ Some of the codes we run as a test are codes that we acquired finding various li
58
54
 
59
55
  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.
60
56
 
61
-
62
57
  ## Maintainers
63
58
 
64
59
  - [Sindre Sorhus](https://github.com/sindresorhus)
65
60
  - [Josh Junon](https://github.com/qix-)
66
61
 
67
-
68
62
  ---
69
63
 
70
64
  <div align="center">