Tabnine Logo For Javascript
LoDashStatic.compact
Code IndexAdd Tabnine to your IDE (free)

How to use
compact
function
in
LoDashStatic

Best JavaScript code snippets using lodash.LoDashStatic.compact(Showing top 15 results out of 315)

origin: moleculerjs/moleculer

/**
   * Merge `mixins` property in schema
   *
   * @static
   * @param {Object} src Source schema property
   * @param {Object} target Target schema property
   *
   * @returns {Object} Merged schema
   */
  static mergeSchemaUniqArray(src, target) {
    return _.uniqWith(_.compact(flatten([src, target])), _.isEqual);
  }
origin: moleculerjs/moleculer

/**
   * Merge `started`, `stopped`, `created` event handler properties in schema
   *
   * @static
   * @param {Object} src Source schema property
   * @param {Object} target Target schema property
   *
   * @returns {Object} Merged schema
   */
  static mergeSchemaLifecycleHandlers(src, target) {
    return _.compact(flatten([target, src]));
  }
origin: lando/lando

/*
 * Parse docker-compose options
 */
const parseOptions = (opts = {}) => {
 const flags = _.map(composeFlags, (value, key) => _.get(opts, key, false) ? value : '');
 const environment = _.flatMap(opts.environment, (value, key) => ['--env', `${key}=${value}`]);
 const user = (_.has(opts, 'user')) ? ['--user', opts.user] : [];
 const workdir = (_.has(opts, 'workdir')) ? ['--workdir', opts.workdir] : [];
 const entrypoint = _.map(opts.entrypoint, entrypoint => ['--entrypoint', entrypoint]);
 return _.compact(_.flatten([flags, environment, user, workdir, entrypoint]));
}
origin: lando/lando

_(cmd)
 // Put into an object so we can handle "multi-service" tooling
 .map(cmd => parseCommand(cmd, service))
 // Handle dynamic services
 .map(config => handleDynamic(config, options, answers))
 // Add in any argv extras if they've been passed in
 .map(config => handleOpts(config, handlePassthruOpts(options, answers)))
 // Wrap the command in /bin/sh if that makes sense
 .map(config => _.merge({}, config, {command: escape(config.command, true, config.args)}))
 // Add any args to the command and compact to remove undefined
 .map(config => _.merge({}, config, {command: _.compact(config.command.concat(config.args))}))
 // Put into an object
 .value()
origin: lando/lando

/*
 * Helper to standardize construction of docker commands
 */
const buildCmd = (run, name, compose, {services, cmd}, opts = {}) => {
 if (!name) throw new Error('Need to give this composition a project name!');
 // @TODO: we need to strip out opts.user on start/stop because we often get it as part of run
 const project = ['--project-name', name];
 const files = _.flatten(_.map(compose, unit => ['--file', unit]));
 const options = parseOptions(opts);
 const argz = _.flatten(_.compact([services, cmd]));
 return _.flatten([project, files, run, options, argz]);
}
origin: moleculerjs/moleculer

/**
   * Initialize Tracer.
   */
  init() {
    if (this.opts.enabled) {

      this.defaultTags = isFunction(this.opts.defaultTags) ? this.opts.defaultTags.call(this, this) : this.opts.defaultTags;

      // Create Exporter instances
      if (this.opts.exporter) {
        const exporters = Array.isArray(this.opts.exporter) ? this.opts.exporter : [this.opts.exporter];

        this.exporter = _.compact(exporters).map(r => {
          const exporter = Exporters.resolve(r);
          exporter.init(this);
          return exporter;
        });

        const exporterNames = this.exporter.map(exporter => this.broker.getConstructorName(exporter));
        this.logger.info(`Tracing exporter${exporterNames.length > 1 ? "s": ""}: ${exporterNames.join(", ")}`);
      }

    }
  }
origin: moleculerjs/moleculer

/**
   * Sanitize hooks. If the hook is a string, convert it to Service method calling.
   *
   * @param {Function|String|Array<any>} hooks
   * @param {Service?} service
   * @returns
   */
  function sanitizeHooks(hooks, service) {
    if (isString(hooks))
      return service && isFunction(service[hooks]) ? service[hooks] : null;

    if (Array.isArray(hooks)) {
      return _.compact(hooks.map(h => {
        if (isString(h))
          return service && isFunction(service[h]) ? service[h] : null;

        return h;
      }));
    }

    return hooks;
  }
origin: moleculerjs/moleculer

/**
   * Merge `events` property in schema
   *
   * @static
   * @param {Object} src Source schema property
   * @param {Object} target Target schema property
   *
   * @returns {Object} Merged schema
   */
  static mergeSchemaEvents(src, target) {
    Object.keys(src).forEach(k => {
      const modEvent = wrapToHander(src[k]);
      const resEvent = wrapToHander(target[k]);

      let handler = _.compact(flatten([resEvent ? resEvent.handler : null, modEvent ? modEvent.handler : null]));
      if (handler.length == 1) handler = handler[0];

      target[k] = _.defaultsDeep(modEvent, resEvent);
      target[k].handler = handler;
    });

    return target;
  }
origin: moleculerjs/moleculer

