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

How to use
flatMap
function
in
LoDashStatic

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

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: FormidableLabs/nodejs-dashboard

const createPanelLayout = function (panelPosition, views) {
 const viewSummaryPosition = getSummaryPosition(views);
 let offsetPosition = { size: 0,
  grow: 0 };

 return _.flatMap(views, (view) => {
  const viewPosition = {
   summary: viewSummaryPosition,
   offset: offsetPosition,
   position: view.position
  };

  offsetPosition = concatPosition(view.position, offsetPosition);

  return createViewLayout(view, viewPosition, panelPosition);
 });
}
origin: lando/lando

// Scan urls
 app.events.on('post-start', 10, () => {
  // Message to let the user know it could take a bit
  console.log('Scanning to determine which services are ready... Please standby...');
  // Filter out any services where the scanner might be disabled
  return app.scanUrls(_.flatMap(getScannable(app), 'urls'), {max: 16}).then(urls => {
   // Get data about our scanned urls
   app.urls = urls;
   // Add in unscannable ones if we have them
   if (!_.isEmpty(getScannable(app, false))) {
    app.urls = app.urls.concat(_.map(_.flatMap(getScannable(app, false), 'urls'), url => ({
     url,
     status: true,
     color: 'yellow',
    })));
   }
  });
 });
origin: tumobi/nideshop

/**
  * 获取完整的省市区名称组成的字符串
  * @param provinceId
  * @param cityId
  * @param districtId
  * @returns {Promise.<*>}
  */
 async getFullRegionName(provinceId, cityId, districtId) {
  const isFullRegion = await this.checkFullRegion(provinceId, cityId, districtId);
  if (!isFullRegion) {
   return '';
  }

  const regionList = await this.limit(3).order({'id': 'asc'}).where({id: {'in': [provinceId, cityId, districtId]}}).select();
  if (think.isEmpty(regionList) || regionList.length !== 3) {
   return '';
  }

  return _.flatMap(regionList, 'name').join('');
 }
origin: lando/lando

// Discover portforward true info
 app.events.on('ready', () => {
  app.log.verbose('discovering dynamic portforward info...');
  const forwarders = _.filter(app.info, service => _.get(service, 'external_connection.port', false));
  return lando.engine.list({project: app.project})
  .filter(service => _.includes(_.flatMap(forwarders, service => service.service), service.service))
  .map(service => ({
   id: service.id,
   service: service.service,
   internal: _.get(_.find(app.info, {service: service.service}), 'internal_connection.port'),
  }))
  .map(service => lando.engine.scan(service).then(data => {
   const key = `NetworkSettings.Ports.${service.internal}/tcp`;
   const port = _.filter(_.get(data, key, []), forward => forward.HostIp === lando.config.bindAddress);
   if (_.has(port[0], 'HostPort')) {
    _.set(_.find(app.info, {service: service.service}), 'external_connection.port', port[0].HostPort);
   }
  }));
 });
origin: hawkeyesec/scanner-cli

stdout
   .trim()
   .split('\n')
   .map(l => JSON.parse(l))
   .filter(l => l.type === 'auditAdvisory')
   .map(l => l.data.advisory)
   .map(adv => ({
    offender: adv.module_name,
    code: `${adv.module_name}-${adv.id}`,
    description: adv.title,
    mitigation: `Ingested via ${_.uniq(_.flatMap(_.get(adv, 'findings', []).map(f => _.get(f, 'paths', ''))).map(f => f.split('>')[0])).join(', ')}`,
    level: mapSeverity(adv.severity)
   }))
   .reduce((results, res) => results[res.level](res), new ModuleResults(key))
origin: ohbarye/review-waiting-list-bot

matchesLabel(pr) {
  if (this.label.values.length > 0) {
   const result = _.some(this.label.values, (_label) => {
    return _.flatMap(pr.labels.nodes, (label) => label.name).includes(_label)
   })
   return (this.label.inclusion ? result : !result)
  } else {
   return true
  }
 }
origin: ExpediaDotCom/haystack-ui

_.flatMap(pbTraces.tracesList, t => converter.toTraceJson(t).sort((s1, s2) => s1.startTime - s2.startTime))
origin: hawkeyesec/scanner-cli

Object.keys(advisories)
   .map(prop => advisories[prop])
   .map(adv => ({
    offender: adv.module_name,
    code: `${adv.module_name}-${adv.id}`,
    description: adv.title,
    mitigation: `Ingested via ${_.uniq(_.flatMap(_.get(adv, 'findings', []).map(f => _.get(f, 'paths', ''))).map(f => f.split('>')[0])).join(', ')}`,
    level: mapSeverity(adv.severity)
   }))
   .reduce((results, res) => results[res.level](res), new ModuleResults(key))
origin: alibaba/AliOS-nodejs

