https://github.com/rootslab/boris
Boris, a pure javascript parser for the Redis serialization protocol.
https://github.com/rootslab/boris
javascript-parser nodejs redis redis-serialization-protocol
Last synced: 2 months ago
JSON representation
Boris, a pure javascript parser for the Redis serialization protocol.
- Host: GitHub
- URL: https://github.com/rootslab/boris
- Owner: rootslab
- License: mit
- Created: 2014-04-27T13:05:57.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2018-02-10T14:40:24.000Z (over 7 years ago)
- Last Synced: 2025-02-27T03:25:46.152Z (3 months ago)
- Topics: javascript-parser, nodejs, redis, redis-serialization-protocol
- Language: JavaScript
- Homepage:
- Size: 57.6 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
### Boris
[](https://www.npmjs.org/package/boris)
[](https://www.codacy.com/public/44gatti/boris)
[](https://codeclimate.com/github/rootslab/boris)
[](https://github.com/rootslab/boris#mit-license)
[](http://travis-ci.org/rootslab/boris)
[](https://david-dm.org/rootslab/boris)
[](https://david-dm.org/rootslab/boris#info=devDependencies)[](http://npm-stat.com/charts.html?package=boris)
[](https://nodei.co/npm/boris/)
> _**Boris**_, a pure javascript parser for the Redis serialization protocol __[RESP](http://redis.io/topics/protocol)__.
> __Boris__ is able to parse all kinds of __Redis__ replies, also __deeply nested multi-bulk__ replies.
### Install
```bash
$ npm install boris [-g]
// clone repo
$ git clone [email protected]:rootslab/boris.git
```
> __require__```javascript
var Boris = require( 'boris' );
```
> See [examples](example/).### Run Tests
```bash
$ cd boris/
$ npm test
```
### Constructor> Create an instance.
```javascript
var b = Boris()
// or
var b = new Boris()
```
#### Options> Default options are listed.
```javascript
opt = {
/*
* For default, the parser returns Buffers,
*/
return_buffers : true
}
```### Properties
> __WARNING__: Don't mess with these properties.
```javascript
/*
* Protocol rules: bulk, multibulk, status, integer, error.
*/
Boris.rules : Object/*
* Current rule in execution.
*/
Boris.crule : Rule/*
* Current parser data.
*/
Boris.cdata : Buffer/*
* Boolean to signal that data is fragmented,
* then another chunk is expected.
*/
Boris.mchk : Boolean/*
* Current parser position in the data.
*/
Boris.cpos : Number/*
* Current parser stack for multibulk replies.
*/
Boris.peela : Peela
```### Methods
> Arguments within [ ] are optional.
```javascript
/*
* parse a chunk of data.
*/
Boris#parse( Buffer data ) : undefined/*
* reset parser state.
*/
Boris#reset() : undefined```
### Events
```javascript
/*
* The current executing rule has found a result.
* The convert function argument is an utility that
* scans an array and turns all Buffers into Strings.
*
* NOTE: the boolean 'isError' signals a Redis error reply,
* not a runtime Error.
*/
Boris.on( 'match', function ( Boolean isError, Array result, Function convert ) { .. } )/*
* A parse error occurred, the parser wasn't able to recognize
* the current control char.
*
* NOTE: on error, parser state ( stack, rules ) will be reset.
*/
Boris.on( 'error', function ( String emsg, Buffer data ) { .. } )/*
* NOTE: events below are disabled for perfomance reasons.
* If you need them, decomment statements in the code.
*//*
* the current executing rule needs further data to continue.
*/
Boris.on( 'miss', function ( Rule rule, Number position ) { .. } )/*
* Data was totally parsed.
*/
Boris.on( 'end', function () { .. } )```
------------------------------------------------------------------------
### MIT License
> Copyright (c) 2013 < Guglielmo Ferri : [email protected] >
> Permission is hereby granted, free of charge, to any person obtaining
> a copy of this software and associated documentation files (the
> 'Software'), to deal in the Software without restriction, including
> without limitation the rights to use, copy, modify, merge, publish,
> distribute, sublicense, and/or sell copies of the Software, and to
> permit persons to whom the Software is furnished to do so, subject to
> the following conditions:> __The above copyright notice and this permission notice shall be
> included in all copies or substantial portions of the Software.__> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
> IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
> CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
> TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
> SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.