Permalink
Browse files

idGenerator option name is now simply generator

  • Loading branch information...
1 parent bdebf0f commit 235deab4968b17d5dd41b5098edc6389fab1af16 @tedeh committed Sep 21, 2012
Showing with 5 additions and 5 deletions.
  1. +1 −1 README.md
  2. +2 −2 lib/client.js
  3. +2 −2 test/client.test.js
View
@@ -207,7 +207,7 @@ Every client supports these options:
* `reviver` -> Function to use as a JSON reviver
* `replacer` -> Function to use as a JSON replacer
-* `idGenerator` -> Function to generate request ids with. If omitted, Jayson will just generate a "random" number like this: `Math.round(Math.random() * Math.pow(2, 24))`
+* `generator` -> Function to generate request ids with. If omitted, Jayson will just generate a "random" number like this: `Math.round(Math.random() * Math.pow(2, 24))`
##### Client.http
View
@@ -21,7 +21,7 @@ var Client = function(server, options) {
var defaults = {
reviver: null,
replacer: null,
- idGenerator: utils.generateId
+ generator: utils.generateId
};
this.options = utils.merge(defaults, options || {});
@@ -75,7 +75,7 @@ Client.prototype.request = function(method, params, id, callback) {
try {
var request = utils.request(method, params, id, {
- generator: this.options.idGenerator
+ generator: this.options.generator
});
} catch(err) {
if(hasCallback) return callback(err);
View
@@ -54,14 +54,14 @@ describe('jayson client instance', function() {
it('should support specifying a request id generator', function(done) {
var ordinal = 0, a = 9, b = 2;
- client.options.idGenerator = function(request) { return ordinal++; };
+ client.options.generator = function(request) { return ordinal++; };
client.request('add', [a, b], function(err, response) {
should.not.exist(err);
should.exist(response);
response.should.have.property('result', a + b);
response.should.have.property('id', 0);
ordinal.should.equal(1);
- delete client.options.idGenerator;
+ delete client.options.generator;
done();
});
});

0 comments on commit 235deab

Please sign in to comment.