Skip to content

Commit

Permalink
Do not break backwards compatibility for followMany method
Browse files Browse the repository at this point in the history
  • Loading branch information
matthisk committed Jan 13, 2016
1 parent 2ec714d commit 65f09b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/lib/batch_operations.js
Expand Up @@ -24,7 +24,7 @@ module.exports = {
}, callback);
},

followMany: function(follows, activityCopyLimit, callback) {
followMany: function(follows, callbackOrActivityCopyLimit, callback) {
/**
* Follow multiple feeds with one API call
* @method followMany
Expand All @@ -35,10 +35,14 @@ module.exports = {
* @param {requestCallback} [callback] Callback called on completion
* @return {Promise} Promise object
*/
var qs = {};
var activityCopyLimit, qs = {};

if (activityCopyLimit && typeof activityCopyLimit !== 'number') {
throw new TypeError('Activity copy limit should be a number');
if (callbackOrActivityCopyLimit && typeof callbackOrActivityCopyLimit === 'number') {
activityCopyLimit = callbackOrActivityCopyLimit;
}

if (callbackOrActivityCopyLimit && typeof callbackOrActivityCopyLimit === 'function') {
callback = callbackOrActivityCopyLimit;
}

if (activityCopyLimit) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/index.js
Expand Up @@ -174,7 +174,7 @@ describe('Stream Client', function() {
.reply(201, {"duration":"13ms"}, { });

it('#followMany', function(done) {
client.followMany(follows, null, function(error, response, body) {
client.followMany(follows, function(error, response, body) {
expect(error).to.be(null);
done();
});
Expand Down

0 comments on commit 65f09b4

Please sign in to comment.