Last change
on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | var $ = require('../internals/export');
|
---|
2 | var toAbsoluteIndex = require('../internals/to-absolute-index');
|
---|
3 |
|
---|
4 | var fromCharCode = String.fromCharCode;
|
---|
5 | // eslint-disable-next-line es/no-string-fromcodepoint -- required for testing
|
---|
6 | var $fromCodePoint = String.fromCodePoint;
|
---|
7 |
|
---|
8 | // length should be 1, old FF problem
|
---|
9 | var INCORRECT_LENGTH = !!$fromCodePoint && $fromCodePoint.length != 1;
|
---|
10 |
|
---|
11 | // `String.fromCodePoint` method
|
---|
12 | // https://tc39.es/ecma262/#sec-string.fromcodepoint
|
---|
13 | $({ target: 'String', stat: true, forced: INCORRECT_LENGTH }, {
|
---|
14 | // eslint-disable-next-line no-unused-vars -- required for `.length`
|
---|
15 | fromCodePoint: function fromCodePoint(x) {
|
---|
16 | var elements = [];
|
---|
17 | var length = arguments.length;
|
---|
18 | var i = 0;
|
---|
19 | var code;
|
---|
20 | while (length > i) {
|
---|
21 | code = +arguments[i++];
|
---|
22 | if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw RangeError(code + ' is not a valid code point');
|
---|
23 | elements.push(code < 0x10000
|
---|
24 | ? fromCharCode(code)
|
---|
25 | : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00)
|
---|
26 | );
|
---|
27 | } return elements.join('');
|
---|
28 | }
|
---|
29 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.