|
970 | 970 | return res; |
971 | 971 | } |
972 | 972 |
|
973 | | - // ref: http://mths.be/fromcodepoint v0.1.0 by @mathias |
974 | | - /* if (!String.fromCodePoint) { |
975 | | - (function () { |
976 | | - var defineProperty = (function () { |
977 | | - // IE 8 only supports `Object.defineProperty` on DOM elements |
978 | | - try { |
979 | | - var object = {}; |
980 | | - var $defineProperty = Object.defineProperty; |
981 | | - var result = $defineProperty(object, object, object) && $defineProperty; |
982 | | - } catch (error) { |
983 | | - } |
984 | | - return result; |
985 | | - }()); |
986 | | - var stringFromCharCode = String.fromCharCode; |
987 | | - var floor = Math.floor; |
988 | | - var fromCodePoint = function () { |
989 | | - var MAX_SIZE = 0x4000; |
990 | | - var codeUnits = []; |
991 | | - var highSurrogate; |
992 | | - var lowSurrogate; |
993 | | - var index = -1; |
994 | | - var length = arguments.length; |
995 | | - if (!length) |
996 | | - return ''; |
997 | | - var result = ''; |
998 | | - while (++index < length) { |
999 | | - var codePoint = Number(arguments[index]); |
1000 | | - if ( |
1001 | | - !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity` |
1002 | | - codePoint < 0 || // not a valid Unicode code point |
1003 | | - codePoint > 0x10FFFF || // not a valid Unicode code point |
1004 | | - floor(codePoint) != codePoint // not an integer |
1005 | | - ) { |
1006 | | - throw RangeError('Invalid code point: ' + codePoint); |
1007 | | - } |
1008 | | - if (codePoint <= 0xFFFF) { // BMP code point |
1009 | | - codeUnits.push(codePoint); |
1010 | | - } else { // Astral code point; split in surrogate halves |
1011 | | - // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae |
1012 | | - codePoint -= 0x10000; |
1013 | | - highSurrogate = (codePoint >> 10) + 0xD800; |
1014 | | - lowSurrogate = (codePoint % 0x400) + 0xDC00; |
1015 | | - codeUnits.push(highSurrogate, lowSurrogate); |
1016 | | - } |
1017 | | - if (index + 1 == length || codeUnits.length > MAX_SIZE) { |
1018 | | - result += stringFromCharCode.apply(null, codeUnits); |
1019 | | - codeUnits.length = 0; |
1020 | | - } |
1021 | | - } |
1022 | | - return result; |
1023 | | - }; |
1024 | | - if (defineProperty) { |
1025 | | - defineProperty(String, 'fromCodePoint', { |
1026 | | - 'value': fromCodePoint, |
1027 | | - 'configurable': true, |
1028 | | - 'writable': true |
1029 | | - }); |
1030 | | - } else { |
1031 | | - String["fromCodePoint"] = fromCodePoint; |
1032 | | - } |
1033 | | - }()); |
1034 | | - } */ |
1035 | | - |
1036 | 973 | // ref: http://mths.be/codepointat v0.1.0 by @mathias |
1037 | 974 | if (!String.prototype.codePointAt) { |
1038 | 975 | (function() { |
|
0 commit comments