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

cuddle

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cuddle - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

23

lib/request.js

@@ -41,3 +41,3 @@ 'use strict';

get: function get() {
return isFinite(Request._max_retry) ? Request._max_retry : 3;
return isFinite(Request._max_retry) ? Request._max_retry : 0;
},

@@ -52,2 +52,5 @@ set: function set(max_retry) {

this._max_retry = Request.MAX_RETRY;
this._retryables = Request.RETRYABLES;
this.method = method;

@@ -59,3 +62,2 @@ this.data = '';

this.retries = 0;
this._max_retry = Request.MAX_RETRY;
this.secure = false;

@@ -66,2 +68,4 @@ this.follow = false;

this.logger = console;
this.end = this.then;
}

@@ -123,2 +127,8 @@

}, {
key: 'set_retryables',
value: function set_retryables(retryables) {
this._retryables = retryables;
return this;
}
}, {
key: 'add_header',

@@ -145,4 +155,11 @@ value: function add_header(key, value) {

value: function then(cb) {
// if cb is not a function, make it a no-op
if (typeof cb !== 'function') {
cb = function cb() {};
}
this.cb = cb;
this.start();
return this;

@@ -369,3 +386,3 @@ }

if (~Request.RETRYABLES.indexOf(err.code) && this.retries < this._max_retry) {
if (~this._retryables.indexOf(err.code) && this.retries < this._max_retry) {
return this.retry();

@@ -372,0 +389,0 @@ }

2

package.json
{
"name": "cuddle",
"version": "1.0.2",
"version": "1.0.3",
"description": "Cuddle is a minimal, chainable and readability first http client",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -11,5 +11,5 @@ #Cuddle

###Use Cases
##Use Cases
Simple
###Simple
```js

@@ -34,3 +34,3 @@ const cudl = require('cuddle');

Promise:
###Promise:
```js

@@ -41,3 +41,3 @@ const cudl = require('cuddle');

.to('http://localhost:8082/api/user/1')
.add_header('Authorization', 'Token sampletoken')
.set_header('Authorization', 'Token sampletoken')
.send({

@@ -53,3 +53,3 @@ username: 'rvnjl',

Using with generators:
###Using with generators:
```js

@@ -62,3 +62,3 @@ const cudl = require('cuddle');

.to('http://localhost:8082/api/user/1')
.add_header('Authorization', 'Token sampletoken')
.set_header('Authorization', 'Token sampletoken')
.promise();

@@ -72,3 +72,3 @@

Easy scoping through args:
###Easy scoping through args:
```js

@@ -75,0 +75,0 @@ const cudl = require('cuddle');

@@ -29,3 +29,3 @@ 'use strict';

? Request._max_retry
: 3;
: 0;
}

@@ -38,2 +38,5 @@

constructor (method) {
this._max_retry = Request.MAX_RETRY;
this._retryables = Request.RETRYABLES;
this.method = method;

@@ -45,3 +48,2 @@ this.data = '';

this.retries = 0;
this._max_retry = Request.MAX_RETRY;
this.secure = false;

@@ -52,2 +54,4 @@ this.follow = false;

this.logger = console;
this.end = this.then;
}

@@ -126,2 +130,8 @@

set_retryables (retryables) {
this._retryables = retryables;
return this;
}
add_header (key, value) {

@@ -146,4 +156,11 @@ console.error(`Cuddle's add_header will be deprecated. Use set_header instead.`);

then (cb) {
// if cb is not a function, make it a no-op
if (typeof cb !== 'function') {
cb = () => {};
}
this.cb = cb;
this.start();
return this;

@@ -373,3 +390,3 @@ }

if (~Request.RETRYABLES.indexOf(err.code) && this.retries < this._max_retry) {
if (~this._retryables.indexOf(err.code) && this.retries < this._max_retry) {
return this.retry();

@@ -379,3 +396,4 @@ }

this.cb(err, null, this, this.additional_arguments);
}
}

@@ -27,7 +27,7 @@ 'use strict';

it ('should set MAX_RETRY to 0', done => {
it ('should set MAX_RETRY to 3', done => {
cudl.Request.MAX_RETRY.should.equal(0);
cudl.Request.MAX_RETRY = 3;
cudl.Request.MAX_RETRY.should.equal(3);
cudl.Request.MAX_RETRY = 0;
cudl.Request.MAX_RETRY.should.equal(0);

@@ -34,0 +34,0 @@ done();

@@ -46,3 +46,3 @@ 'use strict';

.send(payload)
.then((err, result, request) => {
.end((err, result, request) => {

@@ -49,0 +49,0 @@ result.query.should.be.eql(payload);

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