ohctechv3/.svn/pristine/e6/e629452c91c2bd6d50e4c83051c1e2454f9966bd.svn-base
2024-10-28 15:03:36 +05:30

26 lines
735 B
Plaintext

'use strict';
var $TypeError = require('es-errors/type');
var UTF16EncodeCodePoint = require('./UTF16EncodeCodePoint');
var IsArray = require('./IsArray');
var forEach = require('../helpers/forEach');
var isCodePoint = require('../helpers/isCodePoint');
// https://262.ecma-international.org/12.0/#sec-codepointstostring
module.exports = function CodePointsToString(text) {
if (!IsArray(text)) {
throw new $TypeError('Assertion failed: `text` must be a sequence of Unicode Code Points');
}
var result = '';
forEach(text, function (cp) {
if (!isCodePoint(cp)) {
throw new $TypeError('Assertion failed: `text` must be a sequence of Unicode Code Points');
}
result += UTF16EncodeCodePoint(cp);
});
return result;
};