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

get-it

Package Overview
Dependencies
Maintainers
1
Versions
159
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

get-it - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

.babelrc

79

package.json
{
"name": "get-it",
"version": "0.0.1",
"description": "Get it! Get it?",
"main": "index.js",
"version": "0.0.2",
"description": "Generic HTTP request library for node and browsers",
"main": "lib/index.js",
"browser": {
"./src/request/node-request.js": "./src/request/browser-request.js",
"./lib/request/node-request.js": "./lib/request/browser-request.js",
"./src/middleware/progress/node-progress.js": "./src/middleware/progress/browser-progress.js",
"./lib/middleware/progress/node-progress.js": "./lib/middleware/progress/browser-progress.js",
"./src/util/node-shouldRetry.js": "./src/util/browser-shouldRetry.js",
"./lib/util/node-shouldRetry.js": "./lib/util/browser-shouldRetry.js",
"fs": "./test/helpers/noop.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"ci": "npm run coverage && npm run karma && npm run lint",
"clean": "rimraf lib .nyc_output coverage npm-debug.log yarn-debug.log",
"coverage": "nyc --reporter=html --reporter=lcov --reporter=text _mocha",
"karma": "karma start",
"lint": "eslint .",
"posttest": "npm run lint",
"test": "mocha"
},
"author": "Espen Hovlandsdal <espen@hovlandsdal.com>",
"license": "MIT"
"keywords": [
"request",
"http",
"fetch"
],
"author": "Sanity.io <hello@sanity.io>",
"license": "MIT",
"dependencies": {
"@rexxars/timed-out": "^3.0.1",
"any-observable": "^0.2.0",
"any-promise": "^1.3.0",
"create-error-class": "^3.0.2",
"debug": "^2.3.3",
"follow-redirects": "^1.2.0",
"global": "^4.3.1",
"into-stream": "^3.1.0",
"is-retry-allowed": "^1.1.0",
"is-stream": "^1.1.0",
"nano-pubsub": "^1.0.1",
"object-assign": "^4.1.0",
"parse-headers": "^2.0.1",
"progress-stream": "^1.2.0",
"same-origin": "^0.1.1",
"simple-concat": "^1.0.0",
"unzip-response": "^2.0.1",
"url-parse": "^1.1.7"
},
"devDependencies": {
"@sanity/observable": "^1.1.0",
"babel-cli": "^6.18.0",
"babel-loader": "^6.2.8",
"babel-preset-es2015": "^6.18.0",
"babel-preset-es2015-node4": "^2.1.0",
"babel-register": "^6.18.0",
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"chai-subset": "^1.3.0",
"eslint": "^3.11.1",
"eslint-config-sanity": "^2.0.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-firefox-launcher": "^1.0.0",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-virtualboxany-launcher": "^0.0.6",
"karma-webpack": "^1.8.0",
"lodash.once": "^4.1.1",
"mocha": "^3.2.0",
"nyc": "^10.0.0",
"pinkie-promise": "^2.0.1",
"rimraf": "^2.5.4",
"webpack": "^1.13.3"
}
}

@@ -1,2 +0,71 @@

More to come!
# get-it
## Wanted features
* [ ] Developer-friendly assertions that are stripped in production to reduce bundle size and performance
* [ ] Authentication (basic)
* [ ] Stream response middleware?
* [x] Progress upload/download events as middleware (available on observable/eventemitter)
* [x] All HTTP methods supported (obviously)
* [x] Configurable number of retries + "should retry" handler
* [x] Follow redirects (optional) up to limit
* [x] Gzip unwrapping support in node (browser automatically handles this)
* [x] Middleware-ish (like MJ's request lib)
* [x] Node and browser support (XHR), with small browser bundle footprint
* [x] Observable/promise/callback/eventemitter support as middleware (low-level by default)
* [x] Parsing of JSON request/response payloads as middleware
* [x] Send file/buffer/stuff as body, should just work
* [x] Timeouts with errors that are catchable (connect/response as separate in node)
## Options
* `rawBody` - Set to `true` to return the raw value of the response body, instead of a string. *Important note*: The returned body will be different in Node and browser environments. In Node, it will return a `Buffer`, while in browsers it will return an `ArrayBuffer`.
## Middleware
Each middleware is an object of hook => action bindings. They are called in the order they are added to the request instance using `request.use()`. For instance, if you want to always set a certain header on outgoing responses, you could do:
```
const isAwesome = {
processOptions: options => Object.assign({
headers: Object.assign({}, options.headers, {
'X-Is-Awesome': 'Absolutely'
})
})
}
request.use(isAwesome)
```
The available hooks, their arguments and expected return values are as following:
### processOptions
Called once a new request is instantiated. Can be used to alter options before they are validated and turned into an actual HTTP request. This hook is used by the `base` middleware, which prefixes the passed URL if it is not an absolute URI already.
Arguments:
1. `options` - Object of request options passed to the request. Should be cloned if modifications are to be performed, to prevent unexpected side-effects.
Should return: Plain object of options to pass on to the rest of the middlewares.
### parseResponse
Called once a response has been received and the response body is ready.
@todo document
## Prior work
This module was inspired by the great work of others:
* [got](https://github.com/sindresorhus/got)
* [simple-get](https://github.com/feross/simple-get)
* [xhr](https://github.com/naugtur/xhr)
* [Axios](https://github.com/mzabriskie/axios/)
* [http-client](https://github.com/mjackson/http-client)
* [request](https://github.com/request/request)
## License
MIT-licensed. See LICENSE.
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