How to use the @xtuc/long.fromString function in @xtuc/long

To help you get started, we’ve selected a few @xtuc/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 xtuc / webassemblyjs / packages / helper-testsuite-runner / src / asserts.js View on Github external
case "f32": {
      const actuali32 = actual.value.reinterpret();
      const expectedi32 = Long.fromString(expected.value).toInt();

      assert(
        actuali32.toNumber() === expectedi32,
        `Expected value ${expectedi32}, got ${actuali32.toString()}`
      );

      break;
    }

    case "f64": {
      const actuali32 = actual.value.reinterpret();
      const expectedi32 = Long.fromString(expected.value).toNumber();

      assert(
        actuali32.toNumber() === expectedi32,
        `Expected value ${expectedi32}, got ${actuali32.toString()}`
      );

      break;
    }

    case "i64": {
      console.warn("eq with i64 is unsupported");
      // const actuali64 = actual.value.toString();
      // const expectedi64 = Long.fromString(expected.value)
      //   .toSigned()
      //   .toString();
github xtuc / webassemblyjs / packages / helper-testsuite-runner / src / asserts.js View on Github external
function eq(actual: StackLocal, expected: Object) {
  // check type
  assert(
    actual.type === expected.type,
    `type mismatch; expected ${expected.type}, given ${actual.type}`
  );

  // check value
  switch (expected.type) {
    case "i32": {
      const i32Value = Long.fromString(expected.value).toInt();

      assert(
        actual.value.toString() === i32Value.toString(),
        `Expected value ${i32Value}, got ${actual.value.toString()}`
      );
      break;
    }

    case "f32": {
      const actuali32 = actual.value.reinterpret();
      const expectedi32 = Long.fromString(expected.value).toInt();

      assert(
        actuali32.toNumber() === expectedi32,
        `Expected value ${expectedi32}, got ${actuali32.toString()}`
      );
github xtuc / webassemblyjs / packages / helper-testsuite-runner / src / asserts.js View on Github external
const compatibleArgs = args.map(x => {
      if (x.type === "i64") {
        return new Long.fromString(x.value);
      }

      return x.value;
    });
github zc910704 / Vue.js-personal-note / www / day6.1.webpack的url-loader与babel / node_modules / @webassemblyjs / wast-parser / esm / number-literals.js View on Github external
export function parse64I(sourceString) {
  var long;

  if (isHexLiteral(sourceString)) {
    long = Long.fromString(sourceString, false, 16);
  } else if (isDecimalExponentLiteral(sourceString)) {
    throw new Error("This number literal format is yet to be implemented.");
  } else {
    long = Long.fromString(sourceString);
  }

  return {
    high: long.high,
    low: long.low
  };
}
var NAN_WORD = /^\+?-?nan/;
github zc910704 / Vue.js-personal-note / www / day6.1.webpack的url-loader与babel / node_modules / @webassemblyjs / wast-parser / esm / number-literals.js View on Github external
export function parse64I(sourceString) {
  var long;

  if (isHexLiteral(sourceString)) {
    long = Long.fromString(sourceString, false, 16);
  } else if (isDecimalExponentLiteral(sourceString)) {
    throw new Error("This number literal format is yet to be implemented.");
  } else {
    long = Long.fromString(sourceString);
  }

  return {
    high: long.high,
    low: long.low
  };
}
var NAN_WORD = /^\+?-?nan/;

@xtuc/long

A Long class for representing a 64-bit two's-complement integer value.

Apache-2.0
Latest version published 6 years ago

Package Health Score

70 / 100
Full package analysis