Skip to content

Commit

Permalink
[minor] Use spread syntax instead of Object.assign()
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinca committed Jan 19, 2020
1 parent 401a585 commit 748a844
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 37 deletions.
10 changes: 5 additions & 5 deletions bench/parser.benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ const options = {
};

function createBinaryFrame(length) {
const list = Sender.frame(
crypto.randomBytes(length),
Object.assign({ opcode: 0x02 }, options)
);
const list = Sender.frame(crypto.randomBytes(length), {
opcode: 0x02,
...options
});

return Buffer.concat(list);
}

const pingFrame1 = Buffer.concat(
Sender.frame(crypto.randomBytes(5), Object.assign({ opcode: 0x09 }, options))
Sender.frame(crypto.randomBytes(5), { opcode: 0x09, ...options })
);

const textFrame = Buffer.from('819461616161' + '61'.repeat(20), 'hex');
Expand Down
72 changes: 40 additions & 32 deletions test/receiver.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,18 @@ describe('Receiver', () => {
const options = { rsv1: false, mask: true, readOnly: false };

const frame1 = Buffer.concat(
Sender.frame(
Buffer.from(fragment1),
Object.assign({ fin: false, opcode: 0x01 }, options)
)
Sender.frame(Buffer.from(fragment1), {
fin: false,
opcode: 0x01,
...options
})
);
const frame2 = Buffer.concat(
Sender.frame(
Buffer.from(fragment2),
Object.assign({ fin: true, opcode: 0x00 }, options)
)
Sender.frame(Buffer.from(fragment2), {
fin: true,
opcode: 0x00,
...options
})
);

receiver.on('message', (data) => {
Expand Down Expand Up @@ -180,22 +182,25 @@ describe('Receiver', () => {
const options = { rsv1: false, mask: true, readOnly: false };

const frame1 = Buffer.concat(
Sender.frame(
Buffer.from(fragment1),
Object.assign({ fin: false, opcode: 0x01 }, options)
)
Sender.frame(Buffer.from(fragment1), {
fin: false,
opcode: 0x01,
...options
})
);
const frame2 = Buffer.concat(
Sender.frame(
Buffer.from(pingMessage),
Object.assign({ fin: true, opcode: 0x09 }, options)
)
Sender.frame(Buffer.from(pingMessage), {
fin: true,
opcode: 0x09,
...options
})
);
const frame3 = Buffer.concat(
Sender.frame(
Buffer.from(fragment2),
Object.assign({ fin: true, opcode: 0x00 }, options)
)
Sender.frame(Buffer.from(fragment2), {
fin: true,
opcode: 0x00,
...options
})
);

let gotPing = false;
Expand Down Expand Up @@ -226,22 +231,25 @@ describe('Receiver', () => {
const options = { rsv1: false, mask: true, readOnly: false };

const frame1 = Buffer.concat(
Sender.frame(
Buffer.from(fragment1),
Object.assign({ fin: false, opcode: 0x01 }, options)
)
Sender.frame(Buffer.from(fragment1), {
fin: false,
opcode: 0x01,
...options
})
);
const frame2 = Buffer.concat(
Sender.frame(
Buffer.from(pingMessage),
Object.assign({ fin: true, opcode: 0x09 }, options)
)
Sender.frame(Buffer.from(pingMessage), {
fin: true,
opcode: 0x09,
...options
})
);
const frame3 = Buffer.concat(
Sender.frame(
Buffer.from(fragment2),
Object.assign({ fin: true, opcode: 0x00 }, options)
)
Sender.frame(Buffer.from(fragment2), {
fin: true,
opcode: 0x00,
...options
})
);

let chunks = [];
Expand Down

0 comments on commit 748a844

Please sign in to comment.