Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bser

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bser - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

4

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc