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

request-options

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

request-options - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

.idea/jsLibraryMappings.xml

21

index.js

@@ -7,21 +7,16 @@ 'use strict';

* @param {Object} [options]
* @param {Object} [defaults]
* @returns {*|{}}
*/
module.exports = (options = {}, {
json = true,
gzip = true,
timeout = 10000
} = {}) => {
module.exports = (options = {}) => {
if(!options || typeof options !== 'object')
throw new Error('Additional options must be provided as JSON');
Object.assign(
options,
return Object.assign(
{},
{
json: json,
gzip: gzip,
timeout: timeout
}
json: true,
gzip: true,
timeout: 10000
},
options
);
return options;
};
{
"name": "request-options",
"version": "1.0.0",
"version": "2.0.0",
"description": "Default options object generator for the popular NodeJS package Request",

@@ -5,0 +5,0 @@ "keywords": [

@@ -6,3 +6,3 @@ # request-options

Default options object generator written in ES6 for the popular NodeJS package Request, providing a generic set of request options
for the [request](https://www.npmjs.com/package/request) package that can be augmented by providing [`options`](#options) or [`defaults`](#defaults) to overwrite.
for the [request](https://www.npmjs.com/package/request) package that can be augmented or overwritten by providing [`options`](#options).

@@ -16,6 +16,5 @@ ## Install

## Usage
### requestOptions( [options][, defaults] )
### requestOptions( [options] )
```js
@param {Object} [options]
@param {Object} [defaults]
@returns {Object}

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

The defaults can be overwritten by providing your own `defaults` parameter object with the new values. Any additional values will be ignored, use the `options` object for your extended options.
The defaults can be overwritten by providing your own properties in `options` with the new values. Any additional values will be ignored, use the `options` object for your extended options.

@@ -89,4 +88,2 @@ ### Examples

url: 'https://api.yoursite.com/endpoint'
};
const defaults = {
gzip: false,

@@ -100,3 +97,3 @@ timeout: 20000

request(requestOptions(options, defaults), responseHandler);
request(requestOptions(options), responseHandler);

@@ -112,3 +109,3 @@ // requestOptions => {

Notice how the default json value is still present and left unchanged
Notice how the default property `json` is still present and the value left unchanged

@@ -115,0 +112,0 @@ ## Tests

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