add src folder
This commit is contained in:
parent
15cc89bb00
commit
36dcf02bcc
@ -6,7 +6,7 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node index.js"
|
||||
"start": "node ./src/index.js"
|
||||
},
|
||||
"author": "",
|
||||
"license": "MIT",
|
||||
|
@ -1,18 +1,10 @@
|
||||
import puppeteer from "puppeteer-core"
|
||||
import * as utils from "./utils.js"
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms))
|
||||
}
|
||||
|
||||
const settlePromises = async (promiseArray) => {
|
||||
const settledArray = await Promise.allSettled(promiseArray)
|
||||
let errors = settledArray.filter((resolved) => resolved.reason)
|
||||
if (errors.length) {
|
||||
throw errors
|
||||
}
|
||||
return settledArray.map((resolved) => resolved.value)
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const browser = await puppeteer.launch({
|
||||
headless: false,
|
8
src/utils.js
Normal file
8
src/utils.js
Normal file
@ -0,0 +1,8 @@
|
||||
export async function settlePromises(promiseArray) {
|
||||
const settledArray = await Promise.allSettled(promiseArray)
|
||||
let errors = settledArray.filter((resolved) => resolved.reason)
|
||||
if (errors.length) {
|
||||
throw errors
|
||||
}
|
||||
return settledArray.map((resolved) => resolved.value)
|
||||
}
|
Loading…
Reference in New Issue
Block a user