Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async run() {
// Convert markdown to HTML
const markdownFiles = await helper.getFiles('*.md');
await pMap(markdownFiles, async filepath => {
await this.compile(filepath);
});
},
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,
}),
)
}
}
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 })
}
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
}
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
}
async fetchPriceHistoryForAllCurrencies() {
const currencySymbols = appContainer.state.enabledCoins;
const result = await pMap(currencySymbols, symbol => this.getCurrencyHistory(symbol), {concurrency: 6});
return _.zipObject(currencySymbols, result);
}
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);
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+''
})
}
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 })
}
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 })
}