How to use the is_js.function function in is_js

To help you get started, we’ve selected a few is_js 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 Albert-Gao / veasy / src / helpers.js View on Github external
function handleBeforeValidation(fieldValue, handler) {
  if (is.function(handler)) {
    return handler(fieldValue);
  }
  /* eslint no-console: 0 */
  console.warn(`[Veasy]: Expect beforeValidation to be a function \
while the value is ${handler}`);
  return fieldValue;
}
github vadimdemedes / interaptor / lib / interceptor.js View on Github external
var value = b;

      this._asserts.headers[_name2] = value;

      return this;
    }

    // status code
    if (arguments.length === 1 && is.number(a)) {
      this._asserts.statusCode = a;

      return this;
    }

    // function
    if (arguments.length === 1 && is['function'](a)) {
      this._assertFn = a;

      return this;
    }

    // plain body
    if (arguments.length === 1 && is.string(a)) {
      this._asserts.body = a;

      return this;
    }

    // JSON body
    if (arguments.length === 1 && is.object(a)) {
      this._asserts.body = stringify(a);
github dot-microservices / dot / src / base.js View on Github external
advertise(options, added, removed) {
        let advertising = { key: this.options.secret };
        if (is.object(options)) advertising = Object.assign(advertising, options);
        if (is.object(this.options.discover))
            advertising = Object.assign(advertising, this.options.discover);
        this.ad = discover(advertising);
        if (is.function(added)) this.ad.on('added', added);
        if (is.function(removed)) this.ad.on('removed', removed);
    }
github Albert-Gao / veasy / src / helpers / validationUtils.js View on Github external
function handleBeforeValidation(
  fieldValue: mixed,
  handler: BeforeValidationHandler
) {
  if (is.function(handler)) {
    return handler(fieldValue);
  }
  return fieldValue;
}
github thorgate / django-project-template / {{cookiecutter.repo_name}} / app / src / sagas / auth / permissionCheckSaga.js View on Github external
export default function* isLoggedIn(checkPermissions = null) {
    let hasPermission = false;

    if (is.function(checkPermissions)) {
        hasPermission = yield select(checkPermissions);
    } else {
        hasPermission = yield select(isAuthenticated);
    }

    if (!hasPermission) {
        const error = new Error('Permission denied.');
        error.statusCode = 403;
        throw error;
    }
}
github nanopoly / nanopoly / lib / base.js View on Github external
_fixServiceName(service) {
        if (is.function(service) && is.function(service._name)) return service._name();

        return `${ service.name.charAt(0).toLowerCase() }${ service.name.slice(1) }`;
    }
github nanopoly / nanopoly / src / zmq.js View on Github external
handle(event, fn) {
        if (is.function(event)) {
            fn = event;
            event = 'message';
        }
        if (is.not.function(fn)) throw new EventHandlerError(event, fn);

        this._socket.on(event, fn);
    }
github nanopoly / nanopoly / src / base.js View on Github external
static __fixServiceName(service) {
        if (is.not.function(service)) throw new ServiceError(service);

        if (service.hasOwnProperty('_name') && is.function(service._name))
            return service._name();
        return `${ service.name.charAt(0).toLowerCase() }${ service.name.slice(1) }`;
    }
}
github dot-microservices / dot-rest / src / server.js View on Github external
_configureService(service) {
        let configure = is.function(service) && is.function(service._configure) ? service._configure() : {};
        if (is.not.object(configure) || is.array(configure)) configure = {};
        for (let cfg of Object.keys(configure)) {
            if (cfg.startsWith('_') || is.not.function(service[cfg])) delete configure[cfg];
            if (is.not.array(configure[cfg])) delete configure[cfg];
            else if (is.string(configure[cfg][0]))
                configure[cfg] = [ [ configure[cfg][0], configure[cfg][1] || Base._unCamelCase(cfg) ] ];
        }
        for (let method of Object.getOwnPropertyNames(service)) {
            if (!method || method.startsWith('_') || this._ignoredProperties.includes(method)) continue;
            if (is.not.function(service[method]) || is.array(configure[method])) continue;

            configure[method] = [ [ '*', `/${ method }` ] ];
        }
        return configure;
    }