npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jswget

v0.4.1

Published

REST and resumable download client for nodejs

Downloads

42

Readme

jswget

NPM version Stories in Ready build status

Introduction

REST and resumable download client for nodejs

Instalation

npm install jswget

Usage

jswget(options);

Sample

Download File

var jswget = require('jswget');
jswget({
    url: "http://192.168.7.54:4000/2_thumb.jpg",
    downloadmode: true,
    // if not given will try to get name from last path, otherwise force to use this name
    downloadas: "2_thumb.jpg",
    // if not given, the default path is where the program run
    downloadpath: "./",
    method: "GET",
    onsend: function(req, options){
        console.log("Start")
    },
    onhead: function(fstat, req, res){
        console.log(res.headers)
    },
    ondata: function(chunk, req, res){
        console.log("Get: " + chunk.length)
		process.exit();
    },
    onsuccess: function(resp, req, res){
        console.log("Done")
    },
    onerror: function(err, req){
        console.log("Error", err);
    }
});

Features

  1. In downlaod mode, When file with same name found in download path, jswget will try to resume the download.
  2. Cookie support, you can get cookie vars, or store and read automaticaly from a file path
  3. Upload mode
  4. Redirect follow
  5. Auth and OAuth computation
  6. Support for both HTTPS and HTTP
  7. Pipe request output stream
  8. Send POST data or raw data
  9. etc

Options

* the configuration are:
 *   url                #STRING url input with format [protocol]://[host]:[port]/[path]?[query]#[bookmark]
 *   protocol           #STRING protocol, together with hostname, port, path (as query too) as url
 *   hostname           #STRING hostname, together with protocol, port, path (as query too) as url
 *   port               #STRING port, together with protocol, hostname, path (as query too) as url
 *   path               #STRING path (as query too), together with protocol, hostname, port as url
 *   method             #STRING method default is GET
 *   headers            #OBJECT set of request headers
 *   rawdata            #STRING send raw data with request
 *   formdata           #OBJECT JSON of pair form name and value to be sent with request
 *   query	            #OBJECT JSON of pair query argument name and value sent with request, added in path
 *   auth               #OBJECT JSON of pair username and password of base64 auth header
 *   oauth              #OBJECT JSON of oauth component contain {consumer_key, consumer_secret, access_token, token_secret, [signature_method], [oauth_token_version]}
 *   encoding           #STRING response encoding default is utf-8
 *   onsend             #FUNCTION triggered when request is initiated [request object, configuration object]
 *   onresponse         #FUNCTION triggered when request is got first response [request object, response object, configutation object]
 *   onredirect         #FUNCTION triggered when request is beng redirected with argument [request object, response object, configutation object]
 *   ondata             #FUNCTION triggered when request is on progress with argument [chunck, request object, response object, configutation object]
 *   onsuccess          #FUNCTION triggered when request is completed with argument [response, request object, response object, configutation object]
 *   onerror            #FUNCTION triggered when request is incomplete with argument [error object, request object, configutation object]
 *   onhead             #FUNCTION triggered when request is got head response (download mode) with argument [error object, request object, response object, configutation object]
 *   onend              #FUNCTION triggered when request is end, regardless result with argument [request object, configutation object]
 *   onsocket           #FUNCTION triggered when request is got socket assigned with argument [socket object, request object, configutation object]
 *   onconnect          #FUNCTION triggered when request is got response CONNECT method upgrade with argument [request object, response object, socket object, head object, configutation object]
 *   onupgrade          #FUNCTION triggered when request is got response upgrade from server with argument [request object, response object, socket object, head object, configutation object]
 *   oncontinue         #FUNCTION triggered when request is got "100 Continue" response from server with argument [request object, configutation object]
 *   scope              #OBJECT scope of callback
 *   pipestream         #STREAM Stream to be piped response, see node.js Fs documentation
 *   cookiefile         #STRING path of cookie file
 *   cookies            #OBJECT of cookie { configs.cookiename: {value, path, expires, max-age, secure, httponly, domain, port, commenturl, discard} }
 *   downloadmode       #BOOLEAN set true to enter download mode
 *   downloadas         #STRING rename downloaded file
 *   downloadpath       #STRING path of downloaded file
 *   uploadfile         #STRING file path to be uploaded, upload file work only when downlloadmode = false, and no other form is uploaded
 *   timeout            #NUMBER time out in mili second
 *   follow             #BOOLEAN follow redirection, default is true
 *   maxfollow          #NUMBER Max number of redirection before throw error, default is 10
 *   -HTTPS Option see nodejs HTTPS documentation-
 *   pfx                #STRING when the protocol is https, the https client will be constructed using this configuration
 *   key                #STRING when the protocol is https, the https client will be constructed using this configutation
 *   passphrase         #STRING when the protocol is https, the https client will be constructed using this configutation
 *   cert               #STRING when the protocol is https, the https client will be constructed using this configutation
 *   ca                 #STRING when the protocol is https, the https client will be constructed using this configutation
 *   ciphers            #STRING when the protocol is https, the https client will be constructed using this configutation
 *   rejectUnauthorized #STRING when the protocol is https, the https client will be constructed using this configutation

Changelist

Version 0.2.x

  • Add onredirect, onsocket, onconnect, onupgrade, oncontinue listeners
  • Make sure to create new aggent for every request
  • Restructured whole code, to avoid repetitive

To Do

  1. More testing,
  2. Check download integrity
  3. More feature

Documentation

Tests

Contribution

You are welcome to contribute by writing issues or pull requests.

You are also welcome to correct any spelling mistakes or any language issues, because my english is not perfect...

License

Copyright (c) 2014 Decky Fx

MIT (http://www.opensource.org/licenses/mit-license.php)