🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

it-length-prefixed

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

it-length-prefixed - npm Package Compare versions

Comparing version

to
1.1.0

10

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="1.1.0"></a>
# [1.1.0](https://github.com/alanshaw/it-length-prefixed/compare/v1.0.0...v1.1.0) (2019-08-13)
### Features
* encode single and optional decode onLength/onData callbacks ([#1](https://github.com/alanshaw/it-length-prefixed/issues/1)) ([ce68bc8](https://github.com/alanshaw/it-length-prefixed/commit/ce68bc8))
<a name="1.0.0"></a>

@@ -2,0 +12,0 @@ # 1.0.0 (2019-05-07)

4

package.json
{
"name": "it-length-prefixed",
"version": "1.0.0",
"version": "1.1.0",
"description": "Streaming length prefixed buffers with async iterables",

@@ -38,2 +38,3 @@ "main": "src/index.js",

"bl": "^3.0.0",
"buffer": "^5.3.0",
"varint": "^5.0.0"

@@ -47,2 +48,3 @@ },

"it-pushable": "^1.2.1",
"p-defer": "^3.0.0",
"random-bytes": "^1.0.0",

@@ -49,0 +51,0 @@ "random-int": "^2.0.0",

@@ -69,2 +69,8 @@ # it-length-prefixed

### `encode.single(chunk)`
- `chunk: Buffer|BufferList` chunk to encode
Returns a `BufferList` containing the encoded chunk.
### `decode([opts])`

@@ -74,2 +80,4 @@

- `maxDataLength`: If provided, will not decode messages longer than the size specified, if omitted will use the current default of 4MB.
- `onLength(len: Number)`: Called for every length prefix that is decoded from the stream
- `onData(data: BufferList)`: Called for every chunk of data that is decoded from the stream

@@ -76,0 +84,0 @@ All messages will be prefixed with a varint.

@@ -49,3 +49,6 @@ 'use strict'

if (options.onLength) options.onLength(dataLength)
if (dataLength <= 0) {
if (options.onData) options.onData(Empty)
return { mode: ReadModes.LENGTH, chunk, buffer, data: Empty }

@@ -71,2 +74,3 @@ }

if (options.onData) options.onData(data)
return { mode: ReadModes.LENGTH, chunk, buffer, data }

@@ -73,0 +77,0 @@ }

'use strict'
const Varint = require('varint')
const { Buffer } = require('buffer')
const BufferList = require('bl')

@@ -33,4 +34,6 @@

encode.single = c => new BufferList([Buffer.from(Varint.encode(c.length)), c])
module.exports = encode
module.exports.MIN_POOL_SIZE = MIN_POOL_SIZE
module.exports.DEFAULT_POOL_SIZE = DEFAULT_POOL_SIZE

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet