summaryrefslogtreecommitdiff
path: root/lib/crypto.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2013-07-24 18:03:53 +0200
committerBen Noordhuis <info@bnoordhuis.nl>2013-07-24 21:49:35 +0200
commit0330bdf5195eb77f04c26a09a8bd2088a261fe53 (patch)
tree2c13f9f1757bca93e83e425a028dcae78549f40e /lib/crypto.js
parent457d52924152c6f2baf2fddbe76a03bca7bdde7c (diff)
downloadandroid-node-v8-0330bdf5195eb77f04c26a09a8bd2088a261fe53.tar.gz
android-node-v8-0330bdf5195eb77f04c26a09a8bd2088a261fe53.tar.bz2
android-node-v8-0330bdf5195eb77f04c26a09a8bd2088a261fe53.zip
lib: macro-ify type checks
Increases the grep factor. Makes it easier to harmonize type checks across the code base.
Diffstat (limited to 'lib/crypto.js')
-rw-r--r--lib/crypto.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/crypto.js b/lib/crypto.js
index 90e139af32..c450f1c15f 100644
--- a/lib/crypto.js
+++ b/lib/crypto.js
@@ -43,7 +43,7 @@ var util = require('util');
// to break them unnecessarily.
function toBuf(str, encoding) {
encoding = encoding || 'binary';
- if (typeof str === 'string') {
+ if (IS_STRING(str)) {
if (encoding === 'buffer')
encoding = 'binary';
str = new Buffer(str, encoding);
@@ -100,7 +100,7 @@ exports.createCredentials = function(options, context) {
if (options.ciphers) c.context.setCiphers(options.ciphers);
if (options.ca) {
- if (Array.isArray(options.ca)) {
+ if (IS_ARRAY(options.ca)) {
for (var i = 0, len = options.ca.length; i < len; i++) {
c.context.addCACert(options.ca[i]);
}
@@ -112,7 +112,7 @@ exports.createCredentials = function(options, context) {
}
if (options.crl) {
- if (Array.isArray(options.crl)) {
+ if (IS_ARRAY(options.crl)) {
for (var i = 0, len = options.crl.length; i < len; i++) {
c.context.addCRL(options.crl[i]);
}
@@ -198,7 +198,7 @@ Hash.prototype._flush = function(callback) {
Hash.prototype.update = function(data, encoding) {
encoding = encoding || exports.DEFAULT_ENCODING;
- if (encoding === 'buffer' && typeof data === 'string')
+ if (encoding === 'buffer' && IS_STRING(data))
encoding = 'binary';
this._binding.update(data, encoding);
return this;
@@ -539,7 +539,7 @@ DiffieHellman.prototype.setPrivateKey = function(key, encoding) {
exports.pbkdf2 = function(password, salt, iterations, keylen, callback) {
- if (typeof callback !== 'function')
+ if (!IS_FUNCTION(callback))
throw new Error('No callback provided to pbkdf2');
return pbkdf2(password, salt, iterations, keylen, callback);