Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
fix: dont mutate select protocols (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobheun authored Oct 31, 2019
1 parent 1877dcf commit 662b5fd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const multistream = require('./multistream')
const handshake = require('it-handshake')

module.exports = async (stream, protocols, protocolId) => {
protocols = Array.isArray(protocols) ? protocols : [protocols]
protocols = Array.isArray(protocols) ? [...protocols] : [protocols]
const { reader, writer, rest, stream: shakeStream } = handshake(stream)

const protocol = protocols.shift()
Expand Down
1 change: 1 addition & 0 deletions test/dialer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe('Dialer', () => {

const mss = new MSS.Dialer(duplex)
const selection = await mss.select(protocols)
expect(protocols).to.have.length(2)
expect(selection.protocol).to.equal(selectedProtocol)

// Ensure stream is usable after selection
Expand Down

0 comments on commit 662b5fd

Please sign in to comment.