Sha256: fe8625262f23b4fbd2a1d1d3b582fbd1bdeaf8dc682904e6ec4138a5d0c22628

Contents?: true

Size: 1.02 KB

Versions: 46

Compression:

Stored size: 1.02 KB

Contents

// Based on:
// http://norbertlindenberg.com/2012/05/ecmascript-supplementary-characters/
// and:
// https://github.com/mathiasbynens/String.fromCodePoint/blob/master
// /fromcodepoint.js

"use strict";

var floor = Math.floor, fromCharCode = String.fromCharCode;

// eslint-disable-next-line no-unused-vars
module.exports = function (codePoint1 /*, …codePoints*/) {
	var chars = [], length = arguments.length, i, codePoint, result = "";
	for (i = 0; i < length; ++i) {
		codePoint = Number(arguments[i]);
		if (
			!isFinite(codePoint) ||
			codePoint < 0 ||
			codePoint > 0x10ffff ||
			floor(codePoint) !== codePoint
		) {
			throw new RangeError("Invalid code point " + codePoint);
		}

		if (codePoint < 0x10000) {
			chars.push(codePoint);
		} else {
			codePoint -= 0x10000;
			// eslint-disable-next-line no-bitwise
			chars.push((codePoint >> 10) + 0xd800, codePoint % 0x400 + 0xdc00);
		}
		if (i + 1 !== length && chars.length <= 0x4000) continue;
		result += fromCharCode.apply(null, chars);
		chars.length = 0;
	}
	return result;
};

Version data entries

46 entries across 46 versions & 3 rubygems

Version Path
govuk_publishing_components-18.0.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.21.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.20.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.19.1 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.19.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.18.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.17.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.16.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.15.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.14.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.13.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.12.2 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.12.1 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.12.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.11.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.10.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.9.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.8.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.7.0 node_modules/es5-ext/string/from-code-point/shim.js
govuk_publishing_components-17.6.1 node_modules/es5-ext/string/from-code-point/shim.js