How to use the long.fromBits function in long

To help you get started, weā€™ve selected a few long 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 interledgerjs / ilp / src / lib / psk2.js View on Github external
function highLowToBigNumber (highLow) {
  // TODO use a more efficient method to convert this
  const long = Long.fromBits(highLow[1], highLow[0], true)
  return new BigNumber(long.toString(10))
}
github adobe / node-smb-server / lib / smb / cmd / trans2 / trans2_set_file_information.js View on Github external
data: utils.EMPTY_BUFFER
          };
        } else {
          result = {
            status: ntstatus.STATUS_SUCCESS,
            params: eaErrorOffset,  // EaErrorOffset
            data: utils.EMPTY_BUFFER
          };
        }
        cb(result);
      });
      return;

    case SMB.SET_FILE_ALLOCATION_INFO:
    case SMB.FILE_ALLOCATION_INFORMATION:
      var allocationSize = Long.fromBits(commandData.readUInt32LE(0), commandData.readUInt32LE(4), true).toNumber();
      if (!allocationSize && file.size()) {
        file.setLength(0, function (err) {
          if (err) {
            logger.error(err);
            result = {
              status: err.status || ntstatus.STATUS_UNSUCCESSFUL,
              params: utils.EMPTY_BUFFER,
              data: utils.EMPTY_BUFFER
            };
          } else {
            result = {
              status: ntstatus.STATUS_SUCCESS,
              params: eaErrorOffset,  // EaErrorOffset
              data: utils.EMPTY_BUFFER
            };
          }
github datastax / nodejs-driver / test / unit / mutable-long-tests.js View on Github external
].forEach(function (item) {
        const a = Long.fromBits(item[0].getLowBitsUnsigned(), item[0].getHighBitsUnsigned(), false);
        const b = Long.fromBits(item[1].getLowBitsUnsigned(), item[1].getHighBitsUnsigned(), false);
        const c = Long.fromBits(item[2].getLowBitsUnsigned(), item[2].getHighBitsUnsigned(), false);
        assert.ok(a.multiply(b).equals(c));
        assert.ok(item[0].multiply(item[1]).equals(item[2]));
      });
    });
github saul / demofile / props.js View on Github external
/*eslint-enable no-unreachable*/
    } else {
      var highInt = 0;
      var lowInt = 0;
      var neg = false;

      if ((this.flags & SPROP_UNSIGNED) !== 0) {
        lowInt = this.bitbuf.readUBits(32);
        highInt = this.bitbuf.readUBits(this.sendProp.numBits - 32);
      } else {
        neg = this.bitbuf.readOneBit() !== 0;
        lowInt = this.bitbuf.readUBits(32);
        highInt = this.bitbuf.readUBits(this.sendProp.numBits - 32 - 1);
      }

      return Long.fromBits(lowInt, highInt, !neg);
    }
  }
github gabyx / ExecutionGraph / gui / executionGraphGui / client / apps / eg / src / app / services / Conversions.ts View on Github external
export function toLong(value: flatbuffers.Long): Long {
  return Long.fromBits(value.low, value.high, false);
}
github alfa-laboratory / thrift-api-ui / src / renderer / thrift / patchedThrift.ts View on Github external
poolReadFrom(destResult: any, buffer: any, offset: number) {
        const value = Long.fromBits(
            buffer.readInt32BE(offset + 4, 4, true),
            buffer.readInt32BE(offset, 4, true)
        );
        return destResult.reset(null, offset + 8, value);
    }
github blinksocks / blinksocks / src / presets / ssr-auth-chain.js View on Github external
init_from_bin_datalen: function init_from_bin_datalen(bin, datalen) {
      let buf = Buffer.concat([bin, Buffer.alloc(16)]);
      buf = Buffer.concat([ntb(datalen, 2, BYTE_ORDER_LE), buf.slice(2)]);
      v0 = Long.fromBits(buf.readUInt32LE(0), buf.readUInt32LE(4), true);
      v1 = Long.fromBits(buf.readUInt32LE(8), buf.readUInt32LE(12), true);
      [0, 0, 0, 0].forEach(() => void this.next());
    }
  };
github nemtech / nem2-sdk-typescript-javascript / src / model / transaction / TransferTransaction.ts View on Github external
return this.mosaics.sort((a, b) => {
            const long_a = Long.fromBits(a.id.id.lower, a.id.id.higher, true);
            const long_b = Long.fromBits(b.id.id.lower, b.id.id.higher, true);
            return long_a.compare(long_b);
        });
    }
github adobe / node-smb-server / lib / smb / cmd / trans2 / trans2_set_fs_information.js View on Github external
case SMB.FILE_DISPOSITION_INFORMATION:
      var deletePending = !!commandData.readUInt8(0);
      if (deletePending) {
        logger.debug('%s, fid: %d [fileName: %s], deletePending: %d', SMB.SET_INFORMATION_LEVEL_TO_STRING[informationLevel], fid, fileName, deletePending);
        file.setDeleteOnClose();
      }
      result = {
        status: ntstatus.STATUS_SUCCESS,
        params: ntstatus.STATUS_SUCCESS,
        data: utils.EMPTY_BUFFER
      };
      process.nextTick(function () { cb(result); });
      return;

    case SMB.FILE_END_OF_FILE_INFORMATION:
      var endOfFile = Long.fromBits(commandData.readUInt32LE(0), commandData.readUInt32LE(4), true).toNumber();
      file.setLength(endOfFile, function (err) {
        if (err) {
          logger.error(err);
          result = {
            status: err.status || ntstatus.STATUS_UNSUCCESSFUL,
            params: utils.EMPTY_BUFFER,
            data: utils.EMPTY_BUFFER
          };
        } else {
          result = {
            status: ntstatus.STATUS_SUCCESS,
            params: ntstatus.STATUS_SUCCESS,
            data: utils.EMPTY_BUFFER
          };
        }
        cb(result);
github microsoft / onnxjs / lib / tensor.ts View on Github external
return view.getUint8(byteOffset);
    case onnx.TensorProto.DataType.INT8:
      return view.getInt8(byteOffset);
    case onnx.TensorProto.DataType.UINT16:
      return view.getUint16(byteOffset, true);
    case onnx.TensorProto.DataType.INT16:
      return view.getInt16(byteOffset, true);
    case onnx.TensorProto.DataType.FLOAT:
      return view.getFloat32(byteOffset, true);
    case onnx.TensorProto.DataType.INT32:
      return view.getInt32(byteOffset, true);
    case onnx.TensorProto.DataType.UINT32:
      return view.getUint32(byteOffset, true);
    case onnx.TensorProto.DataType.INT64:
      return longToNumber(
          Long.fromBits(view.getUint32(byteOffset, true), view.getUint32(byteOffset + 4, true), false), type);
    case onnx.TensorProto.DataType.DOUBLE:
      return view.getFloat64(byteOffset, true);
    case onnx.TensorProto.DataType.UINT64:
      return longToNumber(
          Long.fromBits(view.getUint32(byteOffset, true), view.getUint32(byteOffset + 4, true), true), type);
    default:
      throw new Error(`cannot read from DataView for type ${onnx.TensorProto.DataType[type]}`);
  }
}