Skip to content

Commit

Permalink
refactor: API tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw committed Nov 12, 2019
1 parent b61654d commit b651ba4
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Returns a `BufferList` containing the encoded chunk.

Returns a [transform](https://gist.github.com/alanshaw/591dc7dd54e4f99338a347ef568d6ee9#transform-it) that yields [`BufferList`](https://www.npmjs.com/package/bl) objects.

### `decodeFromReader(reader, [opts])`
### `decode.fromReader(reader, [opts])`

Behaves like `decode` except it only reads the exact number of bytes needed for each message in `reader`.

Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"aegir": "^20.3.1",
"chai": "^4.2.0",
"it-block": "^2.0.0",
"it-pipe": "^1.0.1",
"it-pushable": "^1.3.1",
"it-pipe": "^1.1.0",
"it-pushable": "^1.4.0",
"it-reader": "^2.0.0",
"p-defer": "^3.0.0",
"random-bytes": "^1.0.0",
Expand Down
3 changes: 1 addition & 2 deletions src/decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function decode (options) {
})()
}

function decodeFromReader (reader, options) {
decode.fromReader = (reader, options) => {
options = options || {}

let byteLength = 1 // Read single byte chunks until the length is known
Expand All @@ -127,5 +127,4 @@ function decodeFromReader (reader, options) {
}

module.exports = decode
module.exports.decodeFromReader = decodeFromReader
module.exports.MAX_DATA_LENGTH = MAX_DATA_LENGTH
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

exports.encode = require('./encode')
exports.decode = require('./decode')
exports.decodeFromReader = exports.decode.decodeFromReader
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('decode from reader', () => {
)

const output = await pipe(
lp.decodeFromReader(reader),
lp.decode.fromReader(reader),
toBuffer,
collect
)
Expand All @@ -42,7 +42,7 @@ describe('decode from reader', () => {
const reader = Reader(input)
try {
await pipe(
lp.decodeFromReader(reader, { maxDataLength: 100 }),
lp.decode.fromReader(reader, { maxDataLength: 100 }),
toBuffer,
collect
)
Expand Down

0 comments on commit b651ba4

Please sign in to comment.