From 4e461125e410fb3e147b0ed26d528858b900d417 Mon Sep 17 00:00:00 2001 From: Shannon Rothe Date: Mon, 8 Mar 2021 20:48:28 +1100 Subject: [PATCH] Use `p-map` --- .DS_Store | Bin 0 -> 6148 bytes .vscode/settings.json | 6 ++++++ package.json | 1 - source/index.ts | 17 ++++++++++------- 4 files changed, 16 insertions(+), 8 deletions(-) create mode 100644 .DS_Store create mode 100644 .vscode/settings.json diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4edabb3d810b6ab38ec783c2e9ec762d4d85f24a GIT binary patch literal 6148 zcmeHKy-or_5dIcUCE8FJW4SM&kvBNVnV47^UO@Q?m_UvQ6n6IjHr7`5HW~{PJ4>~) z@inZho!MPrmjg>;%uKTT?d{C$eD{UhWdW$#xK#nl07}#tqfP1-82h>9tl(z02^Fu= z>s0E^v_Hs2%7iE&3j9R{_}h)Jj}Fc;3clZ~uVdfWPm`q4OB*y-dXH{;&mS+<(BJyi zKj?aU!?mVVY)tB+i!mBObrf#%5k7}v^)-329Ol;Pr!ywYqXIrKeAduM8!b}eEZ}ng zeL`G3ug_x#ZxbFt#Eiq@h@k#MOa-uxAyQJ}0!_372GB?IexF14@^iu=Si@IhSxmqK z2h1bFh;$gv{T{IQ===Qo)w^l^X|7*;kw2^}M+OVOVxu#gt+ZuPdQm_W5Cx_R@cy8w zF~$xvi)QPf&RhWqBbqiw<1!BjwZqt9W|2H(%BB+9ROPN1%BIu2c5$)8%%V+)a+eR~ zDl2zGQKmYruT3~qY*BhqKokfSDB8y|pZ|x;@Bd+vJc$CLz`s&JMM*uW(JQ&LHTQCS v)@o{})Yv#KvuIMNbH}k6@KL-=%^3MK4+vw2nMIl*lRpAR2I)kBl`8N9j=!f` literal 0 HcmV?d00001 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..404d967 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "html.format.enable": false, + "json.format.enable": false, + "javascript.format.enable": false, + "editor.codeActionsOnSave": null +} \ No newline at end of file diff --git a/package.json b/package.json index 68d32be..b8db44c 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,6 @@ "lodash.template": "^4.5.0", "log-symbols": "^4.0.0", "make-dir": "^3.1.0", - "p-all": "^3.0.0", "p-memoize": "^4.0.1", "plur": "^4.0.0", "unused-filename": "^2.1.0", diff --git a/source/index.ts b/source/index.ts index 38afb8a..88d23c4 100644 --- a/source/index.ts +++ b/source/index.ts @@ -1,5 +1,5 @@ -import {promisify} from 'util'; import {parse as parseUrl} from 'url'; // eslint-disable-line node/no-deprecated-api +import {promisify} from 'util'; import path = require('path'); import fs = require('fs'); import {EventEmitter} from 'events'; @@ -17,7 +17,7 @@ import viewportList = require('viewport-list'); import template = require('lodash.template'); import plur = require('plur'); import filenamifyUrl = require('filenamify-url'); -import pAll = require('p-all'); +import pMap = require('p-map'); import os = require('os'); // TODO: Move this to `type-fest` @@ -171,11 +171,14 @@ export default class Pageres extends EventEmitter { return this.viewport({url: source.url, sizes, keywords}, options); } - const screenshots: Screenshot[] = await pAll(this.sizes.map(async (size: string): Promise => { - return this.create(source.url, size, options); - }), {concurrency: cpuCount * 2}); - - this.items.push(...screenshots); + await pMap( + this.sizes, + async (size: string) => { + this.sizes.push(size); + this.items.push(await this.create(source.url, size, options)); + }, + {concurrency: cpuCount * 2} + ); return undefined; }));