disconnect
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -0,1 +1,6 @@ | ||
0.3.0 / 2014-06-24 | ||
================== | ||
* Added automatic request throttle of 1 request per second queueing up to 10 requests | ||
* Exposed the request queueing functions in `util.queue` | ||
0.2.1 / 2014-06-20 | ||
@@ -8,3 +13,3 @@ ================== | ||
================== | ||
* Implemented/fixed broken `image` function from `0.1.1` | ||
* Implemented/fixed broken `database.image` function from `0.1.1` | ||
* Added rate limiting header info to the callback params | ||
@@ -11,0 +16,0 @@ |
@@ -7,3 +7,4 @@ var http = require('http'), | ||
package = require('../package.json'), | ||
error = require('./error.js'); | ||
error = require('./error.js'), | ||
queue = require('./queue.js'); | ||
@@ -160,3 +161,3 @@ module.exports = DiscogsClient; | ||
oauth = options.oauth||this.oauth, | ||
encoding = options.encoding||null; | ||
encoding = options.encoding||'utf8'; | ||
@@ -215,5 +216,2 @@ // Build request headers | ||
// Set encoding when provided | ||
encoding&&res.setEncoding(encoding); | ||
// Find and add rate limiting when present | ||
@@ -228,2 +226,3 @@ if(res.headers['x-ratelimit-type']){ | ||
} | ||
// Get the response content and pass it to the callback | ||
@@ -240,2 +239,4 @@ switch(res.headers['content-encoding']){ | ||
default: | ||
// Set encoding when provided | ||
res.setEncoding(encoding); | ||
res.on('data', add).on('end', passData); | ||
@@ -263,8 +264,15 @@ } | ||
DiscogsClient.prototype._request = function(options, callback){ | ||
var self = this; | ||
(typeof options === 'string')&&(options = {url: options}); | ||
return this._rawRequest(options, function(err, data, rateLimit){ | ||
if((typeof options === 'string') || (options.encoding !== 'binary')){ | ||
data = JSON.parse(data) | ||
queue.add(function(err){ // Add API request to the execution queue | ||
if(!err){ | ||
self._rawRequest(options, function(err, data, rateLimit){ | ||
if((typeof options === 'string') || (options.encoding !== 'binary')){ | ||
data = JSON.parse(data) | ||
} | ||
(typeof callback === 'function')&&callback(err, data, rateLimit); | ||
}); | ||
}else{ | ||
callback(err); | ||
} | ||
(typeof callback === 'function')&&callback(err, data, rateLimit); | ||
}); | ||
@@ -271,0 +279,0 @@ }; |
@@ -6,4 +6,10 @@ var queryString = require('querystring'); | ||
/** | ||
* Expose the request queueing functions | ||
*/ | ||
util.queue = require('./queue.js'); | ||
/** | ||
* Strip the trailing number from a Discogs artist name Artist (2) -> Artist | ||
* @param {String} name | ||
* @param {String} name - The Discogs artist name | ||
* @return {String} | ||
@@ -18,4 +24,4 @@ */ | ||
* Add params to a given url or path | ||
* @param {String} url | ||
* @param {Object} data | ||
* @param {String} url - The url to add the extra params to | ||
* @param {Object} data - Data object containing the params | ||
* @returns {String} | ||
@@ -33,3 +39,3 @@ */ | ||
* Escape a string for use in a query string | ||
* @param {String} str | ||
* @param {String} str - The string to escape | ||
* @returns {String} | ||
@@ -36,0 +42,0 @@ */ |
{ | ||
"name": "disconnect", | ||
"description": "Easy to use client to connect with the discogs.com API v2.0", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"keywords": ["discogs", "api", "client", "oauth"], | ||
@@ -6,0 +6,0 @@ "homepage": "https://github.com/bartve/disconnect", |
@@ -5,3 +5,3 @@ ## About | ||
[![NPM version](https://badge.fury.io/js/disconnect.svg)](http://badge.fury.io/js/disconnect) [![Dependency Status](https://david-dm.org/bartve/disconnect.png)](https://david-dm.org/bartve/disconnect) | ||
[![Dependency Status](https://david-dm.org/bartve/disconnect.png)](https://david-dm.org/bartve/disconnect) | ||
@@ -22,3 +22,3 @@ ## Features | ||
`$ npm install disconnect` | ||
[![NPM](https://nodei.co/npm/disconnect.png?downloads=true)](https://nodei.co/npm/disconnect/) | ||
@@ -25,0 +25,0 @@ ## Structure |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38240
15
926