How to use the is.number function in is

To help you get started, we’ve selected a few is 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 firebase / user-privacy / functions / node_modules / @google-cloud / common-grpc / src / service.js View on Github external
callback(err);
        return;
      }

      self.grpcCredentials = credentials;
      self.request(protoOpts, reqOpts, callback);
    });

    return;
  }

  var service = this.getService_(protoOpts);
  var metadata = this.grpcMetadata;
  var grpcOpts = {};

  if (is.number(protoOpts.timeout)) {
    grpcOpts.deadline = GrpcService.createDeadline_(protoOpts.timeout);
  }

  try {
    reqOpts = this.decorateRequest_(reqOpts);
  } catch(e) {
    callback(e);
    return;
  }

  // Retains a reference to an error from the response. If the final callback is
  // executed with this as the "response", we return it to the user as an error.
  var respError;

  var retryOpts = {
    retries: this.maxRetries,
github yagop / node-telegram-bot-api / test / telegram.js View on Github external
return bot.sendInvoice(USERID, title, description, payload, providerToken, startParameter, currency, prices).then(resp => {
        assert.ok(is.object(resp));
        assert.ok(is.object(resp.invoice));
        assert.ok(is.number(resp.invoice.total_amount));
      });
    });
github yagop / node-telegram-bot-api / test / telegram.js View on Github external
return bot.getMe().then(resp => {
        assert.ok(is.object(resp));
        assert.ok(is.number(resp.id));
        assert.ok(is.string(resp.first_name));
      });
    });
github yagop / node-telegram-bot-api / test / telegram.js View on Github external
return bot.getWebHookInfo().then(resp => {
        assert.ok(is.object(resp));
        assert.ok(is.boolean(resp.has_custom_certificate));
        assert.ok(is.number(resp.pending_update_count));
      });
    });
github yagop / node-telegram-bot-api / test / telegram.js View on Github external
return bot.stopMessageLiveLocation(opts).then(resp => {
        assert.ok(is.object(resp));
        assert.ok(is.object(resp.location));
        assert.ok(is.number(resp.location.latitude));
        assert.ok(is.number(resp.location.longitude));
      });
    });
github massgov / mayflower / react / src / components / atoms / forms / InputCurrency / index.js View on Github external
const displayErrorMessage = (val) => {
            const { min, max, required } = props;
            if (required && !is.number(val)) {
              const errorMsg = 'Please enter a value.';
              return{
                showError: true,
                errorMsg
              };
            } else if (is.number(val)) {
              const { showError, errorMsg } = validNumber(val, min, max);
              return{
                showError, errorMsg
              };
            }
            return{
              showError: false,
              errorMsg: ''
            };
          };
github massgov / mayflower / react / src / components / atoms / forms / InputCurrency / index.js View on Github external
const toCurrency = (number, decimal) => {
            if (is.number(number)) {
              if (props.language) {
                let i = 0;
                const langKeys = Object.keys(languages);
                const langMax = langKeys.length;
                for (; i < langMax; i += 1) {
                  const langKey = langKeys[i];
                  const lang = languages[langKey];
                  numbro.registerLanguage(lang);
                }
                numbro.setLanguage(props.language);
              }
              const currency = numbro(number);
              const { format } = props;
              if (decimal) {
                format.mantissa = decimal;
              }
github googleapis / nodejs-spanner / src / codec.ts View on Github external
function getType(field) {
  if (is.boolean(field)) {
    return 'bool';
  }

  const isSpecialNumber = is.infinite(field) ||
      (is.number(field) && isNaN(field));

  if (is.decimal(field) || isSpecialNumber || field instanceof Float) {
    return 'float64';
  }

  if (is.number(field) || field instanceof Int) {
    return 'int64';
  }

  if (is.string(field)) {
    return 'string';
  }

  if (Buffer.isBuffer(field)) {
    return 'bytes';
  }
github googleapis / nodejs-datastore / src / entity.ts View on Github external
export function isDsDoubleLike(value: unknown) {
    const maybeDsDouble = value as Double;
    return (
      isDsDouble(maybeDsDouble) ||
      (is.object(maybeDsDouble) &&
        is.number(maybeDsDouble.value) &&
        maybeDsDouble.type === 'DatastoreDouble')
    );
  }
github googleapis / nodejs-bigtable / src / filter.ts View on Github external
if (row.key) {
      let key = Filter.convertToRegExpString(row.key);

      key = Mutation.convertToBytes(key);
      this.set('rowKeyRegexFilter', key);
    }

    if (row.sample) {
      this.set('rowSampleFilter', row.sample);
    }

    if (is.number(row.cellOffset)) {
      this.set('cellsPerRowOffsetFilter', row.cellOffset);
    }

    if (is.number(row.cellLimit)) {
      this.set('cellsPerRowLimitFilter', row.cellLimit);
    }
  }

is

the definitive JavaScript type testing library

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis