How to use the is.string 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-firestore / test / watch.js View on Github external
const docsEqual = function(actual, expected) {
  assert.equal(actual.length, expected.length);
  for (let i = 0; i < actual.size; i++) {
    assert.equal(actual[i].ref.id, expected[i].ref.id);
    assert.deepStrictEqual(actual[i].data(), expected[i].data());
    assert.ok(is.string(expected[i].createTime));
    assert.ok(is.string(expected[i].updateTime));
  }
};
/**
github googleapis / nodejs-firestore / test / query.js View on Github external
function endAt(before, value) {
  let cursor = {
    endAt: {
      values: [],
    },
  };

  if (before) {
    cursor.endAt.before = true;
  }

  let values = [].slice.call(arguments, 1);

  for (value of values) {
    if (is.string(value)) {
      cursor.endAt.values.push({
        stringValue: value,
      });
    } else {
      cursor.endAt.values.push(value);
    }
  }

  return cursor;
}
github googleapis / nodejs-dns / src / zone.ts View on Github external
deleteRecords(records, callback) {
    records = arrify(records);
    if (is.string(records[0])) {
      this.deleteRecordsByType_(records, callback);
      return;
    }
    this.createChange(
        {
          delete: records,
        },
        callback);
  }
  /**
github googleapis / nodejs-error-reporting / src / classes / error-message.ts View on Github external
setFunctionName(functionName?: string) {
    this.context.reportLocation.functionName = (is.string(functionName)
      ? functionName
      : '')!;

    return this;
  }
github googleapis / google-cloud-node / packages / bigtable / src / filter.js View on Github external
Filter.convertToRegExpString = function(regex) {
  if (is.regexp(regex)) {
    return regex.toString().replace(/^\/|\/$/g, '');
  }

  if (is.array(regex)) {
    return '(' + regex.join('|') + ')';
  }

  if (is.string(regex)) {
    return regex;
  }

  if (is.number(regex)) {
    return regex.toString();
  }

  throw new TypeError('Can\'t convert to RegExp String from unknown type.');
};
github googleapis / nodejs-pubsub / src / iam.ts View on Github external
testPermissions(permissions: string|string[], gaxOpts, callback?) {
    if (!is.array(permissions) && !is.string(permissions)) {
      throw new Error('Permissions are required.');
    }
    if (is.fn(gaxOpts)) {
      callback = gaxOpts;
      gaxOpts = null;
    }
    const reqOpts = {
      resource: this.id,
      permissions: arrify(permissions),
    };
    this.request(
      {
        client: 'SubscriberClient',
        method: 'testIamPermissions',
        reqOpts: reqOpts,
        gaxOpts: gaxOpts,
github googleapis / nodejs-error-reporting / src / configuration.ts View on Github external
} else if (hasReportMode) {
      this._determineReportMode();
    }

    if (this.isReportingEnabled() && !this.getShouldReportErrorsToAPI()) {
      this._logger.warn(
        [
          'The stackdriver error reporting client is configured to report errors',
          'if and only if the NODE_ENV environment variable is set to "production".',
          'Errors will not be reported.  To have errors always reported, regardless of the',
          'value of NODE_ENV, set the reportMode configuration option to "always".',
        ].join(' ')
      );
    }

    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!;
github googleapis / nodejs-pubsub / src / subscription.ts View on Github external
createSnapshot(name, gaxOpts, callback) {
    if (!is.string(name)) {
      throw new Error('A name is required to create a snapshot.');
    }
    if (is.fn(gaxOpts)) {
      callback = gaxOpts;
      gaxOpts = {};
    }
    const snapshot = this.snapshot(name);
    const reqOpts = {
      name: snapshot.name,
      subscription: this.name,
    };
    this.request(
        {
          client: 'SubscriberClient',
          method: 'createSnapshot',
          reqOpts,
github firebase / user-privacy / functions / node_modules / @google-cloud / common-grpc / node_modules / @google-cloud / common / src / util.js View on Github external
function replaceProjectIdToken(value, projectId) {
  if (is.array(value)) {
    value = value.map(function(val) {
      return replaceProjectIdToken(val, projectId);
    });
  }

  if (is.object(value) && is.fn(value.hasOwnProperty)) {
    for (var opt in value) {
      if (value.hasOwnProperty(opt)) {
        value[opt] = replaceProjectIdToken(value[opt], projectId);
      }
    }
  }

  if (is.string(value) && value.indexOf('{{projectId}}') > -1) {
    if (!projectId) {
      throw util.missingProjectIdError;
    }
    value = value.replace(/{{projectId}}/g, projectId);
  }

  return value;
}
github googleapis / google-cloud-node / packages / common / src / util.js View on Github external
function replaceProjectIdToken(value, projectId) {
  if (is.array(value)) {
    value = value.map(function(val) {
      return replaceProjectIdToken(val, projectId);
    });
  }

  if (is.object(value) && is.fn(value.hasOwnProperty)) {
    for (var opt in value) {
      if (value.hasOwnProperty(opt)) {
        value[opt] = replaceProjectIdToken(value[opt], projectId);
      }
    }
  }

  if (is.string(value) && value.indexOf('{{projectId}}') > -1) {
    if (!projectId || projectId === '{{projectId}}') {
      throw util.missingProjectIdError;
    }
    value = value.replace(/{{projectId}}/g, projectId);
  }

  return value;
}

is

the definitive JavaScript type testing library

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis