Skip to content

download tarball of npm registry with stream/promise api

Notifications You must be signed in to change notification settings

59naga/npm-tarball

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm-tarball

Download tarball of npm registry with stream/promise api

Installation

npm install npm-tarball --save

API

  • resolveUri(packageName, semver) -> Promise<uri>
import {resolveUri} from 'npm-tarball'

resolveUri('jquery').then(uri => console.log(uri))
// https://registry.npmjs.org/jquery/-/jquery-2.2.4.tgz

resolveUri('jquery', 1).then(uri => console.log(uri))
// https://registry.npmjs.org/jquery/-/jquery-1.12.4.tgz

resolveUri('jquery', '~2.1').then(uri => console.log(uri))
// https://registry.npmjs.org/jquery/-/jquery-2.1.4.tgz
  • fetch(packageName, semver) -> Promise<tarballBuffer>
import {fetch} from 'npm-tarball'
import {writeFileSync} from 'fs'

fetch('jquery').then(buffer => writeFileSync('jquery-latest.tgz', buffer))
fetch('jquery', 1).then(buffer => writeFileSync('jquery-v1.tgz', buffer))
fetch('jquery', '~2.1').then(buffer => writeFileSync('jquery-v2.1.tgz', buffer))
  • new NpmTarball(packageName, semver) -> tarballReadableStream
  • createReadStream(packageName, semver) -> tarballReadableStream
import {createReadStream} from 'npm-tarball'
import {createWriteStream} from 'fs'

createReadStream('jquery').pipe(createWriteStream('jquery-latest.tgz'))
createReadStream('jquery', 1).pipe(createWriteStream('jquery-v1.tgz'))
createReadStream('jquery', '~2.1').pipe(createWriteStream('jquery-v2.1.tgz'))

Related project

Development

Requirement global

  • NodeJS v5.11.1
  • Npm v3.8.6 (or pnpm)
git clone https://github.com/59naga/npm-tarball
cd npm-tarball
npm install

npm test
npm run lint

License

MIT

About

download tarball of npm registry with stream/promise api

Resources

Stars

Watchers

Forks

Packages

No packages published