Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created April 28, 2020 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/d5564f4d6a97d76a9b925380cf6b5fe4 to your computer and use it in GitHub Desktop.
Save isaacs/d5564f4d6a97d76a9b925380cf6b5fe4 to your computer and use it in GitHub Desktop.
const pacote = require('../')
const https = require('https')
const fs = require('fs')
const pMap = require('p-map');
https.get('https://replicate.npmjs.com/_all_docs', res => {
const body = []
res.on('data', c => body.push(c))
res.on('end', () => runTest(JSON.parse(Buffer.concat(body).toString())))
})
const runTest = ({rows}) => {
console.error(`Starting test with ${rows.length} packuments`)
let i = 0
pMap(rows, ({id}) => pacote.packument(id).then(result => {
if (++i % 1000 === 0)
console.error(`fetched ${i} successfully`)
}), { concurrency: 8 })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment