How to use the is.boolean 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 / firebase-tools / src / firestore / encodeFirestoreValue.js View on Github external
var encodeHelper = function(val) {
    if (is.string(val)) {
      return {
        stringValue: val,
      };
    }
    if (is.boolean(val)) {
      return {
        booleanValue: val,
      };
    }
    if (is.integer(val)) {
      return {
        integerValue: val,
      };
    }
    // Integers are handled above, the remaining numbers are treated as doubles
    if (is.number(val)) {
      return {
        doubleValue: val,
      };
    }
    if (is.date(val)) {
github googleapis / nodejs-logging / src / common.ts View on Github external
encodeValue_(value: {}) {
    let convertedValue;

    if (is.null(value)) {
      convertedValue = {
        nullValue: 0,
      };
    } else if (is.number(value)) {
      convertedValue = {
        numberValue: value,
      };
    } else if (is.string(value)) {
      convertedValue = {
        stringValue: value,
      };
    } else if (is.boolean(value)) {
      convertedValue = {
        boolValue: value,
      };
    } else if (Buffer.isBuffer(value)) {
      convertedValue = {
        blobValue: value,
      };
    } else if (is.object(value)) {
      if (this.seenObjects.has(value)) {
        // Circular reference.
        if (!this.removeCircular) {
          throw new Error(
            [
              'This object contains a circular reference. To automatically',
              'remove it, set the `removeCircular` option to true.',
            ].join(' ')
github firebase / user-privacy / functions / node_modules / @google-cloud / common-grpc / src / service.js View on Github external
ObjectToStructConverter.prototype.encodeValue_ = function(value) {
  var convertedValue;

  if (is.null(value)) {
    convertedValue = {
      nullValue: 0
    };
  } else if (is.number(value)) {
    convertedValue = {
      numberValue: value
    };
  } else if (is.string(value)) {
    convertedValue = {
      stringValue: value
    };
  } else if (is.boolean(value)) {
    convertedValue = {
      boolValue: value
    };
  } else if (Buffer.isBuffer(value)) {
    convertedValue = {
      blobValue: value
    };
  } else if (is.object(value)) {
    if (this.seenObjects.has(value)) {
      // Circular reference.
      if (!this.removeCircular) {
        throw new Error([
          'This object contains a circular reference. To automatically',
          'remove it, set the `removeCircular` option to true.'
        ].join(' '));
      }
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 googleapis / nodejs-error-reporting / src / configuration.ts View on Github external
if (is.string(this._givenConfiguration.key)) {
      this._key = this._givenConfiguration.key!;
    } else if (has(this._givenConfiguration, 'key')) {
      throw new Error('config.key must be a string');
    }
    if (is.string(this._givenConfiguration.keyFilename)) {
      this.keyFilename = this._givenConfiguration.keyFilename!;
    } else if (has(this._givenConfiguration, 'keyFilename')) {
      throw new Error('config.keyFilename must be a string');
    }
    if (is.object(this._givenConfiguration.credentials)) {
      this.credentials = this._givenConfiguration.credentials!;
    } else if (has(this._givenConfiguration, 'credentials')) {
      throw new Error('config.credentials must be a valid credentials object');
    }
    if (is.boolean(this._givenConfiguration.reportUnhandledRejections)) {
      this._reportUnhandledRejections = this._givenConfiguration.reportUnhandledRejections!;
    } else if (has(this._givenConfiguration, 'reportUnhandledRejections')) {
      throw new Error('config.reportUnhandledRejections must be a boolean');
    }
  }
  /**
github googleapis / nodejs-bigtable / src / app-profile.ts View on Github external
static formatAppProfile_(options) {
    const appProfile: any = {};

    if (options.routing) {
      if (options.routing === 'any') {
        appProfile.multiClusterRoutingUseAny = {};
      } else if (options.routing instanceof Cluster) {
        appProfile.singleClusterRouting = {
          clusterId: options.routing.id,
        };
        if (is.boolean(options.allowTransactionalWrites)) {
          appProfile.singleClusterRouting.allowTransactionalWrites =
            options.allowTransactionalWrites;
        }
      } else {
        throw new Error(
          'An app profile routing policy can only contain "any" or a `Cluster`.'
        );
      }
    }

    if (is.string(options.description)) {
      appProfile.description = options.description;
    }

    return appProfile;
  }
github googleapis / google-cloud-node / packages / datastore / src / entity.js View on Github external
function encodeValue(value) {
  var valueProto = {};

  if (is.boolean(value)) {
    valueProto.booleanValue = value;
    return valueProto;
  }

  if (is.nil(value)) {
    valueProto.nullValue = 0;
    return valueProto;
  }

  if (is.number(value)) {
    if (value % 1 === 0) {
      value = new entity.Int(value);
    } else {
      value = new entity.Double(value);
    }
  }
github googleapis / nodejs-bigtable / src / instance.ts View on Github external
callback = options;
      options = {};
    }
    if (!options.routing) {
      throw new Error('An app profile must contain a routing policy.');
    }

    const appProfile = AppProfile.formatAppProfile_(options);

    const reqOpts: any = {
      parent: this.name,
      appProfileId: id,
      appProfile,
    };

    if (is.boolean(options.ignoreWarnings)) {
      reqOpts.ignoreWarnings = options.ignoreWarnings;
    }

    this.bigtable.request(
      {
        client: 'BigtableInstanceAdminClient',
        method: 'createAppProfile',
        reqOpts,
        gaxOpts: options.gaxOptions,
      },
      (...args) => {
        if (args[1]) {
          args.splice(1, 0, this.appProfile(id));
        }

        callback(...args);
github googleapis / nodejs-bigtable / src / app-profile.ts View on Github external
reqOpts.appProfile.name = this.name;

    const fieldsForMask = [
      'description',
      'singleClusterRouting',
      'multiClusterRoutingUseAny',
      'allowTransactionalWrites',
    ];

    fieldsForMask.forEach(field => {
      if (reqOpts.appProfile[field]) {
        reqOpts.updateMask.paths.push(snakeCase(field));
      }
    });

    if (is.boolean(metadata.ignoreWarnings)) {
      reqOpts.ignoreWarnings = metadata.ignoreWarnings;
    }

    this.bigtable.request(
      {
        client: 'BigtableInstanceAdminClient',
        method: 'updateAppProfile',
        reqOpts,
        gaxOpts: gaxOptions,
      },
      callback
    );
  }
}

is

the definitive JavaScript type testing library

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis