How to use the p-map function in p-map

To help you get started, we’ve selected a few p-map 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 algolia / docsearch / docs / scripts / lib / markdown.js View on Github external
async run() {
    // Convert markdown to HTML
    const markdownFiles = await helper.getFiles('*.md');
    await pMap(markdownFiles, async filepath => {
      await this.compile(filepath);
    });
  },
github steelbrain / pundle / packages / pundle-api / src / context / index.js View on Github external
async invokeIssueReporters(issue: any): Promise {
    const issueReporters = this.getComponents('issue-reporter')

    if (!issueReporters.length) {
      console.error('No Issue Reporters found to report this issue:', issue)
      return
    }

    await pMap(issueReporters, issueReporter =>
      issueReporter.callback({
        issue,
        context: this,
      }),
    )
  }
}
github KnicKnic / WASM-ImageMagick / samples / interactive-execute-context / src / app.tsx View on Github external
protected async updateImages() {
    const files = await this.props.context.getAllFiles()
    const isImageArray = await pMap(files, isImage)
    const imgSrcs = this.state.showImagesAndInfo ? await pMap(files, (f, i) => buildFileSrc(f, isImageArray[i])) : this.state.imgSrcs
    const filesInfo = this.state.showImagesAndInfo ? await pMap(files, (f, i) => isImageArray[i] ? extractInfo(f) : undefined) : this.state.filesInfo
    const outputFileSrcs = await pMap(this.state.outputFiles, (f, i) => buildFileSrc(f))
    this.setState({ ...this.state, files, imgSrcs, outputFileSrcs, filesInfo, isImageArray })
  }
github KnicKnic / WASM-ImageMagick / src / util / imageBuiltIn.ts View on Github external
export async function getBuiltInImages(): Promise {
  if (!builtInImages) {
    builtInImages = await pMap(builtInImageNames, async name => {
      const info = await extractInfo(name)
      const {outputFiles} = await execute({commands: `convert ${name} ${`output1.${info[0].image.format.toLowerCase()}`}`} )
      outputFiles[0].name = name
      return await asInputFile(outputFiles[0])
    })
  }
  return builtInImages
}
github steelbrain / pundle / packages / pundle-core / src / watcher.js View on Github external
async function compile({ changedImports = new Set() }: { changedImports?: Set } = {}) {
    if (!needsRecompilation && !isFirstCompile) {
      return
    }
    const oldIsFirstCompile = isFirstCompile
    isFirstCompile = false
    needsRecompilation = false

    const locks = new Set()
    const changedImportsCombined = new Set([...changedImports, ...lastChangedImports])

    try {
      const changedImportsRef = new Set(changedImportsCombined)
      await pMap(configChunks, chunk =>
        pundle.transformChunk({
          job,
          chunk,
          locks,
          tickCallback,
          changedImports: changedImportsRef,
        }),
      )
      lastChangedImports.clear()
    } catch (error) {
      isFirstCompile = oldIsFirstCompile
      needsRecompilation = !isFirstCompile
      lastChangedImports = changedImportsCombined

      throw error
    }
github atomiclabs / hyperdex / app / renderer / containers / Dashboard.js View on Github external
async fetchPriceHistoryForAllCurrencies() {
		const currencySymbols = appContainer.state.enabledCoins;
		const result = await pMap(currencySymbols, symbol => this.getCurrencyHistory(symbol), {concurrency: 6});
		return _.zipObject(currencySymbols, result);
	}
github microapps / store-locator / src / components / StoreLocator.js View on Github external
async calculateDistance(searchLocation) {
    const {limit} = this.props;
    if (!searchLocation) return this.props.stores;
    const stores = await this.loadStores(searchLocation);
    const data = await promiseMap(stores, store => {
      return this.getDistance(searchLocation, store.location).then(result => {
        Object.assign(store, result);
        return store;
      });
    });
    let result = data.sort((a, b) => a.distance - b.distance);
    const bounds = new google.maps.LatLngBounds();
    bounds.extend(searchLocation);
    this.clearMarkers();
    result = result.map((store, i) => {
      store.hidden = i + 1 > limit;
      const marker = this.addStoreMarker(store);
      if (store.hidden) {
        marker.setOpacity(this.props.farAwayMarkerOpacity);
      } else {
        bounds.extend(store.location);
github KnicKnic / WASM-ImageMagick / samples / supported-formats / src / app.tsx View on Github external
async componentDidMount() {
    const images = await pmap(this.props.formats, format => buildInputFile(this.imageName(format)))
    const results = await pmap(images, image => execute({ inputFiles: images, commands: `convert ${image.name} output.png` }))
    const convertedImages = await pmap(results, r=>r.outputFiles[0])
    await pmap(results, (result, i) => {
      const el = document.getElementById(`image_${this.props.formats[i]}`) as HTMLImageElement
      return loadImageElement(convertedImages[0], el)
    })
    const compareResults = await pmap(images, (image, i) => {  
      return compareNumber(image, convertedImages[i])
    })
    await pmap(compareResults, (r,i)=>{
      const el = document.getElementById(`comparision_${this.props.formats[i]}`)
      el.innerHTML=r+''
    })
  }
github KnicKnic / WASM-ImageMagick / samples / interactive-execute-context / src / app.tsx View on Github external
protected async updateImages() {
    const files = await this.props.context.getAllFiles()
    const isImageArray = await pMap(files, isImage)
    const imgSrcs = this.state.showImagesAndInfo ? await pMap(files, (f, i) => buildFileSrc(f, isImageArray[i])) : this.state.imgSrcs
    const filesInfo = this.state.showImagesAndInfo ? await pMap(files, (f, i) => isImageArray[i] ? extractInfo(f) : undefined) : this.state.filesInfo
    const outputFileSrcs = await pMap(this.state.outputFiles, (f, i) => buildFileSrc(f))
    this.setState({ ...this.state, files, imgSrcs, outputFileSrcs, filesInfo, isImageArray })
  }
github KnicKnic / WASM-ImageMagick / samples / interactive-execute-context / src / app.tsx View on Github external
protected async updateImages() {
    const files = await this.props.context.getAllFiles()
    const isImageArray = await pMap(files, isImage)
    const imgSrcs = this.state.showImagesAndInfo ? await pMap(files, (f, i) => buildFileSrc(f, isImageArray[i])) : this.state.imgSrcs
    const filesInfo = this.state.showImagesAndInfo ? await pMap(files, (f, i) => isImageArray[i] ? extractInfo(f) : undefined) : this.state.filesInfo
    const outputFileSrcs = await pMap(this.state.outputFiles, (f, i) => buildFileSrc(f))
    this.setState({ ...this.state, files, imgSrcs, outputFileSrcs, filesInfo, isImageArray })
  }

p-map

Map over promises concurrently

MIT
Latest version published 29 days ago

Package Health Score

85 / 100
Full package analysis