/**
   * Initialize queues for REQUEST & EVENT packets.
   *
   * @memberof AmqpTransporter
   */
  makeBalancedSubscriptions() {
    if (!this.hasBuiltInBalancer) return this.broker.Promise.resolve();

    return this.unsubscribeFromBalancedCommands().then(() => {
      const services = this.broker.getLocalNodeInfo().services;
      return this.broker.Promise.all(services.map(service => {
        const p = [];

        // Service actions queues
        if (service.actions && typeof(service.actions) == "object") {
          p.push(Object.keys(service.actions).map(action => this.subscribeBalancedRequest(action)));
        }

        // Load-balanced/grouped events queues
        if (service.events && typeof(service.events) == "object") {
          p.push(Object.keys(service.events).map(event => {
            const group = service.events[event].group || service.name;
            this.subscribeBalancedEvent(event, group);
          }));
        }

        return this.broker.Promise.all(_.compact(flatten(p, true)));
      }));
    });
  }
origin: moleculerjs/moleculer

const reporters = Array.isArray(this.opts.reporter) ? this.opts.reporter : [this.opts.reporter];
this.reporter = _.compact(reporters).map(r => {
  const reporter = Reporters.resolve(r);
  reporter.init(this);
origin: lando/lando

/*
  * Get list of sites
  */
 getSites() {
  // Call to get user sites
  const pantheonUserSites = () => {
   const getSites = ['users', _.get(this.session, 'user_id'), 'memberships', 'sites'];
   return pantheonRequest(this.request, this.log, 'get', getSites, {params: {limit: MAX_SITES}})
   .then(sites => _.map(sites, (site, id) => _.merge(site, site.site)));
  };
  // Call to get org sites
  const pantheonOrgSites = () => {
   const getOrgs = ['users', _.get(this.session, 'user_id'), 'memberships', 'organizations'];
   return pantheonRequest(this.request, this.log, 'get', getOrgs)
   .map(org => {
    if (org.role !== 'unprivileged') {
     const getOrgsSites = ['organizations', org.id, 'memberships', 'sites'];
     return pantheonRequest(this.request, this.log, 'get', getOrgsSites, {params: {limit: MAX_SITES}})
     .map(site => _.merge(site, site.site));
    }
   })
   .then(sites => _.flatten(sites));
  };
  // Run both requests
  return Promise.all([pantheonUserSites(), pantheonOrgSites()])
  // Combine, cache and all the things
  .then(sites => _.compact(_.sortBy(_.uniqBy(_.flatten(sites), 'name'), 'name')))
  // Filter out any BAAAAD BIZZZNIZZZ
  .filter(site => !site.frozen);
 }
origin: moleculerjs/moleculer

/**
   * Merge `hooks` property in schema
   *
   * @static
   * @param {Object} src Source schema property
   * @param {Object} target Target schema property
   *
   * @returns {Object} Merged schema
   */
  static mergeSchemaHooks(src, target) {
    Object.keys(src).forEach(k => {
      if (target[k] == null)
        target[k] = {};

      Object.keys(src[k]).forEach(k2 => {
        const modHook = wrapToArray(src[k][k2]);
        const resHook = wrapToArray(target[k][k2]);

        target[k][k2] = _.compact(flatten(k == "before" ? [resHook, modHook] : [modHook, resHook]));
      });
    });

    return target;
  }
origin: lando/lando

 volumes: utils.getNamedVolumes(excludes),
 services: toObject(app.services, {
  volumes: _.compact(serviceExcludes.concat(serviceIncludes)),
 }),
}));
app.add(new app.ComposeService('excludes', {}, {
 services: toObject(app.services, {
  volumes: _.compact(serviceExcludes),
 }),
}));
origin: moleculerjs/moleculer

  const resHook = wrapToArray(targetAction.hooks[k]);
  srcAction.hooks[k] = _.compact(flatten(k == "before" ? [resHook, modHook] : [modHook, resHook]));
});
origin: lando/lando

// Helper to get popuylation command
const getPopCommand = (excludes = []) => _.compact(_.flatten([['/helpers/mounter.sh'], excludes]))
lodash(npm)LoDashStaticcompact

JSDoc

Creates an array with all falsey values removed. The values false, null, 0, "", undefined, and NaN are
falsey.

Most used lodash functions

  • LoDashStatic.map
    Creates an array of values by running each element in collection through iteratee. The iteratee is
  • LoDashStatic.isEmpty
    Checks if value is empty. A value is considered empty unless it’s an arguments object, array, string
  • LoDashStatic.forEach
    Iterates over elements of collection invoking iteratee for each element. The iteratee is invoked wit
  • LoDashStatic.find
    Iterates over elements of collection, returning the first element predicate returns truthy for.
  • LoDashStatic.pick
    Creates an object composed of the picked `object` properties.
  • LoDashStatic.get,
  • LoDashStatic.isArray,
  • LoDashStatic.filter,
  • LoDashStatic.merge,
  • LoDashStatic.isString,
  • LoDashStatic.isFunction,
  • LoDashStatic.assign,
  • LoDashStatic.extend,
  • LoDashStatic.includes,
  • LoDashStatic.keys,
  • LoDashStatic.cloneDeep,
  • LoDashStatic.uniq,
  • LoDashStatic.isObject,
  • LoDashStatic.omit

Popular in JavaScript

  • js-yaml
    YAML 1.2 parser and serializer
  • semver
    The semantic version parser used by npm.
  • chalk
    Terminal string styling done right
  • mocha
    simple, flexible, fun test framework
  • handlebars
    Handlebars provides the power necessary to let you build semantic templates effectively with no frustration
  • minimist
    parse argument options
  • axios
    Promise based HTTP client for the browser and node.js
  • redis
    Redis client library
  • mongodb
    The official MongoDB driver for Node.js
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now