How to use the is.infinite 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 googleapis / nodejs-spanner / src / session-pool.ts View on Github external
let removeListener: Function;

    const promises = [
      this._onClose.then(() => {
        throw new Error(errors.Closed);
      }),
      new Promise(resolve => {
        this.once('available', resolve);
        removeListener = this.removeListener.bind(this, 'available', resolve);
      }),
    ];

    const timeout = this.options.acquireTimeout;

    if (!is.infinite(timeout!)) {
      const elapsed = Date.now() - startTime!;
      const remaining = timeout! - elapsed;

      promises.push(
        new Promise((_, reject) => {
          const error = new Error(errors.Timeout);
          setTimeout(reject.bind(null, error), remaining);
        })
      );
    }

    // Only create a new session if there are more waiters than sessions already
    // being created. The current requester will be waiter number _numWaiters+1.
    if (
      !this.isFull &&
      this._pending + this._pendingPrepare <= this._numWaiters
github googleapis / nodejs-spanner / src / session-pool.ts View on Github external
let removeListener: Function;

    const promises = [
      this._onClose.then(() => {
        throw new Error(errors.Closed);
      }),
      new Promise(resolve => {
        this.once('available', resolve);
        removeListener = this.removeListener.bind(this, 'available', resolve);
      }),
    ];

    const timeout = this.options.acquireTimeout;

    if (!is.infinite(timeout!)) {
      const elapsed = Date.now() - startTime!;
      const remaining = timeout! - elapsed;

      promises.push(
        new Promise((_, reject) => {
          const error = new Error(errors.Timeout);
          setTimeout(reject.bind(null, error), remaining);
        })
      );
    }

    if (!this.isFull) {
      promises.push(
        new Promise((resolve, reject) => {
          this._createSession(type).then(() => this.emit('available'), reject);
        })
github googleapis / nodejs-spanner / src / codec.ts View on Github external
function preEncode(value) {
    const numberShouldBeStringified =
        (!(value instanceof Float) && is.integer(value)) ||
        value instanceof Int || is.infinite(value) || Number.isNaN(value);

    if (is.date(value)) {
      value = value.toJSON();
    } else if (
        value instanceof SpannerDate || value instanceof Float ||
        value instanceof Int) {
      value = value.value;
    } else if (Buffer.isBuffer(value)) {
      value = value.toString('base64');
    } else if (Struct.isStruct(value)) {
      value = value.map(field => preEncode(field.value));
    } else if (is.array(value)) {
      value = value.map(preEncode);
    } else if (is.object(value) && is.fn(value.hasOwnProperty)) {
      for (const prop in value) {
        if (value.hasOwnProperty(prop)) {
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';

is

the definitive JavaScript type testing library

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis