Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

deps: update uint8arraylist dep #199

Merged
merged 1 commit into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
"it-pipe": "^2.0.3",
"it-pushable": "^3.0.0",
"it-stream-types": "^1.0.4",
"uint8arraylist": "^1.4.0",
"uint8arraylist": "^2.1.1",
"uint8arrays": "^3.0.0",
"varint": "^6.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/decode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Decoder {
}

if (type === MessageTypes.NEW_STREAM || type === MessageTypes.MESSAGE_INITIATOR || type === MessageTypes.MESSAGE_RECEIVER) {
msg.data = this._buffer.slice(offset, offset + length)
msg.data = this._buffer.subarray(offset, offset + length)
}

msgs.push(msg)
Expand Down
4 changes: 2 additions & 2 deletions src/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Encoder {

offset += varint.encode.bytes

const header = pool.slice(this._poolOffset, offset)
const header = pool.subarray(this._poolOffset, offset)

if (POOL_SIZE - offset < 100) {
this._pool = allocUnsafe(POOL_SIZE)
Expand All @@ -44,7 +44,7 @@ class Encoder {
if ((msg.type === MessageTypes.NEW_STREAM || msg.type === MessageTypes.MESSAGE_INITIATOR || msg.type === MessageTypes.MESSAGE_RECEIVER) && msg.data != null) {
return [
header,
msg.data instanceof Uint8Array ? msg.data : msg.data.slice()
msg.data instanceof Uint8Array ? msg.data : msg.data.subarray()
]
}

Expand Down
10 changes: 5 additions & 5 deletions src/mplex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ function printMessage (msg: Message) {
}

if (msg.type === MessageTypes.NEW_STREAM) {
output.data = uint8ArrayToString(msg.data instanceof Uint8Array ? msg.data : msg.data.slice())
output.data = uint8ArrayToString(msg.data instanceof Uint8Array ? msg.data : msg.data.subarray())
}

if (msg.type === MessageTypes.MESSAGE_INITIATOR || msg.type === MessageTypes.MESSAGE_RECEIVER) {
output.data = uint8ArrayToString(msg.data instanceof Uint8Array ? msg.data : msg.data.slice(), 'base16')
output.data = uint8ArrayToString(msg.data instanceof Uint8Array ? msg.data : msg.data.subarray(), 'base16')
}

return output
Expand Down Expand Up @@ -165,7 +165,7 @@ export class MplexStreamMuxer implements StreamMuxer {
}

if (msg.type === MessageTypes.NEW_STREAM || msg.type === MessageTypes.MESSAGE_INITIATOR || msg.type === MessageTypes.MESSAGE_RECEIVER) {
msg.data = msg.data instanceof Uint8Array ? msg.data : msg.data.slice()
msg.data = msg.data instanceof Uint8Array ? msg.data : msg.data.subarray()
}

this._source.push(msg)
Expand Down Expand Up @@ -263,7 +263,7 @@ export class MplexStreamMuxer implements StreamMuxer {
return
}

const stream = this._newReceiverStream({ id, name: uint8ArrayToString(message.data instanceof Uint8Array ? message.data : message.data.slice()) })
const stream = this._newReceiverStream({ id, name: uint8ArrayToString(message.data instanceof Uint8Array ? message.data : message.data.subarray()) })

if (this._init.onIncomingStream != null) {
this._init.onIncomingStream(stream)
Expand Down Expand Up @@ -301,7 +301,7 @@ export class MplexStreamMuxer implements StreamMuxer {
}

// We got data from the remote, push it into our local stream
stream.source.push(message.data.slice())
stream.source.push(message.data.subarray())
break
case MessageTypes.CLOSE_INITIATOR:
case MessageTypes.CLOSE_RECEIVER:
Expand Down