UNPKG

@small-tech/auto-encrypt

Version:

Automatically provisions and renews Let’s Encrypt TLS certificates on Node.js https servers (including Kitten, Polka, Express.js, etc.)

28 lines (26 loc) 717 B
//////////////////////////////////////////////////////////////////////////////// // // asyncForEach by Sebastien Chopin // // https://codeburst.io/javascript-async-await-with-foreach-b6ba62bbf404 // // Example: // // const waitFor = (ms) => new Promise(r => setTimeout(r, ms)) // // async function main () { // await asyncForEach([1, 2, 3], async (num) => { // await waitFor(50) // console.log(num) // }) // console.log('Done') // } // // main(); // //////////////////////////////////////////////////////////////////////////////// export default async function asyncForEach(array, callback) { for (let index = 0; index < array.length; index++) { await callback(array[index], index, array); } }