]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/shim.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / node-gyp / node_modules / path-array / node_modules / array-index / node_modules / es6-symbol / node_modules / es5-ext / string / # / code-point-at / shim.js
1 // Based on: https://github.com/mathiasbynens/String.prototype.codePointAt
2 // Thanks @mathiasbynens !
3
4 'use strict';
5
6 var toInteger  = require('../../../number/to-integer')
7   , validValue = require('../../../object/valid-value');
8
9 module.exports = function (pos) {
10         var str = String(validValue(this)), l = str.length, first, second;
11         pos = toInteger(pos);
12
13         // Account for out-of-bounds indices:
14         if (pos < 0 || pos >= l) return undefined;
15
16         // Get the first code unit
17         first = str.charCodeAt(pos);
18         if ((first >= 0xD800) && (first <= 0xDBFF) && (l > pos + 1)) {
19                 second = str.charCodeAt(pos + 1);
20                 if (second >= 0xDC00 && second <= 0xDFFF) {
21                         // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
22                         return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
23                 }
24         }
25         return first;
26 };