Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

popsicle

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

popsicle - npm Package Compare versions

Comparing version 2.0.2 to 3.0.0

dist/base.d.ts

29

package.json
{
"name": "popsicle",
"version": "2.0.2",
"version": "3.0.0",
"description": "Simple HTTP requests for node and the browser",
"main": "dist/lib/index.js",
"main": "dist/common.js",
"files": [
"dist/lib/",
"dist/",
"typings.json",

@@ -14,14 +14,15 @@ "LICENSE",

"buffer": false,
"form-data": "./dist/lib/browser/form-data.js",
"tough-cookie": "./dist/lib/browser/tough-cookie.js",
"./dist/lib/index.js": "./dist/lib/browser.js",
"./dist/lib/plugins/index.js": "./dist/lib/plugins/browser.js"
"form-data": "./dist/browser/form-data.js",
"tough-cookie": "./dist/browser/tough-cookie.js",
"./dist/index.js": "./dist/browser.js",
"./dist/plugins/index.js": "./dist/plugins/browser.js"
},
"scripts": {
"lint": "# TODO",
"build": "rm -rf dist/ && tsc",
"check-size": "browserify . -s popsicle --external bluebird > popsicle.js && du -h popsicle.js",
"build": "rm -rf dist/ && tsc && npm run check-size",
"test-spec": "npm run test-server-open && PORT=7357 node dist/test/index.js | tap-spec; EXIT=$?; npm run test-server-close; exit $EXIT",
"test-cov": "PORT=7357 istanbul cover --print none dist/test/index.js | tap-spec",
"test-browser": "PORT=7357 browserify -d -t envify dist/test/index.js | tape-run --browser phantom --render tap-spec",
"test-server-open": "PORT=7357 node test/support/server.js & echo $! > test.pid",
"test-browser": "PORT=7357 browserify -d -t envify dist/test/index.js | tape-run --render tap-spec",
"test-server-open": "PORT=7357 node scripts/server.js & echo $! > test.pid",
"test-server-close": "if [ -f test.pid ]; then kill -9 $(cat test.pid); rm test.pid; fi",

@@ -58,13 +59,11 @@ "test": "npm run lint && npm run build && npm run test-server-open && npm run test-cov && npm run test-browser; EXIT=$?; npm run test-server-close; exit $EXIT",

"body-parser": "^1.9.2",
"browserify": "^12.0.1",
"browserify": "^13.0.0",
"envify": "^3.4.0",
"es6-promise": "^3.0.2",
"express": "^4.10.2",
"istanbul": "^0.4.0",
"phantomjs": "^1.9.18",
"pre-commit": "^1.0.10",
"tap-spec": "^4.1.1",
"tape-run": "^2.1.0",
"tape-run": "2.1.0",
"typescript": "^1.7.3",
"typings": "^0.3.1"
"typings": "^0.5.2"
},

@@ -71,0 +70,0 @@ "dependencies": {

@@ -8,6 +8,6 @@ # ![Popsicle](https://cdn.rawgit.com/blakeembrey/popsicle/master/logo.svg)

**Popsicle** is designed to be easiest way for making HTTP requests by offering a consistent, intuitive and light-weight API that works with both node and the browser.
**Popsicle** is the easiest way to make HTTP requests - offering a consistent, intuitive and light-weight API that works on node and the browser.
```js
popsicle('/users.json')
popsicle.get('/users.json')
.then(function (res) {

@@ -22,5 +22,4 @@ console.log(res.status) //=> 200

```bash
```
npm install popsicle --save
bower install popsicle --save
```

@@ -34,3 +33,3 @@

popsicle({
popsicle.default({
method: 'POST',

@@ -53,5 +52,7 @@ url: 'http://example.com/api/users',

**Popsicle** is ES6-ready, aliasing `default` to the default export. Try using `import popsicle from 'popsicle'` or import specific methods using `import { get, defaults } from 'popsicle'`.
### Handling Requests
* **url** The resource URI
* **url** The resource location
* **method** The HTTP request method (default: `"GET"`)

@@ -62,3 +63,3 @@ * **headers** An object with HTTP headers, header name to value (default: `{}`)

* **timeout** The number of milliseconds to wait before aborting the request (default: `Infinity`)
* **use** An array of plugins to be used (default: `[stringify, headers, parse]`)
* **use** An array of plugins to be used (default: see below)
* **options** Raw options used by the transport layer (default: `{}`)

@@ -69,3 +70,3 @@ * **transport** Override the transportation layer (default: `http.request/https.request` (node), `XMLHttpRequest` (brower))

The default plugins under node are `[stringify, headers, cookieJar, unzip, concatStream('string'), parse]`, since the extra options aren't customizable for the browser.
The default plugins under node are `[stringify(), headers(), unzip(), concatStream('string'), parse()]`.

@@ -80,2 +81,4 @@ * **jar** An instance of a cookie jar (`popsicle.jar()`) (default: `null`)

The default plugins in the browser are `[stringify(), headers(), parse()]`. Notice that unzipping and various stream parsing is not yet available in browsers.
* **withCredentials** Send cookies with CORS requests (default: `false`)

@@ -88,6 +91,10 @@ * **responseType** Set the XHR `responseType` (default: `undefined`)

Every method has a short hand exposed under the main Popsicle function.
Common methods have a short hand exported (created using `defaults({ method: 'get' })`).
```js
popsicle.get('http://example.com/api/users')
popsicle.post('http://example.com/api/users')
popsicle.put('http://example.com/api/users')
popsicle.patch('http://example.com/api/users')
popsicle.del('http://example.com/api/users')
```

@@ -97,3 +104,3 @@

Create a new Popsicle function with defaults set. Handy for a consistent cookie jar or transport to be used.
Create a new request function with defaults pre-populated. Handy for a common cookie jar or transport to be used.

@@ -106,6 +113,6 @@ ```js

Popsicle can automatically serialize the request body with the built-in `stringify` plugin. If an object is supplied, it will automatically be stringified as JSON unless the `Content-Type` was set otherwise. If the `Content-Type` is `multipart/form-data` or `application/x-www-form-urlencoded`, it will be automatically serialized.
Popsicle can automatically serialize the request body using the built-in `stringify` plugin. If an object is supplied, it will automatically be stringified as JSON unless the `Content-Type` was set otherwise. If the `Content-Type` is `multipart/form-data` or `application/x-www-form-urlencoded`, it will be automatically serialized.
```js
popsicle({
popsicle.get({
url: 'http://example.com/api/users',

@@ -142,3 +149,3 @@ body: {

```js
var request = popsicle('http://example.com')
var request = popsicle.get('http://example.com')

@@ -169,3 +176,3 @@ setTimeout(function () {

```js
var request = popsicle('http://example.com')
var request = popsicle.get('http://example.com')

@@ -221,3 +228,3 @@ request.uploaded //=> 0

popsicle({
popsicle.default({
method: 'POST',

@@ -240,3 +247,3 @@ url: '/users',

```js
popsicle('/users')
popsicle.get('/users')
.then(function (res) {

@@ -250,7 +257,7 @@ // Success!

If you live on the edge, try using it with generators (with [co](https://www.npmjs.com/package/co)) or ES7 `async`.
If you live on the edge, try using it with generators (see [co](https://www.npmjs.com/package/co)) or ES7's `async`.
```js
co(function * () {
yield popsicle('/users')
yield popsicle.get('/users')
})

@@ -264,3 +271,3 @@ ```

```js
popsicle('/users')
popsicle.get('/users')
.exec(function (err, res) {

@@ -309,6 +316,7 @@ if (err) {

* [Server](https://github.com/blakeembrey/popsicle-server) - Automatically mount a server on each request (handy for testing)
* [Server](https://github.com/blakeembrey/popsicle-server) - Automatically mount a server on an available for the request (helpful for testing a la `supertest`)
* [Status](https://github.com/blakeembrey/popsicle-status) - Reject responses on HTTP failure status codes
* [Cache](https://github.com/blakeembrey/popsicle-cache) - Built-in cache handling of HTTP requests under node (customizable store, uses a filesystem store by default)
* [No Cache](https://github.com/blakeembrey/popsicle-no-cache) - Prevent caching of HTTP requests in browsers
* [Basic Auth](https://github.com/blakeembrey/popsicle-basic-auth) - Add basic authentication headers to each request
* [Basic Auth](https://github.com/blakeembrey/popsicle-basic-auth) - Add a basic authentication header to each request
* [Prefix](https://github.com/blakeembrey/popsicle-prefix) - Prefix all HTTP requests

@@ -331,3 +339,3 @@ * [Resolve](https://github.com/blakeembrey/popsicle-resolve) - Resolve all HTTP requests against a base URL

popsicle('/user')
popsicle.default('/user')
.use(prefix('http://example.com'))

@@ -365,3 +373,3 @@ .then(function (response) {

Install dependencies and run the test runners (node and PhantomJS using Tap).
Install dependencies and run the test runners (node and Electron using Tape).

@@ -368,0 +376,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc