0.1.1 • Published 9 years ago

npm-tarball v0.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

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'))

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