Skip to content

Commit

Permalink
move RegExp.escape to stage 2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Apr 7, 2024
1 parent d8292f3 commit 97f6a1e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
## Changelog
##### Unreleased
- [`RegExp.escape`](https://github.com/tc39/proposal-regex-escaping):
- Built-ins:
- `RegExp.escape`
- Moved to stage 2.7, April 2024 TC39 meeting
- Moved to hex-escape semantics, [regex-escaping/67](https://github.com/tc39/proposal-regex-escaping/pull/67)
- Added [`URL.parse`](https://url.spec.whatwg.org/#dom-url-parse), [url/825](https://github.com/whatwg/url/pull/825)
- [`RegExp.escape`](https://github.com/tc39/proposal-regex-escaping) [moved to hex-escape semantics](https://github.com/tc39/proposal-regex-escaping/pull/67)
- Some minor updates of [Explicit Resource Management](https://github.com/tc39/proposal-explicit-resource-management) Stage 3 proposal like [explicit-resource-management/217](https://github.com/tc39/proposal-explicit-resource-management/pull/217)
- Compat data improvements:
- [`URL.parse`](https://url.spec.whatwg.org/#dom-url-parse) added and marked as supported [from FF 126](https://bugzilla.mozilla.org/show_bug.cgi?id=1887611)
Expand Down
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2498,7 +2498,27 @@ core-js(-pure)/actual|full/function/metadata
core-js(-pure)/stage/2.7
```

*Nothing*
##### [`RegExp` escaping](https://github.com/tc39/proposal-regex-escaping)[⬆](#index)
Module [`esnext.regexp.escape`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.regexp.escape.js)
```js
class RegExp {
static escape(value: string): string
}
```
[*CommonJS entry points:*](#commonjs-api)
```js
core-js/proposals/regexp-escaping
core-js(-pure)/full/regexp/escape
```
[*Example*](https://tinyurl.com/2cdgu3cz):
```js
console.log(RegExp.escape('10$')); // => '\\x310\\x24'
console.log(RegExp.escape('abcdefg_123456')); // => 'abcdefg_123456'
console.log(RegExp.escape('(){}[]|,.?*+-^$=<>\\/#&!%:;@~\'"`'));
// => '\\x28\\x29\\x7b\\x7d\\x5b\\x5d\\x7c\\x2c\\x2e\\x3f\\x2a\\x2b\\x2d\\x5e\\x24\\x3d\\x3c\\x3e\\x5c\\x2f\\x23\\x26\\x21\\x25\\x3a\\x3b\\x40\\x7e\\x27\\x22\\x60'
console.log(RegExp.escape('\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'));
// => '\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029\\ufeff'
```
#### Stage 2 proposals[⬆](#index)
[*CommonJS entry points:*](#commonjs-api)
Expand Down Expand Up @@ -2670,27 +2690,6 @@ String.dedent(console.log)`
print('${ message }')
`; // => ["print('", "')", raw: Array(2)], 42
```
##### [`RegExp` escaping](https://github.com/tc39/proposal-regex-escaping)[⬆](#index)
Module [`esnext.regexp.escape`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.regexp.escape.js)
```js
class RegExp {
static escape(value: string): string
}
```
[*CommonJS entry points:*](#commonjs-api)
```js
core-js/proposals/regexp-escaping
core-js(-pure)/full/regexp/escape
```
[*Example*](https://tinyurl.com/2cdgu3cz):
```js
console.log(RegExp.escape('10$')); // => '\\x310\\x24'
console.log(RegExp.escape('abcdefg_123456')); // => 'abcdefg_123456'
console.log(RegExp.escape('(){}[]|,.?*+-^$=<>\\/#&!%:;@~\'"`'));
// => '\\x28\\x29\\x7b\\x7d\\x5b\\x5d\\x7c\\x2c\\x2e\\x3f\\x2a\\x2b\\x2d\\x5e\\x24\\x3d\\x3c\\x3e\\x5c\\x2f\\x23\\x26\\x21\\x25\\x3a\\x3b\\x40\\x7e\\x27\\x22\\x60'
console.log(RegExp.escape('\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'));
// => '\\x09\\x0a\\x0b\\x0c\\x0d\\x20\\xa0\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\u2028\\u2029\\ufeff'
```
##### [`Promise.try`](https://github.com/tc39/proposal-promise-try)
Module [`esnext.promise.try`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.promise.try.js)
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/stage/2.7.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
var parent = require('./3');

// nothing
require('../proposals/regexp-escaping');

module.exports = parent;
1 change: 0 additions & 1 deletion packages/core-js/stage/2.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ require('../proposals/async-iterator-helpers');
require('../proposals/iterator-range');
require('../proposals/map-upsert-stage-2');
require('../proposals/promise-try');
require('../proposals/regexp-escaping');
require('../proposals/string-dedent');
require('../proposals/symbol-predicates-v2');
// TODO: Obsolete versions, remove from `core-js@4`
Expand Down

0 comments on commit 97f6a1e

Please sign in to comment.