获取源文件的位置信息

@param {Number} offset
@return {Object}
481651
function getSourceLocation(offset) {
  const lines = new Error().stack.split(/\n/);
  const line = lines[offset] || '';
  const ret = line.match(/at (.*):(\d+):(\d+)/);
  if (!ret) {
    return { file: '', line: 0, column: 0, info: '' };
  }
  let file = ret[1];
  const ret2 = file.match(/\((.*)/);
  if (ret2) {
    file = ret2[1];
  }
  const lineNum = Number(ret[2] || 0);
  const column = Number(ret[3] || 0);
  return {
    file,
    line: lineNum,
    column,
    info: `${ file }:${ lineNum }:${ column }`,
  };
}
654518
function _offsetPos(pos, offset) {
        return {line: pos.line, ch: pos.ch + offset};
    }
1058749
def _get_offset_from_gcs(self):
    
    headers = {'content-range': 'bytes */*'}
    status, response_headers, content = self._api.put_object(
        self._path_with_token, headers=headers)
    errors.check_status(status, [308], self._path, headers,
                        response_headers, content,
                        {'upload_path': self._path_with_token})
    val = response_headers.get('range')
    if val is None:
      return -1
    _, offset = val.rsplit('-', 1)
    return int(offset)
36836
function get(data) {
    if ('string' === typeof data) return { content: data };
    if (data.readme) return { content: data.readme, file: 'readme' };
    if (data.content) return data;
  }
31394
function (node, offset) {
      if (typeof offset === 'undefined') {
        offset = node.nodeType === 3 ? node.length : node.childNodes.length;
      }

      while (node && node.hasChildNodes()) {
        node = node.childNodes[offset];
        if (node) {
          offset = node.nodeType === 3 ? node.length : node.childNodes.length;
        }
      }
      return { node: node, offset: offset };
    }
457880
function getLineInfo(input, offset) {
  for (var line = 0, cur = 0;;) {
    _whitespace.lineBreakG.lastIndex = cur;
    var match = _whitespace.lineBreakG.exec(input);
    if (match && match.index < offset) {
      ++line;
      cur = match.index + match[0].length;
    } else {
      return new Position(line, offset - cur);
    }
  }
}
1016279
function(err, str, fileDetails) {
      if (err) {
        return cb(err);
      }

      var res = {
        stream: str,
        type: fileDetails.contentType,
        length: fileDetails.length,
        name: fileDetails.filename
      };
      return cb(undefined, res);
    }
1029916
function(target, targetOffset, offset, length) {
    return this.toBuffer().copy(target, targetOffset, offset, length);
  }
910066
function(offset) {
        var index = this._indexArray,
            l = this.index_pointer;
        index[0 + l] = 0 + offset;
        index[1 + l] = 1 + offset;
        index[2 + l] = 2 + offset;
        index[3 + l] = 1 + offset;
        index[4 + l] = 2 + offset;
        index[5 + l] = 3 + offset;
        this.index_pointer += 6;
    }
686062
function FileKeyInfo(file) {
  this.file = file

  this.getKeyInfo = function(key, prefix) {
    prefix = prefix || ''
    prefix = prefix ? prefix + ':' : prefix
    return "<" + prefix + "X509Data></" + prefix + "X509Data>"
  }

  this.getKey = function(keyInfo) {
    return fs.readFileSync(this.file)
  }
}
1370341
function(ln, offset) {
  var rest = ln.slice(offset);
  var match;
  var spaces_after_marker;
  var data = {};
  if (rest.match(reHrule)) {
    return null;
  }
  if ((match = rest.match(/^[*+-]( +|$)/))) {
    spaces_after_marker = match[1].length;
    data.type = 'Bullet';
    data.bullet_char = match[0].charAt(0);

  } else if ((match = rest.match(/^(\d+)([.)])( +|$)/))) {
    spaces_after_marker = match[3].length;
    data.type = 'Ordered';
    data.start = parseInt(match[1]);
    data.delimiter = match[2];
  } else {
    return null;
  }
  var blank_item = match[0].length === rest.length;
  if (spaces_after_marker >= 5 ||
      spaces_after_marker < 1 ||
      blank_item) {
        data.padding = match[0].length - spaces_after_marker + 1;
  } else {
        data.padding = match[0].length;
  }
  return data;
}
1229260
public int peek(int offset) throws IOException {
        if(this.count < 0) {
            return EOF;
        }

        if(offset < 0) {
            throw new java.lang.IllegalArgumentException("offset must be >= 0");
        }

        /**
         * 实际请求位置
         */
        int i = this.index + offset;

        if(i < this.count) {
            return this.buffer[i];
        }

        /**
         * �?��读取新数�?         * 先将旧的数据移动到buffer的起始位�?         */
        if(this.index > 0) {
            if(this.count - this.index > 0) {
                System.arraycopy(this.buffer, this.index, this.buffer, 0, this.count - this.index);
            }
            this.count = this.count - this.index;
            this.index = 0;
        }

        /**
         * 如果请求位置超出了buffer容量
         */
        if(offset > this.buffer.length) {
            /**
             * 扩容, 确保容量超过请求位置
             * 新的容量大小是当前bufferSize的�?�?             */
            int bufferSize = (offset / this.buffer.length + 1) * this.buffer.length;
            char[] cbuf = new char[bufferSize];
            System.arraycopy(this.buffer, 0, cbuf, 0, this.count);
            this.buffer = cbuf;
        }

        /**
         * 读取新数�?         */
        int length = this.reader.read(this.buffer, this.count, this.buffer.length - this.count);

        if(length > 0) {
            this.count = this.count + length;
        }

        if(offset < this.count) {
            return this.buffer[offset];
        }
        return EOF;
    }
274025
def _read_offset_value(self, f, offset, size):
        '''
        
        '''
        f.seek(offset, 0)
        if (size == 8):
            return int.from_bytes(f.read(8), 'big', signed=True)
        else:
            return int.from_bytes(f.read(4), 'big', signed=True)
261660
function(file) {
      return {
        name: file.name,
        size: file.size,
        lastModifiedDate: file.lastModifiedDate
      };
    }
1304294
public int read(long fileOffset, byte []buffer, int offset, int length)
    throws IOException
  {
    log.info("random-read(0x" + Long.toHexString(fileOffset) + "," + 
             length + ")");
    
    return _file.read(fileOffset, buffer, offset, length);
  }
293968
public String getString(int offset)
   {
      String result = null;
      byte[] data = getByteArray(offset);
      if (data != null)
      {
         result = new String(data);
      }

      return (result);
   }
1174747
function getFileMIME(file) {
  var idx = file.lastIndexOf('.')
  var ext = idx > -1 ? file.slice(idx) : null
  if (ext) ext = ext.toLowerCase().substring(1)
  return MIMES[ext] || MIMES.txt
}