1 | var $ = require('../internals/export');
|
2 | var toAbsoluteIndex = require('../internals/to-absolute-index');
|
3 |
|
4 | var fromCharCode = String.fromCharCode;
|
5 | var nativeFromCodePoint = String.fromCodePoint;
|
6 |
|
7 |
|
8 | var INCORRECT_LENGTH = !!nativeFromCodePoint && nativeFromCodePoint.length != 1;
|
9 |
|
10 |
|
11 |
|
12 | $({ target: 'String', stat: true, forced: INCORRECT_LENGTH }, {
|
13 | fromCodePoint: function fromCodePoint(x) {
|
14 | var elements = [];
|
15 | var length = arguments.length;
|
16 | var i = 0;
|
17 | var code;
|
18 | while (length > i) {
|
19 | code = +arguments[i++];
|
20 | if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw RangeError(code + ' is not a valid code point');
|
21 | elements.push(code < 0x10000
|
22 | ? fromCharCode(code)
|
23 | : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00)
|
24 | );
|
25 | } return elements.join('');
|
26 | }
|
27 | });
|