Tabnine Logo For Javascript
flatten
Code IndexAdd Tabnine to your IDE (free)

How to use
flatten
function
in
lodash

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

origin: UPchieve/server

flatten(
  volunteers.map(vol => {
   return vol.references
    .filter(ref => ref.status === REFERENCE_STATUS.UNSENT)
    .map(ref => ({
     reference: ref,
     volunteer: vol
    }));
  })
 )
origin: TryGhost/nodecmsguide

/**
 * Generate dropdown filter values from frontmatter values.
 */
function generateFilters (projects) {
 const types = sortBy(uniq(map(projects, 'type')))
 const generators = sortBy(uniq(flatten(map(projects, 'generators'))))

 return { types, generators }
}
origin: avajs/ava-codemods

flatten(scripts).map(script => path.join(__dirname, script))
origin: mindjs/mindjs

/**
  *
  * @param moduleDI
  * @returns {Promise<*[]>}
  */
 static async extractRoutingModules(moduleDI) {
  const { module: appModule, injector: moduleInjector } = moduleDI;
  const { imports = [] } = appModule;
  let resolvedRoutingModules = [];

  const routingModules = imports.filter(m => isModuleWithProviders(m) && isRoutingModule(m));

  const routingModulesResolver = toArray(injectSync(moduleInjector, APP_ROUTING_MODULES_RESOLVER));
  if (routingModulesResolver) {
   resolvedRoutingModules = await invokeOnAll(routingModulesResolver, 'resolve');
  }

  return [
   ...flatten(resolvedRoutingModules),
   ...routingModules,
  ];
 }
origin: james-jenkinson/react-twitterApi-example

const initSearchServer = () => {
 const client = elasticsearch.Client({
  host: "localhost:9200",
 });

 return {
  load: (tweets) => tweets.length > 0 &&
   client.bulk({
    body: flatten(tweets.map(t => [{index: { _index: "tweets", _type: "tweet", _id: t.id}}, t])),
   }),
  search: (search) => client.search({
   index: "tweets",
   type: "tweet",
   q: `text:${search}`
  }),
 };
}
origin: brantburnett/couchbase-index-manager

/**
   * Prints the plan
   */
  print() {
    if (this.isEmpty()) {
      this.options.logger.info(
        chalk.yellowBright('No mutations to be performed'));
      return;
    }

    this.options.logger.info();
    this.options.logger.info('Index sync plan:');
    this.options.logger.info();

    flatten(this.mutations).forEach((mutation) => {
      mutation.print(this.options.logger);

      // Add blank line
      this.options.logger.info();
    });
  }
origin: dunizb/CodeTest

static async getList(artInfoList) {
    const artInfoObj = {
      100: [],
      200: [],
      300: [],
    }
    for (let artInfo of artInfoList) {
      artInfoObj[artInfo.type].push(artInfo.art_id)
    }
    const arts = []
    for (let key in artInfoObj) {
      const ids = artInfoObj[key]
      if (ids.length === 0) {
        continue
      }

      key = parseInt(key)
      arts.push(await Art._getListByType(ids, key))
    }

    return flatten(arts)
  }
origin: bukinoshita/open-source

static async getInitialProps() {
  const getIssuesRes = await fetch(
   `https://api.github.com/search/issues?q=state:open+label:first-timers-only&sort=created&order=desc&per_page=100&access_token=${
    process.env.GITHUB_TOKEN
   }`,
   { cache: 'default' }
  )
  const issuesResJson = await getIssuesRes.json()
  const issues = issuesResJson.items
  const repoLanguagesStore = await getLanguages(issues)
  const languages = uniq(flatten(Object.values(repoLanguagesStore)))
  const languageCountStore = languages.reduce(
   (languageCountStore, language) => set(languageCountStore, language, 0),
   { [clearLanguageFilterButtonText]: issues.length }
  )

  issues.forEach(issue => {
   issue.languages = repoLanguagesStore[issue.repository_url]
   issue.languages.forEach(language => (languageCountStore[language] += 1))
  })

  return { issues, languageCountStore }
 }
origin: mindjs/mindjs

/**
  *
  * @param appServer
  * @returns {Promise<[]|*>}
  */
 async resolveAndInitRouters(appServer) {
  if (!appServer) {
   return;
  }

  this.appServer = appServer;

  const routerDescriptorResolvers = injectSync(this.moduleInjector, APP_ROUTER_DESCRIPTOR_RESOLVER);

  if (!routerDescriptorResolvers) {
   this.routers = [];
   return;
  }

  const routers = await Promise.all(
   toArray(routerDescriptorResolvers)
    .filter(Boolean)
    .filter(r => isFunction(r.resolve))
    .map((r) => this._resolveRouter(r))
  );

  this.routers = flatten(routers);
  await this.initRouters();
 }
origin: TryGhost/Ghost-CLI

const combinedChecks = checks.concat(flatten(extensionChecks).filter(Boolean));
origin: northerneyes/react-intl-example

const length = files.length;
console.log(`Received ${length} files`);
const messages = flatten(files.map((filePath, index) => {
 const file = fs.readFileSync(filePath);
 const code = file.toString();
origin: flipio/react-d3-examples

 bars: flatten(bars),
};
origin: flipio/react-d3-examples

const {xScale, yScale, lineGenerator} = prevState;
const dataToShow = multi ? flatten(data) : data;
origin: mindjs/mindjs

/**
  *
  * @param moduleDI
  * @returns {Promise<*[]>}
  */
 static async extractRoutingModules(moduleDI) {
  const { module: appModule, injector: moduleInjector } = moduleDI;
  const { imports = [] } = appModule;
  let resolvedRoutingModules = [];

  const routingModules = imports.filter(m => isModuleWithProviders(m) && isRoutingModule(m));

  const routingModulesResolver = toArray(injectSync(moduleInjector, APP_ROUTING_MODULES_RESOLVER));
  if (routingModulesResolver) {
   resolvedRoutingModules = await invokeOnAll(routingModulesResolver, 'resolve');
  }

  return [
   ...flatten(resolvedRoutingModules),
   ...routingModules,
  ];
 }
origin: mindjs/mindjs

/**
  *
  * @param appServer
  * @returns {Promise<[]|*>}
  */
 async resolveAndInitRouters(appServer) {
  if (!appServer) {
   return;
  }

  this.appServer = appServer;

  const routerDescriptorResolvers = injectSync(this.moduleInjector, APP_ROUTER_DESCRIPTOR_RESOLVER);

  if (!routerDescriptorResolvers) {
   this.routers = [];
   return;
  }

  const routers = await Promise.all(
   toArray(routerDescriptorResolvers)
    .filter(Boolean)
    .filter(r => isFunction(r.resolve))
    .map((r) => this._resolveRouter(r))
  );

  this.routers = flatten(routers);
  await this.initRouters();
 }
lodash(npm)flatten

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

  • fs
  • http
  • colors
    get colors in your node.js console
  • minimist
    parse argument options
  • axios
    Promise based HTTP client for the browser and node.js
  • commander
    the complete solution for node.js command-line programs
  • superagent
    elegant & feature rich browser / node HTTP with a fluent API
  • path
  • express
    Fast, unopinionated, minimalist web framework
  • Best IntelliJ 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