Skip to content

Commit

Permalink
dependency bump
Browse files Browse the repository at this point in the history
Includes a prettier change, so small formatting changes go with it
  • Loading branch information
nfriedly committed Apr 18, 2017
1 parent 971f4b6 commit b66e421
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 111 deletions.
16 changes: 9 additions & 7 deletions examples/conversation.v1.js
Expand Up @@ -24,13 +24,15 @@ const message = function(text, context) {
},
context: context
};
return new Promise((resolve, reject) => conversation.message(payload, function(err, data) {
if (err) {
reject(err);
} else {
resolve(data);
}
}));
return new Promise((resolve, reject) =>
conversation.message(payload, function(err, data) {
if (err) {
reject(err);
} else {
resolve(data);
}
})
);
};

// This example makes two successive calls to conversation service.
Expand Down
9 changes: 3 additions & 6 deletions examples/retrieve_and_rank_lifecycle.v1.js
Expand Up @@ -73,12 +73,9 @@ function waitForCluster(clusterId, callback) {
console.log('Solr cluster ' + clusterId + ' is ready.');
callback();
} else {
setTimeout(
function() {
waitForCluster(clusterId, callback);
},
5000
);
setTimeout(function() {
waitForCluster(clusterId, callback);
}, 5000);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion language-translation/v2.js
Expand Up @@ -156,7 +156,7 @@ LanguageTranslationV2.prototype.deleteModel = function(params, callback) {
LanguageTranslationV2.prototype.translate = function(params, callback) {
params = params || {};

if (!(params.model_id || params.source && params.target)) {
if (!(params.model_id || (params.source && params.target))) {
callback(new Error('Missing required parameters: model_id or source and target'));
return;
}
Expand Down
2 changes: 1 addition & 1 deletion language-translator/v2.js
Expand Up @@ -173,7 +173,7 @@ LanguageTranslatorV2.prototype.deleteModel = function(params, callback) {
LanguageTranslatorV2.prototype.translate = function(params, callback) {
params = params || {};

if (!(params.model_id || params.source && params.target)) {
if (!(params.model_id || (params.source && params.target))) {
callback(new Error('Missing required parameters: model_id or source and target'));
return;
}
Expand Down
11 changes: 4 additions & 7 deletions lib/requestwrapper.js
Expand Up @@ -121,7 +121,7 @@ function createRequest(parameters, _callback) {
const qs = options.qs; // Query parameters

// Provide a default callback if it doesn't exists
const callback = typeof _callback === 'function' ? _callback /* no op */ : (function() {});
const callback = typeof _callback === 'function' ? _callback /* no op */ : function() {};

// Missing parameters
if (parameters.options.requiredParams) {
Expand All @@ -136,12 +136,9 @@ function createRequest(parameters, _callback) {
return callback(missingParams);
} else {
const errorStream = readableStream();
setTimeout(
function() {
errorStream.emit('error', missingParams);
},
0
);
setTimeout(function() {
errorStream.emit('error', missingParams);
}, 0);
return errorStream;
}
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -62,7 +62,7 @@
"devDependencies": {
"browserify": "^14.0.0",
"concat-stream": "^1.5.1",
"dependency-lint": "^4.2.0",
"dependency-lint": "^5.0.1",
"eslint": "^3.14.1",
"eslint-config-google": "^0.7.1",
"eslint-config-prettier": "git+https://github.com/nfriedly/eslint-config-prettier.git#nfriedly-patch-1",
Expand All @@ -78,7 +78,7 @@
"mocha": "^3.2.0",
"nock": "^9.0.2",
"object.assign": "^4.0.4",
"prettier": "^0.18.0",
"prettier": "^1.1.0",
"shebang-loader": "0.0.1",
"uglify-js": "^2.7.0",
"watchify": "^3.7.0",
Expand All @@ -94,7 +94,7 @@
"isstream": "~0.1.2",
"object.omit": "~2.0.0",
"object.pick": "~1.2.0",
"request": "~2.79.0",
"request": "~2.81.0",
"solr-client": "~0.6.0",
"string": "3.3.3",
"vcap_services": "~0.3.0",
Expand Down
4 changes: 2 additions & 2 deletions speech-to-text/recognize_stream.js
Expand Up @@ -101,7 +101,7 @@ RecognizeStream.prototype.initialize = function() {

// node params: requestUrl, protocols, origin, headers, extraRequestOptions
// browser params: requestUrl, protocols (all others ignored)
const socket = this.socket = new W3CWebSocket(url, null, null, options.headers, null);
const socket = (this.socket = new W3CWebSocket(url, null, null, options.headers, null));

// when the input stops, let the service know that we're done
self.on('finish', function() {
Expand Down Expand Up @@ -217,7 +217,7 @@ RecognizeStream.prototype.initialize = function() {
this.initialized = true;
};

RecognizeStream.prototype._read = function() /* size*/ {
RecognizeStream.prototype._read = function(/* size*/) {
// there's no easy way to control reads from the underlying library
// so, the best we can do here is a no-op
};
Expand Down
22 changes: 8 additions & 14 deletions test/unit/test.retrieve_and_rank.v1.js
Expand Up @@ -435,23 +435,17 @@ describe('retrieve_and_rank', function() {
});

it('returns error when cluster_id is not specified when building Solr client', function() {
assert.throws(
function() {
search.createSolrClient({});
},
/required parameters: cluster_id/
);
assert.throws(function() {
search.createSolrClient({});
}, /required parameters: cluster_id/);
});

it('returns error when collection_name is not specified when building Solr client', function() {
assert.throws(
function() {
search.createSolrClient({
cluster_id: clusterId
});
},
/required parameters: collection_name/
);
assert.throws(function() {
search.createSolrClient({
cluster_id: clusterId
});
}, /required parameters: collection_name/);
});

it('generate valid request when creating a ranker', function() {
Expand Down
6 changes: 4 additions & 2 deletions test/unit/test.speech_to_text.v1.js
Expand Up @@ -390,7 +390,8 @@ describe('speech_to_text', function() {
});

it('should create new recognitions job', function() {
const path = '/v1/recognitions?callback_url=http%3A%2F%2Fwatson-test-resources.mybluemix.net%2Fresults&events=recognitions.completed&user_token=myArbitraryIdentifier1&results_ttl=60';
const path =
'/v1/recognitions?callback_url=http%3A%2F%2Fwatson-test-resources.mybluemix.net%2Fresults&events=recognitions.completed&user_token=myArbitraryIdentifier1&results_ttl=60';
const response = {
id: '4bd734c0-e575-21f3-de03-f932aa0468a0',
status: 'waiting',
Expand Down Expand Up @@ -420,7 +421,8 @@ describe('speech_to_text', function() {
});

it('should create new recognitions job w/ multiple events', function() {
const path = '/v1/recognitions?callback_url=http%3A%2F%2Fwatson-test-resources.mybluemix.net%2Fresults&events=recognitions.started%2Crecognitions.failed%2Crecognitions.completed_with_results&user_token=myArbitraryIdentifier1&results_ttl=60';
const path =
'/v1/recognitions?callback_url=http%3A%2F%2Fwatson-test-resources.mybluemix.net%2Fresults&events=recognitions.started%2Crecognitions.failed%2Crecognitions.completed_with_results&user_token=myArbitraryIdentifier1&results_ttl=60';
const response = {
id: '4bd734c0-e575-21f3-de03-f932aa0468a0',
status: 'waiting',
Expand Down
18 changes: 7 additions & 11 deletions test/unit/test.visual_recognition.v3.js
Expand Up @@ -87,7 +87,7 @@ describe('visual_recognition', function() {
const visual_recognition = watson.visual_recognition(service);

const missingParameter = function(err) {
assert(err instanceof Error && /parameter/.test(err), 'Expected error to mention "parameter" but got "' + (err && err.message || err) + '"');
assert(err instanceof Error && /parameter/.test(err), 'Expected error to mention "parameter" but got "' + ((err && err.message) || err) + '"');
};

describe('credentials', function() {
Expand All @@ -107,22 +107,18 @@ describe('visual_recognition', function() {
assert.throws(() => new watson.VisualRecognitionV3({ username: 'foo' }), /key/);
});

it(
'should accept an API key for regular usage',
() => new watson.VisualRecognitionV3({
it('should accept an API key for regular usage', () =>
new watson.VisualRecognitionV3({
api_key: 'foo',
version_date: '2016-05-20'
})
);
}));

it(
'should accept username/password for regular usage',
() => new watson.VisualRecognitionV3({
it('should accept username/password for regular usage', () =>
new watson.VisualRecognitionV3({
username: 'foo',
password: 'bar',
version_date: '2016-05-20'
})
);
}));

it('should accept VISUAL_RECOGNITION_API_KEY env property', () => {
process.env.VISUAL_RECOGNITION_API_KEY = 'foo';
Expand Down
91 changes: 35 additions & 56 deletions test/unit/test.wrapper.js
Expand Up @@ -19,18 +19,12 @@ describe('wrapper', function() {
};

it('should check for missing parameters', function() {
assert.throws(
function() {
create_service(undefined);
},
/version/
);
assert.throws(
function() {
create_service({});
},
/version/
);
assert.throws(function() {
create_service(undefined);
}, /version/);
assert.throws(function() {
create_service({});
}, /version/);
});

it('should check for use_unauthenticated', function() {
Expand All @@ -40,56 +34,41 @@ describe('wrapper', function() {
version: 'v1'
})
);
assert.throws(
function() {
create_service({
use_unauthenticated: false,
version: 'v1'
});
},
/use_unauthenticated/
);
assert.throws(function() {
create_service({
use_unauthenticated: false,
version: 'v1'
});
}, /use_unauthenticated/);
});

it('should check for missing version', function() {
assert.throws(
function() {
create_service({
username: 'user',
password: 'pass'
});
},
/version/
);
assert.throws(
function() {
create_service({
api_key: 'keykeykey'
});
},
/version/
);
assert.throws(function() {
create_service({
username: 'user',
password: 'pass'
});
}, /version/);
assert.throws(function() {
create_service({
api_key: 'keykeykey'
});
}, /version/);
});

it('should check for missing authentication', function() {
assert.throws(
function() {
create_service({
version: 'v1',
username: 'user'
});
},
/password/
);
assert.throws(
function() {
create_service({
version: 'v1',
password: 'pass'
});
},
/username/
);
assert.throws(function() {
create_service({
version: 'v1',
username: 'user'
});
}, /password/);
assert.throws(function() {
create_service({
version: 'v1',
password: 'pass'
});
}, /username/);

assert.ok(
create_service({
Expand Down
2 changes: 1 addition & 1 deletion visual-recognition/v3.js
Expand Up @@ -97,7 +97,7 @@ function fixupImageParam(params) {
* @return {Function}
*/
function errorFormatter(cb) {
const callback = typeof cb === 'function' ? cb /* no op */ : (function() {});
const callback = typeof cb === 'function' ? cb /* no op */ : function() {};
return function(err, result) {
if (err) {
callback(err, result);
Expand Down

0 comments on commit b66e421

Please sign in to comment.