How to use the is.function 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-bigtable / src / row.ts View on Github external
get(columns, options, callback?) {
    if (!is.array(columns)) {
      callback = options;
      options = columns;
      columns = [];
    }

    if (is.function(options)) {
      callback = options;
      options = {};
    }

    let filter;
    columns = arrify(columns);

    // if there is column filter
    if (columns.length) {
      const filters = columns.map(Mutation.parseColumnName).map(column => {
        const colmFilters: any = [{family: column.family}];
        if (column.qualifier) {
          colmFilters.push({column: column.qualifier});
        }
        return colmFilters;
      });
github leepowellcouk / mongoose-validator / lib / mongoose-validator.js View on Github external
const validate = function validate(options) {
  if (is.undef(options.validator)) {
    throw new Error('validator option undefined')
  }

  if (!is.function(options.validator) && !is.string(options.validator)) {
    throw new Error(
      `validator must be of type function or string, received ${typeof options.validator}`
    )
  }

  const validatorName = is.string(options.validator) ? options.validator : ''
  const validatorFn = getValidatorFn(options.validator)

  if (is.undef(validatorFn)) {
    throw new Error(
      `validator \`${validatorName}\` does not exist in validator.js or as a custom validator`
    )
  }

  const passIfEmpty = !!options.passIfEmpty
  const mongooseOpts = omit(
github googleapis / nodejs-bigtable / src / instance.ts View on Github external
getTables(options, callback) {
    if (is.function(options)) {
      callback = options;
      options = {};
    }

    const reqOpts = Object.assign({}, options, {
      parent: this.name,
      view: Table.VIEWS[options.view || 'unspecified'],
    });

    delete reqOpts.gaxOptions;

    this.bigtable.request(
      {
        client: 'BigtableTableAdminClient',
        method: 'listTables',
        reqOpts,
github googleapis / nodejs-error-reporting / src / request-extractors / koa.ts View on Github external
export function koaRequestInformationExtractor(
  req: koa.Request,
  res: koa.Response
) {
  const returnObject = new RequestInformationContainer();

  if (
    !is.object(req) ||
    !is.object(res) ||
    is.function(req) ||
    is.function(res) ||
    is.array(req) ||
    is.array(res) ||
    !is.object(req.headers)
  ) {
    return returnObject;
  }

  returnObject
    .setMethod(req.method)
    .setUrl(req.url)
    .setUserAgent(req.headers['user-agent'])
    .setReferrer(req.headers.referrer)
    .setStatusCode(res.status)
    .setRemoteAddress(req.ip);
github alibaba / beidou / packages / beidou-webpack / lib / factory / plugin.js View on Github external
constructor(...args) {
    if (is.function(args[0])) {
      [this.class] = args;
      this.alias = args[0].name;
    } else if (is.object(args[0])) {
      [this.object] = args;
      this.alias = args[0].constructor.name;
    } else {
      throw new Error('Class Plugin constructor error ! ');
    }
    if (args[1]) {
      [, this.options] = args;
    }
    if (args[2]) {
      [, , this.alias] = args;
    }
  }
github googleapis / nodejs-logging / src / log.js View on Github external
getEntries(options, callback) {
    if (is.function(options)) {
      callback = options;
      options = {};
    }
    options = extend(
      {
        filter: 'logName="' + this.formattedName_ + '"',
      },
      options
    );
    return this.logging.getEntries(options, callback);
  }
github googleapis / nodejs-error-reporting / utils / fuzzer.ts View on Github external
const expectsArgTypesChecked = (is.array(expectsArgTypes)
      ? expectsArgTypes
      : [])!;
    const typesToFuzzOnEach = this._generateTypesToFuzzWith(
      expectsArgTypesChecked
    ) as string[][];

    let returnValue = undefined;

    for (let i = 0; i < typesToFuzzOnEach[0].length; i++) {
      returnValue = fnToFuzz.apply(
        withContext,
        this._generateValuesForFuzzTyping(typesToFuzzOnEach, i)
      );

      if (is.function(cb)) {
        cb!(returnValue);
      }
    }

    return true;
  }
}
github googleapis / nodejs-bigtable / src / table.ts View on Github external
getMetadata(options, callback?) {
    if (is.function(options)) {
      callback = options;
      options = {};
    }

    const reqOpts = {
      name: this.name,
      view: (Table as any).VIEWS[options.view || 'unspecified'],
    };

    this.bigtable.request(
      {
        client: 'BigtableTableAdminClient',
        method: 'getTable',
        reqOpts,
        gaxOpts: options.gaxOptions,
      },
github googleapis / nodejs-error-reporting / src / request-extractors / koa.ts View on Github external
export function koaRequestInformationExtractor(
  req: koa.Request,
  res: koa.Response
) {
  const returnObject = new RequestInformationContainer();

  if (
    !is.object(req) ||
    !is.object(res) ||
    is.function(req) ||
    is.function(res) ||
    is.array(req) ||
    is.array(res) ||
    !is.object(req.headers)
  ) {
    return returnObject;
  }

  returnObject
    .setMethod(req.method)
    .setUrl(req.url)
    .setUserAgent(req.headers['user-agent'])
    .setReferrer(req.headers.referrer)
    .setStatusCode(res.status)
    .setRemoteAddress(req.ip);

  return returnObject;

is

the definitive JavaScript type testing library

MIT
Latest version published 5 years ago

Package Health Score

71 / 100
Full package analysis