How to use the cuint.UINT64 function in cuint

To help you get started, we’ve selected a few cuint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github commaai / cabana / src / models / can / dbc.js View on Github external
valueForInt64Signal(signalSpec, hexData) {
    const blen = hexData.length * 4;
    let value;
    let startBit;
    let dataBitPos;

    if (signalSpec.isLittleEndian) {
      value = UINT64(swapOrder(hexData, 16, 2), 16);
      startBit = signalSpec.startBit;
      dataBitPos = UINT64(startBit);
    } else {
      // big endian
      value = UINT64(hexData, 16);

      startBit = DbcUtils.bigEndianBitIndex(signalSpec.startBit);
      dataBitPos = UINT64(blen - (startBit + signalSpec.size));
    }
    if (dataBitPos < 0) {
      return null;
    }

    const rightHandAnd = UINT64(Math.pow(2, signalSpec.size) - 1);
    let ival = value
      .shiftr(dataBitPos)
      .and(rightHandAnd)
      .toNumber();

    if (signalSpec.isSigned && ival & Math.pow(2, signalSpec.size - 1)) {
      ival -= Math.pow(2, signalSpec.size);
    }
    ival = ival * signalSpec.factor + signalSpec.offset;
    return ival;
github onmyway133 / PushNotifications / node_modules / asar / lib / filesystem.js View on Github external
const handler = () => {
      const size = file.transformed ? file.transformed.stat.size : file.stat.size

      // JavaScript can not precisely present integers >= UINT32_MAX.
      if (size > 4294967295) {
        throw new Error(`${p}: file size can not be larger than 4.2GB`)
      }

      node.size = size
      node.offset = this.offset.toString()
      if (process.platform !== 'win32' && (file.stat.mode & 0o100)) {
        node.executable = true
      }
      this.offset.add(UINT64(size))

      return callback()
    }
github commaai / cabana / src / models / can / dbc.js View on Github external
if (signalSpec.isLittleEndian) {
      value = UINT64(swapOrder(hexData, 16, 2), 16);
      startBit = signalSpec.startBit;
      dataBitPos = UINT64(startBit);
    } else {
      // big endian
      value = UINT64(hexData, 16);

      startBit = DbcUtils.bigEndianBitIndex(signalSpec.startBit);
      dataBitPos = UINT64(blen - (startBit + signalSpec.size));
    }
    if (dataBitPos < 0) {
      return null;
    }

    const rightHandAnd = UINT64(Math.pow(2, signalSpec.size) - 1);
    let ival = value
      .shiftr(dataBitPos)
      .and(rightHandAnd)
      .toNumber();

    if (signalSpec.isSigned && ival & Math.pow(2, signalSpec.size - 1)) {
      ival -= Math.pow(2, signalSpec.size);
    }
    ival = ival * signalSpec.factor + signalSpec.offset;
    return ival;
  }
github electron / asar / lib / filesystem.js View on Github external
// JavaScript can not precisely present integers >= UINT32_MAX.
      if (size > UINT32_MAX) {
        const error = new Error(`${p}: file size can not be larger than 4.2GB`)
        if (reject) {
          return reject(error)
        } else {
          throw error
        }
      }

      node.size = size
      node.offset = this.offset.toString()
      if (process.platform !== 'win32' && (file.stat.mode & 0o100)) {
        node.executable = true
      }
      this.offset.add(UINT64(size))

      return resolve ? resolve() : Promise.resolve()
    }
