source: trip-planner-front/node_modules/code-point-at/index.js@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 610 bytes
Line 
1/* eslint-disable babel/new-cap, xo/throw-new-error */
2'use strict';
3module.exports = function (str, pos) {
4 if (str === null || str === undefined) {
5 throw TypeError();
6 }
7
8 str = String(str);
9
10 var size = str.length;
11 var i = pos ? Number(pos) : 0;
12
13 if (Number.isNaN(i)) {
14 i = 0;
15 }
16
17 if (i < 0 || i >= size) {
18 return undefined;
19 }
20
21 var first = str.charCodeAt(i);
22
23 if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
24 var second = str.charCodeAt(i + 1);
25
26 if (second >= 0xDC00 && second <= 0xDFFF) {
27 return ((first - 0xD800) * 0x400) + second - 0xDC00 + 0x10000;
28 }
29 }
30
31 return first;
32};
Note: See TracBrowser for help on using the repository browser.