"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/code-point-at/index.js" (8 Mar 2017, 610 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /* eslint-disable babel/new-cap, xo/throw-new-error */
    2 'use strict';
    3 module.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 };