github commaai / cabana / src / models / can / dbc.js View on Github external
valueForInt64Signal(signalSpec, hexData) {
    const blen = hexData.length * 4;
    let value;
    let startBit;
    let dataBitPos;

    if (signalSpec.isLittleEndian) {
      value = UINT64(swapOrder(hexData, 16, 2), 16);
      startBit = signalSpec.startBit;
      dataBitPos = UINT64(startBit);
    } else {
      // big endian
      value = UINT64(hexData, 16);

      startBit = DbcUtils.bigEndianBitIndex(signalSpec.startBit);
      dataBitPos = UINT64(blen - (startBit + signalSpec.size));
    }
    if (dataBitPos < 0) {
      return null;
    }

    const rightHandAnd = UINT64(Math.pow(2, signalSpec.size) - 1);
    let ival = value
      .shiftr(dataBitPos)
      .and(rightHandAnd)
      .toNumber();

    if (signalSpec.isSigned && ival & Math.pow(2, signalSpec.size - 1)) {
      ival -= Math.pow(2, signalSpec.size);
github pierrec / js-xxhash / lib / xxhash64.js View on Github external
/**
xxHash64 implementation in pure Javascript

Copyright (C) 2016, Pierre Curto
MIT license
*/
var UINT64 = require('cuint').UINT64

/*
 * Constants
 */
var PRIME64_1 = UINT64( '11400714785074694791' )
var PRIME64_2 = UINT64( '14029467366897019727' )
var PRIME64_3 = UINT64(  '1609587929392839161' )
var PRIME64_4 = UINT64(  '9650029242287828579' )
var PRIME64_5 = UINT64(  '2870177450012600261' )

/**
* Convert string to proper UTF-8 array
* @param str Input string
* @returns {Uint8Array} UTF8 array is returned as uint8 array
*/
function toUTF8Array (str) {
	var utf8 = []
	for (var i=0, n=str.length; i < n; i++) {
		var charcode = str.charCodeAt(i)
		if (charcode < 0x80) utf8.push(charcode)
		else if (charcode < 0x800) {
			utf8.push(0xc0 | (charcode >> 6),
			0x80 | (charcode & 0x3f))
github shanetechwiz / node-steamcardbot / bot.js View on Github external
function steamIdObjectToSteamId64(steamIdObject) {
	return new UInt64(steamIdObject.accountid, (steamIdObject.universe << 24) | (steamIdObject.type << 20) | (steamIdObject.instance)).toString();
}
github electron-userland / electron-builder / src / asarUtil.ts View on Github external
else {
          if (newData != null) {
            this.changedFiles.set(file, newData)
          }

          if (fileSize > 4294967295) {
            throw new Error(`${file}: file size can not be larger than 4.2GB`)
          }

          node.offset = this.fs.offset.toString()
          //noinspection JSBitwiseOperatorUsage
          if (process.platform !== "win32" && stat.mode & 0x40) {
            node.executable = true
          }
          this.toPack.push(file)
          this.fs.offset.add(UINT64(fileSize))
        }
      }
      else if (stat.isDirectory()) {
        let unpacked = false
        if (autoUnpackDirs.has(file)) {
          unpacked = true
        }
        else {
          unpacked = unpackDir != null && isUnpackDir(path.relative(this.src, file), unpackDir, this.options.unpackDir!)
          if (unpacked) {
            createDirPromises.push(ensureDir(path.join(unpackedDest, path.relative(this.src, file))))
          }
          else {
            for (let d of autoUnpackDirs) {
              if (file.length > (d.length + 2) && file[d.length] === path.sep && file.startsWith(d)) {
                unpacked = true
github pierrec / js-xxhash / lib / xxhash64.js View on Github external
/**
xxHash64 implementation in pure Javascript

Copyright (C) 2016, Pierre Curto
MIT license
*/
var UINT64 = require('cuint').UINT64

/*
 * Constants
 */
var PRIME64_1 = UINT64( '11400714785074694791' )
var PRIME64_2 = UINT64( '14029467366897019727' )
var PRIME64_3 = UINT64(  '1609587929392839161' )
var PRIME64_4 = UINT64(  '9650029242287828579' )
var PRIME64_5 = UINT64(  '2870177450012600261' )

/**
* Convert string to proper UTF-8 array
* @param str Input string
* @returns {Uint8Array} UTF8 array is returned as uint8 array
*/
function toUTF8Array (str) {
	var utf8 = []
	for (var i=0, n=str.length; i < n; i++) {
		var charcode = str.charCodeAt(i)
		if (charcode < 0x80) utf8.push(charcode)
		else if (charcode < 0x800) {
			utf8.push(0xc0 | (charcode >> 6),
			0x80 | (charcode & 0x3f))
		}
		else if (charcode < 0xd800 || charcode >= 0xe000) {

cuint

Unsigned integers for Javascript

MIT
Latest version published 8 years ago

Package Health Score

50 / 100
Full package analysis