redis-parser
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -0,1 +1,8 @@ | ||
## v.1.3.0 - 27 Mar, 2016 | ||
Features | ||
- Added `auto` as parser name option to check what parser is available | ||
- Non existing requested parsers falls back into auto mode instead of always choosing the JS parser | ||
## v.1.2.0 - 27 Mar, 2016 | ||
@@ -2,0 +9,0 @@ |
@@ -23,4 +23,4 @@ 'use strict'; | ||
/* istanbul ignore if: hiredis should always be installed while testing */ | ||
if (options.name === 'hiredis') { | ||
/* istanbul ignore if: hiredis should always be installed while testing */ | ||
if (!parsers.hiredis) { | ||
@@ -31,4 +31,4 @@ msg = 'You explicitly required the hiredis parser but hiredis is not installed. The JS parser is going to be returned instead.'; | ||
} | ||
} else if (options.name && !parsers[options.name]) { | ||
msg = 'The requested parser "' + options.name + '" is unkown and the JS parser is choosen instead.'; | ||
} else if (options.name && !parsers[options.name] && options.name !== 'auto') { | ||
msg = 'The requested parser "' + options.name + '" is unkown and the default parser is choosen instead.'; | ||
} | ||
@@ -38,3 +38,2 @@ | ||
console.warn(new Error(msg).stack.replace('Error: ', 'Warning: ')); | ||
options.name = 'javascript'; | ||
} | ||
@@ -41,0 +40,0 @@ |
{ | ||
"name": "redis-parser", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Javascript Redis protocol (RESP) parser", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -33,3 +33,3 @@ [![Build Status](https://travis-ci.org/NodeRedis/node-redis-parser.png?branch=master)](https://travis-ci.org/NodeRedis/node-redis-parser) | ||
* `returnBuffers`: *boolean*; optional, defaults to false | ||
* `name`: *javascript|hiredis*; optional, defaults to hiredis and falls back to the js parser if not available or if the stringNumbers option is choosen | ||
* `name`: *'javascript'|'hiredis'|'auto'|null*; optional, defaults to hiredis and falls back to the js parser if not available or if the stringNumbers option is choosen. Setting this to 'auto' or null is going to automatically determine what parser is available and chooses that one. | ||
* `stringNumbers`: *boolean*; optional, defaults to false. This is only available for the javascript parser at the moment! | ||
@@ -59,4 +59,5 @@ | ||
lib.returnFatalError(err); | ||
} | ||
}); // This returns either a hiredis or the js parser instance depending on what's available | ||
}, | ||
name: 'auto' // This returns either the hiredis or the js parser instance depending on what's available | ||
}); | ||
@@ -63,0 +64,0 @@ Library.prototype.streamHandler = function () { |
@@ -26,2 +26,20 @@ 'use strict'; | ||
it('auto parser', function () { | ||
var parser = new Parser({ | ||
returnReply: returnReply, | ||
returnError: returnError, | ||
name: 'auto' | ||
}); | ||
assert.strictEqual(parser.name, 'hiredis'); | ||
}); | ||
it('auto parser v2', function () { | ||
var parser = new Parser({ | ||
returnReply: returnReply, | ||
returnError: returnError, | ||
name: null | ||
}); | ||
assert.strictEqual(parser.name, 'hiredis'); | ||
}); | ||
it('fail for missing options', function () { | ||
@@ -46,3 +64,3 @@ assert.throws(function() { | ||
}); | ||
new Parser({ | ||
var parser = new Parser({ | ||
returnReply: returnReply, | ||
@@ -53,3 +71,4 @@ returnError: returnError, | ||
unhookIntercept(); | ||
assert(/^Warning: The requested parser "something_unknown" is unkown and the JS parser is choosen instead\.\n +at new Parser/.test(str), str); | ||
assert.strictEqual(parser.name, 'hiredis'); | ||
assert(/^Warning: The requested parser "something_unknown" is unkown and the default parser is choosen instead\.\n +at new Parser/.test(str), str); | ||
}); | ||
@@ -63,3 +82,3 @@ | ||
}); | ||
new Parser({ | ||
var parser = new Parser({ | ||
returnReply: returnReply, | ||
@@ -71,2 +90,3 @@ returnError: returnError, | ||
unhookIntercept(); | ||
assert.strictEqual(parser.name, 'javascript'); | ||
assert(/^Warning: You explicitly required the hiredis parser in combination with the stringNumbers option. .+.\.\n +at new Parser/.test(str), str); | ||
@@ -73,0 +93,0 @@ }); |
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
38488
674
128