-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move well-formed unicode strings proposal to stage 4
- Loading branch information
Showing
37 changed files
with
218 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../string/virtual/is-well-formed'); | ||
var parent = require('../../stable/instance/is-well-formed'); | ||
|
||
var StringPrototype = String.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.isWellFormed; | ||
return typeof it == 'string' || it === StringPrototype | ||
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.isWellFormed) ? method : own; | ||
}; | ||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,3 @@ | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../string/virtual/to-well-formed'); | ||
var parent = require('../../stable/instance/to-well-formed'); | ||
|
||
var StringPrototype = String.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.toWellFormed; | ||
return typeof it == 'string' || it === StringPrototype | ||
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.toWellFormed) ? method : own; | ||
}; | ||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// TODO: Remove from `core-js@4` | ||
require('../../modules/esnext.string.is-well-formed'); | ||
|
||
module.exports = require('../../internals/entry-unbind')('String', 'isWellFormed'); | ||
var parent = require('../../stable/string/is-well-formed'); | ||
|
||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// TODO: Remove from `core-js@4` | ||
require('../../modules/esnext.string.to-well-formed'); | ||
|
||
module.exports = require('../../internals/entry-unbind')('String', 'toWellFormed'); | ||
var parent = require('../../stable/string/to-well-formed'); | ||
|
||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// TODO: Remove from `core-js@4` | ||
require('../../../modules/esnext.string.is-well-formed'); | ||
|
||
module.exports = require('../../../internals/entry-virtual')('String').isWellFormed; | ||
var parent = require('../../../stable/string/virtual/is-well-formed'); | ||
|
||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// TODO: Remove from `core-js@4` | ||
require('../../../modules/esnext.string.to-well-formed'); | ||
|
||
module.exports = require('../../../internals/entry-virtual')('String').toWellFormed; | ||
var parent = require('../../../stable/string/virtual/to-well-formed'); | ||
|
||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../string/virtual/is-well-formed'); | ||
|
||
var StringPrototype = String.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.isWellFormed; | ||
return typeof it == 'string' || it === StringPrototype | ||
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.isWellFormed) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var isPrototypeOf = require('../../internals/object-is-prototype-of'); | ||
var method = require('../string/virtual/to-well-formed'); | ||
|
||
var StringPrototype = String.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.toWellFormed; | ||
return typeof it == 'string' || it === StringPrototype | ||
|| (isPrototypeOf(StringPrototype, it) && own === StringPrototype.toWellFormed) ? method : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require('../../modules/es.string.is-well-formed'); | ||
|
||
module.exports = require('../../internals/entry-unbind')('String', 'isWellFormed'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require('../../modules/es.string.to-well-formed'); | ||
|
||
module.exports = require('../../internals/entry-unbind')('String', 'toWellFormed'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require('../../../modules/es.string.is-well-formed'); | ||
|
||
module.exports = require('../../../internals/entry-virtual')('String').isWellFormed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require('../../../modules/es.string.to-well-formed'); | ||
|
||
module.exports = require('../../../internals/entry-virtual')('String').toWellFormed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var requireObjectCoercible = require('../internals/require-object-coercible'); | ||
var toString = require('../internals/to-string'); | ||
|
||
var charCodeAt = uncurryThis(''.charCodeAt); | ||
|
||
// `String.prototype.isWellFormed` method | ||
// https://github.com/tc39/proposal-is-usv-string | ||
$({ target: 'String', proto: true }, { | ||
isWellFormed: function isWellFormed() { | ||
var S = toString(requireObjectCoercible(this)); | ||
var length = S.length; | ||
for (var i = 0; i < length; i++) { | ||
var charCode = charCodeAt(S, i); | ||
// single UTF-16 code unit | ||
if ((charCode & 0xF800) != 0xD800) continue; | ||
// unpaired surrogate | ||
if (charCode >= 0xDC00 || ++i >= length || (charCodeAt(S, i) & 0xFC00) != 0xDC00) return false; | ||
} return true; | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var call = require('../internals/function-call'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var requireObjectCoercible = require('../internals/require-object-coercible'); | ||
var toString = require('../internals/to-string'); | ||
var fails = require('../internals/fails'); | ||
|
||
var $Array = Array; | ||
var charAt = uncurryThis(''.charAt); | ||
var charCodeAt = uncurryThis(''.charCodeAt); | ||
var join = uncurryThis([].join); | ||
// eslint-disable-next-line es/no-string-prototype-iswellformed-towellformed -- safe | ||
var $toWellFormed = ''.toWellFormed; | ||
var REPLACEMENT_CHARACTER = '\uFFFD'; | ||
|
||
// Safari bug | ||
var TO_STRING_CONVERSION_BUG = $toWellFormed && fails(function () { | ||
return call($toWellFormed, 1) !== '1'; | ||
}); | ||
|
||
// `String.prototype.toWellFormed` method | ||
// https://github.com/tc39/proposal-is-usv-string | ||
$({ target: 'String', proto: true, forced: TO_STRING_CONVERSION_BUG }, { | ||
toWellFormed: function toWellFormed() { | ||
var S = toString(requireObjectCoercible(this)); | ||
if (TO_STRING_CONVERSION_BUG) return call($toWellFormed, S); | ||
var length = S.length; | ||
var result = $Array(length); | ||
for (var i = 0; i < length; i++) { | ||
var charCode = charCodeAt(S, i); | ||
// single UTF-16 code unit | ||
if ((charCode & 0xF800) != 0xD800) result[i] = charAt(S, i); | ||
// unpaired surrogate | ||
else if (charCode >= 0xDC00 || i + 1 >= length || (charCodeAt(S, i + 1) & 0xFC00) != 0xDC00) result[i] = REPLACEMENT_CHARACTER; | ||
// surrogate pair | ||
else { | ||
result[i] = charAt(S, i); | ||
result[++i] = charAt(S, i); | ||
} | ||
} return join(result, ''); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,2 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var requireObjectCoercible = require('../internals/require-object-coercible'); | ||
var toString = require('../internals/to-string'); | ||
|
||
var charCodeAt = uncurryThis(''.charCodeAt); | ||
|
||
// `String.prototype.isWellFormed` method | ||
// https://github.com/tc39/proposal-is-usv-string | ||
$({ target: 'String', proto: true }, { | ||
isWellFormed: function isWellFormed() { | ||
var S = toString(requireObjectCoercible(this)); | ||
var length = S.length; | ||
for (var i = 0; i < length; i++) { | ||
var charCode = charCodeAt(S, i); | ||
// single UTF-16 code unit | ||
if ((charCode & 0xF800) != 0xD800) continue; | ||
// unpaired surrogate | ||
if (charCode >= 0xDC00 || ++i >= length || (charCodeAt(S, i) & 0xFC00) != 0xDC00) return false; | ||
} return true; | ||
} | ||
}); | ||
// TODO: Remove from `core-js@4` | ||
require('../modules/es.string.is-well-formed'); |
Oops, something went wrong.