Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "bser", | ||
"version": "1.0.1", | ||
"description": "JavaScript implementation of the BSER Binary Protocol", | ||
"version": "1.0.2", | ||
"description": "JavaScript implementation of the BSER Binary Serialization", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "directories": { |
@@ -1,5 +0,14 @@ | ||
# BSER Binary Protocol | ||
# BSER Binary Serialization | ||
For more details about the protocol see [Watchman's docs](https://facebook.github.io/watchman/docs/bser.html). | ||
BSER is a binary serialization scheme that can be used as an alternative to JSON. | ||
BSER uses a framed encoding that makes it simpler to use to stream a sequence of | ||
encoded values. | ||
It is intended to be used for local-IPC only and strings are represented as binary | ||
with no specific encoding; this matches the convention employed by most operating | ||
system filename storage. | ||
For more details about the serialization scheme see | ||
[Watchman's docs](https://facebook.github.io/watchman/docs/bser.html). | ||
## API | ||
@@ -11,19 +20,30 @@ | ||
### Buffer | ||
### bser.loadFromBuffer | ||
#### Create | ||
The is the synchronous decoder; given an input string or buffer, | ||
decodes a single value and returns it. Throws an error if the | ||
input is invalid. | ||
```js | ||
var bunser = new bser.BunserBuf(); | ||
var obj = bser.loadFromBuffer(buf); | ||
``` | ||
#### Append | ||
### bser.dumpToBuffer | ||
Synchronously encodes a value as BSER. | ||
```js | ||
bunser.append(buf); | ||
var encoded = bser.dumpToBuffer(['hello']); | ||
console.log(bser.loadFromBuffer(encoded)); // ['hello'] | ||
``` | ||
#### Read | ||
### BunserBuf | ||
The asynchronous decoder API is implemented in the BunserBuf object. | ||
You may incrementally append data to this object and it will emit the | ||
decoded values via its `value` event. | ||
```js | ||
var bunser = new bser.BunserBuf(); | ||
bunser.on('value', function(obj) { | ||
@@ -34,6 +54,6 @@ console.log(obj); | ||
#### Dump | ||
Then in your socket `data` event: | ||
```js | ||
bser.dumpToBuffer(obj); | ||
bunser.append(buf); | ||
``` | ||
@@ -49,3 +69,3 @@ | ||
bunser.on('value', function(obj) { | ||
console.log('data from socket', obj); | ||
console.log('data from socket', obj); | ||
}); | ||
@@ -52,0 +72,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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
82
19645
4
1