From d6c615f2680e79bbb76cc85a056aadfe3524513f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 24 Jan 2015 11:07:01 -0800 Subject: Removed JS implementation, which is moving to its own repo: --- js/lib/from-code-point.js | 59 ----------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 js/lib/from-code-point.js (limited to 'js/lib/from-code-point.js') diff --git a/js/lib/from-code-point.js b/js/lib/from-code-point.js deleted file mode 100644 index a0557b3..0000000 --- a/js/lib/from-code-point.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; - -// derived from https://github.com/mathiasbynens/String.fromCodePoint -/*! http://mths.be/fromcodepoint v0.2.1 by @mathias */ -if (String.fromCodePoint) { - module.exports = function (_) { - try { - return String.fromCodePoint(_); - } catch (e) { - if (e instanceof RangeError) { - return String.fromCharCode(0xFFFD); - } - throw e; - } - }; - -} else { - - var stringFromCharCode = String.fromCharCode; - var floor = Math.floor; - var fromCodePoint = function() { - var MAX_SIZE = 0x4000; - var codeUnits = []; - var highSurrogate; - var lowSurrogate; - var index = -1; - var length = arguments.length; - if (!length) { - return ''; - } - var result = ''; - while (++index < length) { - var codePoint = Number(arguments[index]); - if ( - !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity` - codePoint < 0 || // not a valid Unicode code point - codePoint > 0x10FFFF || // not a valid Unicode code point - floor(codePoint) !== codePoint // not an integer - ) { - return String.fromCharCode(0xFFFD); - } - if (codePoint <= 0xFFFF) { // BMP code point - codeUnits.push(codePoint); - } else { // Astral code point; split in surrogate halves - // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae - codePoint -= 0x10000; - highSurrogate = (codePoint >> 10) + 0xD800; - lowSurrogate = (codePoint % 0x400) + 0xDC00; - codeUnits.push(highSurrogate, lowSurrogate); - } - if (index + 1 === length || codeUnits.length > MAX_SIZE) { - result += stringFromCharCode.apply(null, codeUnits); - codeUnits.length = 0; - } - } - return result; - }; - module.exports = fromCodePoint; -} -- cgit v1.2.3