How to use the bytebuffer.Long.isLong function in bytebuffer

To help you get started, we’ve selected a few bytebuffer 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 EOSIO / eosjs / src / format.js View on Github external
function ULong(value, unsigned = true, radix = 10) {
  if(typeof value === 'number') {
    // Some JSON libs use numbers for values under 53 bits or strings for larger.
    // Accomidate but double-check it..
    if(value > Number.MAX_SAFE_INTEGER)
      throw new TypeError('value parameter overflow')

    value = Long.fromString(String(value), unsigned, radix)
  } else if(typeof value === 'string') {
    value = Long.fromString(value, unsigned, radix)
  } else if(!Long.isLong(value)) {
    throw new TypeError('value parameter is a requied Long, Number or String')
  }
  return value
}
github svk31 / graphenejs-lib / lib / serializer / src / SerializerValidation.js View on Github external
no_overflow53(value, field_name=""){
        if (typeof value === "number") {
            if (value > MAX_SAFE_INT || value < MIN_SAFE_INT) {
                throw new Error(`overflow ${field_name} ${value}`);
            }
            return;
        }
        if (typeof value === "string") {
            var int = parseInt(value);
            if (value > MAX_SAFE_INT || value < MIN_SAFE_INT) {
                throw new Error(`overflow ${field_name} ${value}`);
            }
            return;
        }
        if (Long.isLong(value) ){
            // typeof value.toInt() is 'number'
            this.no_overflow53(value.toInt(), field_name);
            return;
        }
        throw `unsupported type ${field_name}: (${typeof value}) ${value}`;
    },
github bitshares / bitsharesjs / lib / serializer / src / SerializerValidation.js View on Github external
to_long(value, field_name = "", unsigned = false) {
        if (this.is_empty(value)) {
            return value;
        }
        if (Long.isLong(value)) {
            return value;
        }

        this.no_overflow64(value, field_name, unsigned);
        if (typeof value === "number") {
            value = "" + value;
        }
        return Long.fromString(value, unsigned);
    },
github svk31 / graphenejs-lib / lib / serializer / src / SerializerValidation.js View on Github external
require_long(value, field_name=""){
        if (!Long.isLong(value)) {
            throw new Error(`Long value required ${field_name} ${value}`);
        }
        return value;
    },
github peerplays-network / peerplays-core-gui / lib / serializer / src / SerializerValidation.ts View on Github external
to_string(value, field_name = '') {
    if (this.is_empty(value)) {
      return value;
    }

    if (typeof value === 'string') {
      return value;
    }

    if (typeof value === 'number') {
      this.no_overflow53(value, field_name);
      return `${value}`;
    }

    if (Long.isLong(value)) {
      return value.toString();
    }

    throw new Error(`unsupported type ${field_name}: (${typeof value}) ${value}`);
  },
github steemit / steem-js / src / auth / serializer / src / validation.js View on Github external
require_long(value, field_name=""){
        if (!Long.isLong(value)) {
            throw new Error(`Long value required ${field_name} ${value}`);
        }
        return value;
    },
github steemit / steem-js / src / auth / serializer / src / validation.js View on Github external
to_long(value, field_name=""){
        if (is_empty(value) ){ return value; }
        if (Long.isLong(value) ){ return value; }
        
        _my.no_overflow64(value, field_name);
        if (typeof value === "number") {
            value = ""+value;
        }
        return Long.fromString(value);
    },
github bitshares / bitsharesjs / lib / serializer / src / SerializerValidation.js View on Github external
require_long(value, field_name = "") {
        if (!Long.isLong(value)) {
            throw new Error(`Long value required ${field_name} ${value}`);
        }
        return value;
    },
github peerplays-network / peerplays-core-gui / lib / serializer / src / SerializerValidation.ts View on Github external
require_long(value, field_name = '') {
    if (!Long.isLong(value)) {
      throw new Error(`Long value required ${field_name} | ${value}`);
    }

    return value;
  },