Skip to content

Commit d6ad38c

Browse files
committed
move Well-Formed Unicode Strings proposal to stage 3
1 parent 26e0e6d commit d6ad38c

25 files changed

+100
-74
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Changelog
22
##### Unreleased
3+
- [Well-Formed Unicode Strings](https://github.com/tc39/proposal-is-usv-string) proposal:
4+
- Methods:
5+
- `String.prototype.isWellFormed`
6+
- `String.prototype.toWellFormed`
7+
- Moved to Stage 3, [November TC39 meeting](https://github.com/babel/proposals/issues/85#issuecomment-1332180862)
8+
- Added `/actual/` entries, disabled unconditional forced replacement
39
- Fixed a theoretically possible future conflict of polyfills definitions in the pure version
410
- [Compat data targets](/packages/core-js-compat#targets-option) improvements:
511
- [React Native from 0.70 shipped with Hermes as the default engine.](https://reactnative.dev/blog/2022/07/08/hermes-as-the-default) However, bundled Hermes versions differ from standalone Hermes releases. So added **`react-native`** target for React Native with bundled Hermes.

README.md

+23-23
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ queueMicrotask(() => console.log('called as microtask'));
128128
- [`Array.fromAsync`](#arrayfromasync)
129129
- [`Array` grouping](#array-grouping)
130130
- [Change `Array` by copy](#change-array-by-copy)
131+
- [Well-formed unicode strings](#well-formed-unicode-strings)
131132
- [Stage 2 proposals](#stage-2-proposals)
132133
- [`Iterator` helpers](#iterator-helpers)
133134
- [New `Set` methods](#new-set-methods)
134135
- [`Map.prototype.emplace`](#mapprototypeemplace)
135136
- [`Array.isTemplateObject`](#arrayistemplateobject)
136-
- [Well-formed unicode strings](#well-formed-unicode-strings)
137137
- [`Symbol.{ asyncDispose, dispose }` for `using` statement](#symbol-asyncdispose-dispose--for-using-statement)
138138
- [`Symbol.metadataKey` for decorators metadata proposal](#symbolmetadatakey-for-decorators-metadata-proposal)
139139
- [Stage 1 proposals](#stage-1-proposals)
@@ -2174,6 +2174,28 @@ const correctionNeeded = [1, 1, 3];
21742174
correctionNeeded.with(1, 2); // => [1, 2, 3]
21752175
correctionNeeded; // => [1, 1, 3]
21762176
````
2177+
##### [Well-formed unicode strings](https://github.com/tc39/proposal-is-usv-string)[⬆](#index)
2178+
Modules [`esnext.string.is-well-formed`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.string.is-well-formed.js) and [`esnext.string.to-well-formed`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.string.to-well-formed.js)
2179+
```js
2180+
class String {
2181+
isWellFormed(): boolean;
2182+
toWellFormed(): string;
2183+
}
2184+
```
2185+
[*CommonJS entry points:*](#commonjs-api)
2186+
```js
2187+
core-js/proposals/well-formed-unicode-strings
2188+
core-js(-pure)/actual|full/string(/virtual)/is-well-formed
2189+
core-js(-pure)/actual|full/string(/virtual)/to-well-formed
2190+
```
2191+
[*Examples*](https://tinyurl.com/2fulc2ak):
2192+
```js
2193+
'a💩b'.isWellFormed(); // => true
2194+
'a\uD83Db'.isWellFormed(); // => false
2195+
2196+
'a💩b'.toWellFormed(); // => 'a💩b'
2197+
'a\uD83Db'.toWellFormed(); // => 'a�b'
2198+
```
21772199

21782200
#### Stage 2 proposals[⬆](#index)
21792201
[*CommonJS entry points:*](#commonjs-api)
@@ -2361,28 +2383,6 @@ core-js(-pure)/full/array/is-template-object
23612383
```js
23622384
console.log(Array.isTemplateObject((it => it)`qwe${ 123 }asd`)); // => true
23632385
```
2364-
##### [Well-formed unicode strings](https://github.com/tc39/proposal-is-usv-string)[⬆](#index)
2365-
Modules [`esnext.string.is-well-formed`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.string.is-well-formed.js) and [`esnext.string.to-well-formed`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.string.to-well-formed.js)
2366-
```js
2367-
class String {
2368-
isWellFormed(): boolean;
2369-
toWellFormed(): string;
2370-
}
2371-
```
2372-
[*CommonJS entry points:*](#commonjs-api)
2373-
```js
2374-
core-js/proposals/well-formed-unicode-strings
2375-
core-js(-pure)/full/string(/virtual)/is-well-formed
2376-
core-js(-pure)/full/string(/virtual)/to-well-formed
2377-
```
2378-
[*Examples*](https://tinyurl.com/2fulc2ak):
2379-
```js
2380-
'a💩b'.isWellFormed(); // => true
2381-
'a\uD83Db'.isWellFormed(); // => false
2382-
2383-
'a💩b'.toWellFormed(); // => 'a💩b'
2384-
'a\uD83Db'.toWellFormed(); // => 'a�b'
2385-
```
23862386
##### [`Symbol.{ asyncDispose, dispose }` for `using` statement](https://github.com/tc39/proposal-using-statement)[⬆](#index)
23872387
Modules [`esnext.symbol.dispose`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.symbol.dispose.js) and [`esnext.symbol.async-dispose`](https://github.com/zloirock/core-js/blob/master/packages/core-js/modules/esnext.symbol.async-dispose.js).
23882388
```js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var isPrototypeOf = require('../../internals/object-is-prototype-of');
2+
var method = require('../string/virtual/is-well-formed');
3+
4+
var StringPrototype = String.prototype;
5+
6+
module.exports = function (it) {
7+
var own = it.isWellFormed;
8+
return typeof it == 'string' || it === StringPrototype
9+
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.isWellFormed) ? method : own;
10+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var isPrototypeOf = require('../../internals/object-is-prototype-of');
2+
var method = require('../string/virtual/to-well-formed');
3+
4+
var StringPrototype = String.prototype;
5+
6+
module.exports = function (it) {
7+
var own = it.toWellFormed;
8+
return typeof it == 'string' || it === StringPrototype
9+
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.toWellFormed) ? method : own;
10+
};
+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
var parent = require('../../stable/string');
22

3+
require('../../modules/esnext.string.is-well-formed');
4+
require('../../modules/esnext.string.to-well-formed');
5+
36
module.exports = parent;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require('../../modules/esnext.string.is-well-formed');
2+
3+
module.exports = require('../../internals/entry-unbind')('String', 'isWellFormed');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require('../../modules/esnext.string.to-well-formed');
2+
3+
module.exports = require('../../internals/entry-unbind')('String', 'toWellFormed');
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
var parent = require('../../../stable/string/virtual');
22

3+
require('../../../modules/esnext.string.is-well-formed');
4+
require('../../../modules/esnext.string.to-well-formed');
5+
36
module.exports = parent;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require('../../../modules/esnext.string.is-well-formed');
2+
3+
module.exports = require('../../../internals/entry-virtual')('String').isWellFormed;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
require('../../../modules/esnext.string.to-well-formed');
2+
3+
module.exports = require('../../../internals/entry-virtual')('String').toWellFormed;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
var isPrototypeOf = require('../../internals/object-is-prototype-of');
2-
var method = require('../string/virtual/is-well-formed');
1+
var parent = require('../../actual/instance/is-well-formed');
32

4-
var StringPrototype = String.prototype;
5-
6-
module.exports = function (it) {
7-
var own = it.isWellFormed;
8-
return typeof it == 'string' || it === StringPrototype
9-
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.isWellFormed) ? method : own;
10-
};
3+
module.exports = parent;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
var isPrototypeOf = require('../../internals/object-is-prototype-of');
2-
var method = require('../string/virtual/to-well-formed');
1+
var parent = require('../../actual/instance/to-well-formed');
32

4-
var StringPrototype = String.prototype;
5-
6-
module.exports = function (it) {
7-
var own = it.toWellFormed;
8-
return typeof it == 'string' || it === StringPrototype
9-
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.toWellFormed) ? method : own;
10-
};
3+
module.exports = parent;

packages/core-js/full/string/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ var parent = require('../../actual/string');
33
require('../../modules/esnext.string.at');
44
require('../../modules/esnext.string.cooked');
55
require('../../modules/esnext.string.code-points');
6-
require('../../modules/esnext.string.is-well-formed');
76
// TODO: remove from `core-js@4`
87
require('../../modules/esnext.string.match-all');
98
require('../../modules/esnext.string.replace-all');
10-
require('../../modules/esnext.string.to-well-formed');
119

1210
module.exports = parent;
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
require('../../modules/esnext.string.is-well-formed');
1+
var parent = require('../../actual/string/is-well-formed');
22

3-
module.exports = require('../../internals/entry-unbind')('String', 'isWellFormed');
3+
module.exports = parent;
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
require('../../modules/esnext.string.to-well-formed');
1+
var parent = require('../../actual/string/to-well-formed');
22

3-
module.exports = require('../../internals/entry-unbind')('String', 'toWellFormed');
3+
module.exports = parent;

packages/core-js/full/string/virtual/index.js

-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ var parent = require('../../../actual/string/virtual');
22
// TODO: remove from `core-js@4`
33
require('../../../modules/esnext.string.at');
44
require('../../../modules/esnext.string.code-points');
5-
require('../../../modules/esnext.string.is-well-formed');
65
// TODO: remove from `core-js@4`
76
require('../../../modules/esnext.string.match-all');
87
require('../../../modules/esnext.string.replace-all');
9-
require('../../../modules/esnext.string.to-well-formed');
108

119
module.exports = parent;
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
require('../../../modules/esnext.string.is-well-formed');
1+
var parent = require('../../../actual/string/virtual/is-well-formed');
22

3-
module.exports = require('../../../internals/entry-virtual')('String').isWellFormed;
3+
module.exports = parent;
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
require('../../../modules/esnext.string.to-well-formed');
1+
var parent = require('../../../actual/string/virtual/to-well-formed');
22

3-
module.exports = require('../../../internals/entry-virtual')('String').toWellFormed;
3+
module.exports = parent;

packages/core-js/modules/esnext.string.is-well-formed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var charCodeAt = uncurryThis(''.charCodeAt);
88

99
// `String.prototype.isWellFormed` method
1010
// https://github.com/tc39/proposal-is-usv-string
11-
$({ target: 'String', proto: true, forced: true }, {
11+
$({ target: 'String', proto: true }, {
1212
isWellFormed: function isWellFormed() {
1313
var S = toString(requireObjectCoercible(this));
1414
var length = S.length;

packages/core-js/modules/esnext.string.to-well-formed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ var REPLACEMENT_CHARACTER = '\uFFFD';
1212

1313
// `String.prototype.toWellFormed` method
1414
// https://github.com/tc39/proposal-is-usv-string
15-
$({ target: 'String', proto: true, forced: true }, {
15+
$({ target: 'String', proto: true }, {
1616
toWellFormed: function toWellFormed() {
1717
var S = toString(requireObjectCoercible(this));
1818
var length = S.length;

packages/core-js/stage/2.js

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ require('../proposals/iterator-helpers');
66
require('../proposals/map-upsert-stage-2');
77
require('../proposals/set-methods');
88
require('../proposals/using-statement');
9-
require('../proposals/well-formed-unicode-strings');
109
// TODO: Obsolete versions, remove from `core-js@4`
1110
require('../proposals/array-grouping');
1211
require('../proposals/decorators');

packages/core-js/stage/3.js

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var parent = require('./4');
33
require('../proposals/array-from-async-stage-2');
44
require('../proposals/array-grouping-stage-3-2');
55
require('../proposals/change-array-by-copy');
6+
require('../proposals/well-formed-unicode-strings');
67
// TODO: Obsolete versions, remove from `core-js@4`
78
require('../proposals/array-grouping-stage-3');
89

tests/entries/unit.mjs

+16-16
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,10 @@ for (PATH of ['core-js-pure', 'core-js']) {
614614
ok(load(NS, 'array/virtual/to-reversed').call([1, 2, 3])[0] === 3);
615615
ok(load(NS, 'array/virtual/to-sorted').call([3, 2, 1])[0] === 1);
616616
ok(load(NS, 'array/virtual/to-spliced').call([3, 2, 1], 1, 1, 4, 5).length === 4);
617+
ok(load(NS, 'string/is-well-formed')('a'));
618+
ok(load(NS, 'string/virtual/is-well-formed').call('a'));
619+
ok(load(NS, 'string/to-well-formed')('a') === 'a');
620+
ok(load(NS, 'string/virtual/to-well-formed').call('a') === 'a');
617621

618622
const instanceGroup = load(NS, 'instance/group');
619623
ok(typeof instanceGroup == 'function');
@@ -662,6 +666,18 @@ for (PATH of ['core-js-pure', 'core-js']) {
662666
ok(instanceWith({}) === undefined);
663667
ok(typeof instanceWith([]) == 'function');
664668
ok(instanceWith([]).call([1, 2, 3], 1, 4)[1] === 4);
669+
670+
const instanceIsWellFormed = load(NS, 'instance/is-well-formed');
671+
ok(typeof instanceIsWellFormed == 'function');
672+
ok(instanceIsWellFormed({}) === undefined);
673+
ok(typeof instanceIsWellFormed('') == 'function');
674+
ok(instanceIsWellFormed('').call('a'));
675+
676+
const instanceToWellFormed = load(NS, 'instance/to-well-formed');
677+
ok(typeof instanceToWellFormed == 'function');
678+
ok(instanceToWellFormed({}) === undefined);
679+
ok(typeof instanceToWellFormed('') == 'function');
680+
ok(instanceToWellFormed('').call('a') === 'a');
665681
}
666682

667683
for (const NS of ['full', 'features']) {
@@ -787,10 +803,6 @@ for (PATH of ['core-js-pure', 'core-js']) {
787803
ok(load(NS, 'string/cooked')`a${ 1 }b` === 'a1b');
788804
ok('next' in load(NS, 'string/code-points')('a'));
789805
ok('next' in load(NS, 'string/virtual/code-points').call('a'));
790-
ok(load(NS, 'string/is-well-formed')('a'));
791-
ok(load(NS, 'string/virtual/is-well-formed').call('a'));
792-
ok(load(NS, 'string/to-well-formed')('a') === 'a');
793-
ok(load(NS, 'string/virtual/to-well-formed').call('a') === 'a');
794806
ok(load(NS, 'symbol/async-dispose'));
795807
ok(load(NS, 'symbol/dispose'));
796808
ok(load(NS, 'symbol/matcher'));
@@ -827,18 +839,6 @@ for (PATH of ['core-js-pure', 'core-js']) {
827839
ok(typeof instanceFilterReject([]) == 'function');
828840
ok(instanceFilterReject([]).call([1, 2, 3], it => it % 2).length === 1);
829841

830-
const instanceIsWellFormed = load(NS, 'instance/is-well-formed');
831-
ok(typeof instanceIsWellFormed == 'function');
832-
ok(instanceIsWellFormed({}) === undefined);
833-
ok(typeof instanceIsWellFormed('') == 'function');
834-
ok(instanceIsWellFormed('').call('a'));
835-
836-
const instanceToWellFormed = load(NS, 'instance/to-well-formed');
837-
ok(typeof instanceToWellFormed == 'function');
838-
ok(instanceToWellFormed({}) === undefined);
839-
ok(typeof instanceToWellFormed('') == 'function');
840-
ok(instanceToWellFormed('').call('a') === 'a');
841-
842842
const instanceUniqueBy = load(NS, 'instance/unique-by');
843843
ok(typeof instanceUniqueBy == 'function');
844844
ok(instanceUniqueBy({}) === undefined);

tests/unit-pure/esnext.string.is-well-formed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { STRICT } from '../helpers/constants';
22
import Symbol from 'core-js-pure/es/symbol';
3-
import isWellFormed from 'core-js-pure/full/string/virtual/is-well-formed';
3+
import isWellFormed from 'core-js-pure/actual/string/virtual/is-well-formed';
44

55
QUnit.test('String#isWellFormed', assert => {
66
assert.isFunction(isWellFormed);

tests/unit-pure/esnext.string.to-well-formed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { STRICT } from '../helpers/constants';
22
import Symbol from 'core-js-pure/es/symbol';
3-
import toWellFormed from 'core-js-pure/full/string/virtual/to-well-formed';
3+
import toWellFormed from 'core-js-pure/actual/string/virtual/to-well-formed';
44

55
QUnit.test('String#toWellFormed', assert => {
66
assert.isFunction(toWellFormed);

0 commit comments

Comments
 (0)