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

curling

v1.1.0

Published

A simple wrapper around curl with a easy to use interface.

Downloads

251

Readme

curling

Build Status

A node wrapper for curl with a very simple api.

History:

1.1.0 Fixes bug introduce on 1.0.0 re-exports .run() and adds validation thanks @snoopysecurity and @joshuambg for the PR's

1.0.0 Removes curl.run because of a possible security issue reported by the Snyk team CVE-2019-10789

0.3.0: Increase max buffer size for curl response. By romansky - pull request 0.2.0: First release

API

Exports only one methods connect

The following characters are not allowed to be provided as part of a command to prevent possible command injections:

  • Dollar Sign ($)
  • Ampersand (&)
  • Backquote (`)
  • Curly brackets ({})
  • Square brackets ([)
  • Semi-colon (;)
  • Vertical bar (|)

connect(options)

This method takes an options object with general options that will be re-used in each command.

var options = {user: "hernan:secret"};

It returns a connection object.

Connection object API

It has five methods, each corresponding to an HTTP verb. They all have the same signature: method(url, options, cb). The method are:

head();
get();
post();
put();
del();  //DELETE

The callback takes two parameters cb(err, result) where the result is a curl-result object.

curl-result

It has two properties, payload and stats. The payload contains the data returned in the stdout by curl while the stats is an object that parse as the content of stderr.

Stats is of the form:

{
  totalSize: 0,
  received: 0,
  xferd: 0,
  averageDownloadSpeed: 0,
  averageUploadSpeed: 0,
  totalTime: 0,
  timeSpent: 0,
  timeLeft: 0,
  currentSpeed: '0 Kb'
}

The time properties are converted to milliseconds, the rest of the properties are of type Number in the same units as returned by curl except for the currentSpeed that is a string with the unit at the end (again as returned by curl).

Passing options.

There are two ways to pass options and data to a request. You can use the options for the connect method and this options will be used in each and every request. You can also use the options object in each of the verb methods.

The options object is actually a hash where the keys should be the name of the flag in a curl command, for example to set an Accept header and pass some data you could pass an options as the following.

var options = {
  header: "Accept: text/html",
  data: ["name=hernan", "last=garcia"]
};

The keys in an options object can be one of the following types, String, Array or null.

Strings are useful when you only need to set a single value, arrays are used to pass multiple values, like data, header and so. Null is a special case and is used for empty flags, like --false.