You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ new Parser(options);
30
30
*`returnError`: *function*; mandatory
31
31
*`returnFatalError`: *function*; optional, defaults to the returnError function
32
32
*`returnBuffers`: *boolean*; optional, defaults to false
33
-
*`name`: *javascript|hiredis*; optional, defaults to hiredis and falls back to the js parser if not available or if the stringNumbers option is choosen
33
+
*`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.
34
34
*`stringNumbers`: *boolean*; optional, defaults to false. This is only available for the javascript parser at the moment!
35
35
36
36
### Example
@@ -55,8 +55,9 @@ var parser = new Parser({
55
55
},
56
56
returnFatalError:function (err) {
57
57
lib.returnFatalError(err);
58
-
}
59
-
}); // This returns either a hiredis or the js parser instance depending on what's available
58
+
},
59
+
name:'auto'// This returns either the hiredis or the js parser instance depending on what's available
Copy file name to clipboardExpand all lines: lib/parser.js
+3-4Lines changed: 3 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -20,20 +20,19 @@ function Parser (options) {
20
20
thrownewError('Please provide all return functions while initiating the parser');
21
21
}
22
22
23
-
/* istanbul ignore if: hiredis should always be installed while testing */
24
23
if(options.name==='hiredis'){
24
+
/* istanbul ignore if: hiredis should always be installed while testing */
25
25
if(!parsers.hiredis){
26
26
msg='You explicitly required the hiredis parser but hiredis is not installed. The JS parser is going to be returned instead.';
27
27
}elseif(options.stringNumbers){
28
28
msg='You explicitly required the hiredis parser in combination with the stringNumbers option. Only the JS parser can handle that and is choosen instead.';
29
29
}
30
-
}elseif(options.name&&!parsers[options.name]){
31
-
msg='The requested parser "'+options.name+'" is unkown and the JS parser is choosen instead.';
0 commit comments