Tabnine Logo For Javascript
Array._pickAndConcatResults
Code IndexAdd Tabnine to your IDE (free)

How to use
_pickAndConcatResults
function
in
Array

Best JavaScript code snippets using builtins.Array._pickAndConcatResults(Showing top 6 results out of 315)

origin: commercetools/nodejs

async _getChannelsById(ids: Array<string>): Promise<Array<Object>> {
  const notCachedIds = ids.filter((id: string) => !this.channelsCache[id])

  // fetch unknown channels from API
  if (notCachedIds.length) {
   const predicate = `id in ("${notCachedIds.join('", "')}")`
   const channelService = this._createService('channels')
   const uri = channelService.where(predicate).build()

   const results = ProductJsonToCsv._pickAndConcatResults(
    await this.fetchReferences(uri)
   )
   results.forEach((result: Channel) => {
    // we should keep old channels in the cache because we can resolve
    // multiple products in parallel and we don't want to fetch same channels
    // multiple times
    this.channelsCache[result.id] = result
   })
  }

  // pick only requested channels from cache
  return pick(this.channelsCache, ids)
 }
origin: commercetools/nodejs

// This method decides if to get the categories from cache or API
 _getCategories(ids: Array<string>): Promise<Array<Object>> {
  const notCachedIds = []
  const cachedCategories = []
  ids.forEach((id: string) => {
   if (this.categoriesCache[id])
    cachedCategories.push(this.categoriesCache[id])
   else notCachedIds.push(id)
  })
  if (!notCachedIds.length) return Promise.resolve(cachedCategories)

  const predicate = `id in ("${notCachedIds.join('", "')}")`
  const categoriesService = this._createService('categories')
  const uri = categoriesService.where(predicate).build()
  return this.fetchReferences(uri).then(
   (res: SuccessResult[]): Array<Category> => {
    const results = ProductJsonToCsv._pickAndConcatResults(res)
    results.forEach((result: Category) => {
     cachedCategories.push(result)
     this.categoriesCache[result.id] = result
    })
    return cachedCategories
   }
  )
 }
origin: commercetools/nodejs

async _getCustomerGroupsById(ids: Array<string>): Promise<Array<Object>> {
  const notCachedIds = ids.filter(
   (id: string) => !this.customerGroupsCache[id]
  )

  // fetch unknown customerGroups from API
  if (notCachedIds.length) {
   const predicate = `id in ("${notCachedIds.join('", "')}")`
   const customerGroupService = this._createService('customerGroups')
   const uri = customerGroupService.where(predicate).build()
   const results = ProductJsonToCsv._pickAndConcatResults(
    await this.fetchReferences(uri)
   )

   results.forEach((result: CustomerGroup) => {
    // we should keep old customerGroups in the cache because we can resolve
    // multiple products in parallel and we don't want to fetch same customerGroups
    // multiple times
    this.customerGroupsCache[result.id] = result
   })
  }

  // pick only requested customerGroups from cache
  return pick(this.customerGroupsCache, ids)
 }
origin: commercetools/nodejs

async _getChannelsById(ids: Array<string>): Promise<Array<Object>> {
  const notCachedIds = ids.filter((id: string) => !this.channelsCache[id])

  // fetch unknown channels from API
  if (notCachedIds.length) {
   const predicate = `id in ("${notCachedIds.join('", "')}")`
   const channelService = this._createService('channels')
   const uri = channelService.where(predicate).build()

   const results = ProductJsonToCsv._pickAndConcatResults(
    await this.fetchReferences(uri)
   )
   results.forEach((result: Channel) => {
    // we should keep old channels in the cache because we can resolve
    // multiple products in parallel and we don't want to fetch same channels
    // multiple times
    this.channelsCache[result.id] = result
   })
  }

  // pick only requested channels from cache
  return pick(this.channelsCache, ids)
 }
origin: commercetools/nodejs

// This method decides if to get the categories from cache or API
 _getCategories(ids: Array<string>): Promise<Array<Object>> {
  const notCachedIds = []
  const cachedCategories = []
  ids.forEach((id: string) => {
   if (this.categoriesCache[id])
    cachedCategories.push(this.categoriesCache[id])
   else notCachedIds.push(id)
  })
  if (!notCachedIds.length) return Promise.resolve(cachedCategories)

  const predicate = `id in ("${notCachedIds.join('", "')}")`
  const categoriesService = this._createService('categories')
  const uri = categoriesService.where(predicate).build()
  return this.fetchReferences(uri).then(
   (res: SuccessResult[]): Array<Category> => {
    const results = ProductJsonToCsv._pickAndConcatResults(res)
    results.forEach((result: Category) => {
     cachedCategories.push(result)
     this.categoriesCache[result.id] = result
    })
    return cachedCategories
   }
  )
 }
origin: commercetools/nodejs

async _getCustomerGroupsById(ids: Array<string>): Promise<Array<Object>> {
  const notCachedIds = ids.filter(
   (id: string) => !this.customerGroupsCache[id]
  )

  // fetch unknown customerGroups from API
  if (notCachedIds.length) {
   const predicate = `id in ("${notCachedIds.join('", "')}")`
   const customerGroupService = this._createService('customerGroups')
   const uri = customerGroupService.where(predicate).build()
   const results = ProductJsonToCsv._pickAndConcatResults(
    await this.fetchReferences(uri)
   )

   results.forEach((result: CustomerGroup) => {
    // we should keep old customerGroups in the cache because we can resolve
    // multiple products in parallel and we don't want to fetch same customerGroups
    // multiple times
    this.customerGroupsCache[result.id] = result
   })
  }

  // pick only requested customerGroups from cache
  return pick(this.customerGroupsCache, ids)
 }
builtins(MDN)Array_pickAndConcatResults

Most used builtins functions

  • Console.log
  • Console.error
  • Promise.then
    Attaches callbacks for the resolution and/or rejection of the Promise.
  • Promise.catch
    Attaches a callback for only the rejection of the Promise.
  • Array.push
    Appends new elements to an array, and returns the new length of the array.
  • Array.length,
  • Array.map,
  • String.indexOf,
  • fetch,
  • Window.location,
  • Window.addEventListener,
  • ObjectConstructor.keys,
  • Array.forEach,
  • Location.reload,
  • Response.status,
  • Navigator.serviceWorker,
  • ServiceWorkerContainer.register,
  • ServiceWorkerRegistration.installing,
  • ServiceWorkerContainer.controller

Popular in JavaScript

  • minimist
    parse argument options
  • yargs
    yargs the modern, pirate-themed, successor to optimist.
  • mocha
    simple, flexible, fun test framework
  • cheerio
    Tiny, fast, and elegant implementation of core jQuery designed specifically for the server
  • fs
  • http
  • bluebird
    Full featured Promises/A+ implementation with exceptionally good performance
  • through2
    A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise
  • js-yaml
    YAML 1.2 parser and serializer
  • Best plugins for Eclipse
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