@@ -29,7 +29,6 @@ new Parser(options);
2929*  ` returnFatalError ` : * function* ; optional, defaults to the returnError function
3030*  ` returnBuffers ` : * boolean* ; optional, defaults to false
3131*  ` name ` : * javascript|hiredis* ; optional, defaults to hiredis and falls back to the js parser if not available
32- *  ` context ` : * A class instance that the return functions get bound to* ; optional
3332
3433### Example  
3534
@@ -45,10 +44,15 @@ Library.prototype.returnFatalError = function (err) { ... }
4544var  lib =  new  Library ();
4645
4746var  parser =  new  Parser ({
48-     returnReply:  returnReply,
49-     returnError:  returnError,
50-     returnFatalError:  returnFatalError,
51-     context:  lib
47+     returnReply :  function (reply ) {
48+         lib .returnReply (reply);
49+     },
50+     returnError :  function (err ) {
51+         lib .returnError (err);
52+     },
53+     returnFatalError :  function  (err ) {
54+         lib .returnFatalError (err);
55+     }
5256}); //  This returns either a hiredis or the js parser instance depending on what's available
5357
5458Library .prototype .streamHandler  =  function  () {
@@ -58,17 +62,20 @@ Library.prototype.streamHandler = function () {
5862    });
5963};
6064``` 
61- You do not have to use the context variable, but can also bind the function while passing them to the option object .
65+ You do not have to use the returnFatalError function. Fatal errors will be returned in the normal error function in that case .
6266
6367And if you want to return buffers instead of strings, you can do this by adding the returnBuffers option.
6468
6569``` js 
6670//  Same functions as in the first example
6771
6872var  parser =  new  Parser ({
69-     returnReply:  returnReply .bind (lib),
70-     returnError:  returnError .bind (lib),
71-     returnFatalError:  returnFatalError .bind (lib),
73+     returnReply :  function (reply ) {
74+         lib .returnReply (reply);
75+     },
76+     returnError :  function (err ) {
77+         lib .returnError (err);
78+     },
7279    returnBuffers:  true  //  All strings are returned as buffer e.g. <Buffer 48 65 6c 6c 6f>
7380});
7481
0 commit comments