Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

es.string.from-code-point.js 1.2KB

1234567891011121314151617181920212223242526272829303132
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var uncurryThis = require('../internals/function-uncurry-this');
  4. var toAbsoluteIndex = require('../internals/to-absolute-index');
  5. var $RangeError = RangeError;
  6. var fromCharCode = String.fromCharCode;
  7. // eslint-disable-next-line es/no-string-fromcodepoint -- required for testing
  8. var $fromCodePoint = String.fromCodePoint;
  9. var join = uncurryThis([].join);
  10. // length should be 1, old FF problem
  11. var INCORRECT_LENGTH = !!$fromCodePoint && $fromCodePoint.length !== 1;
  12. // `String.fromCodePoint` method
  13. // https://tc39.es/ecma262/#sec-string.fromcodepoint
  14. $({ target: 'String', stat: true, arity: 1, forced: INCORRECT_LENGTH }, {
  15. // eslint-disable-next-line no-unused-vars -- required for `.length`
  16. fromCodePoint: function fromCodePoint(x) {
  17. var elements = [];
  18. var length = arguments.length;
  19. var i = 0;
  20. var code;
  21. while (length > i) {
  22. code = +arguments[i++];
  23. if (toAbsoluteIndex(code, 0x10FFFF) !== code) throw new $RangeError(code + ' is not a valid code point');
  24. elements[i] = code < 0x10000
  25. ? fromCharCode(code)
  26. : fromCharCode(((code -= 0x10000) >> 10) + 0xD800, code % 0x400 + 0xDC00);
  27. } return join(elements, '');
  28. }
  29. });