lodash.flatMap(options.directives, directive => {
    switch (directive.type) {
      case "disable":
      case "enable":
        return [];

      case "disable-line":
        return [
          { type: "disable", line: directive.line, column: 1, ruleId: directive.ruleId, unprocessedDirective: directive },
          { type: "enable", line: directive.line + 1, column: 0, ruleId: directive.ruleId, unprocessedDirective: directive }
        ];

      case "disable-next-line":
        return [
          { type: "disable", line: directive.line + 1, column: 1, ruleId: directive.ruleId, unprocessedDirective: directive },
          { type: "enable", line: directive.line + 2, column: 0, ruleId: directive.ruleId, unprocessedDirective: directive }
        ];

      default:
        throw new TypeError(`Unrecognized directive type '${directive.type}'`);
    }
  }).sort(compareLocations)
origin: hawkeyesec/scanner-cli

/**
  * @param {ModuleResult[]} moduleResultList
  * @return {ScanResults}
  */
 static fromModuleResultsList (moduleResultList) {
  const results = moduleResultList
   .map(({ key, data }) => {
    const result = []
    for (const level in threshold) {
     data[level].forEach(item => {
      const filteredItem = _.pick(item, ['code', 'offender', 'description', 'mitigation'])
      result.push({ module: key, level, ...filteredItem })
     })
    }
    return result
   })

  return new ScanResults(_.flatMap(results))
 }
origin: kopickik/klydelearns1

function useMultiple(list) {
 // Use one or more map, concatAll, and filter calls to create an array with the following items
 // [
 //	 {"id": 675465,"title": "Fracture","boxart":"http://cdn-0.nflximg.com/images/2891/Fracture150.jpg" },
 //	 {"id": 65432445,"title": "The Chamber","boxart":"http://cdn-0.nflximg.com/images/2891/TheChamber150.jpg" },
 //	 {"id": 654356453,"title": "Bad Boys","boxart":"http://cdn-0.nflximg.com/images/2891/BadBoys150.jpg" },
 //	 {"id": 70111470,"title": "Die Hard","boxart":"http://cdn-0.nflximg.com/images/2891/DieHard150.jpg" }
 // ]
 let results = _.flatMap(list, l =>
  _.map(l.videos, v => {
   return {
    id: v.id,
    title: v.title,
    boxart: _.filter(v.boxarts, function(boxc) {
     return boxc.width === 150
    }).reduce(function(prev, curr) {
     return curr.url
    }, ''),
   }
  }),
 )

 results = _.orderBy(results, ['id', 'title'], ['asc'])

 return results
}
origin: ExpediaDotCom/haystack-ui

function calculateShadowDuration(spans) {
  if (!spans.length) return 0;

  const filteredSpans = spans.filter(span => !findTag(span.tags, 'X-HAYSTACK-AUTOGEN'));

  const shadows = _.flatMap(filteredSpans, span => [{time: span.startTime, value: 1}, {time: span.startTime + span.duration, value: -1}]);

  const sortedShadows = shadows.sort((a, b) => a.time - b.time);

  let runningCount = 0;
  let lastStartTimestamp = sortedShadows[0].time;
  let runningShadowDuration = 0;

  for (let i = 0; i < sortedShadows.length; i += 1) {
    if (runningCount === 1 && sortedShadows[i].value === -1) {
      runningShadowDuration += sortedShadows[i].time - lastStartTimestamp;
    }

    if (runningCount === 0 && sortedShadows[i].value === 1) {
      lastStartTimestamp = sortedShadows[i].time;
    }

    runningCount += sortedShadows[i].value;
  }

  return runningShadowDuration;
}
origin: ohbarye/review-waiting-list-bot

matchesReviewer(pr) {
  if (this.reviewer.values.length > 0) {
   const result = _.some(this.reviewer.values, (_reviewer) => {
    // Reviewer could be a user or a team
    const matched = _reviewer.match(/^.+\/(.+)$/)
    const usernameOrTeamName = matched ? matched[1] : _reviewer

    return _.flatMap(pr.reviewRequests.nodes, (request) => {
     return request.requestedReviewer.login || request.requestedReviewer.name
    }).includes(usernameOrTeamName)
   })
   return (this.reviewer.inclusion ? result : !result)
  } else {
   return true
  }
 }
origin: ohbarye/review-waiting-list-bot

matchesAssignee(pr) {
  if (this.assignee.values.length > 0) {
   const result = _.some(this.assignee.values, (_assignee) => {
    const matched = _assignee.match(/^.+\/(.+)$/)
    const username = matched ? matched[1] : _assignee

    return _.flatMap(pr.assignees.nodes, (assignee) => {
     return assignee.login
    }).includes(username)
   })
   return (this.assignee.inclusion ? result : !result)
  } else {
   return true
  }
 }
lodash(npm)LoDashStaticflatMap

JSDoc

Creates an array of flattened values by running each element in collection through iteratee
and concating its result to the other mapped values. The iteratee is invoked with three arguments:
(value, index|key, collection).

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

  • crypto
  • minimist
    parse argument options
  • minimatch
    a glob matcher in javascript
  • winston
    A logger for just about everything.
  • through2
    A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise
  • bluebird
    Full featured Promises/A+ implementation with exceptionally good performance
  • glob
    a little globber
  • express
    Fast, unopinionated, minimalist web framework
  • webpack
    Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.
  • Top PhpStorm plugins
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