New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dgram: support Uint8Array input to send() #11985

Closed
wants to merge 2 commits into
base: master
from

Conversation

Projects
None yet
7 participants
@addaleax
Member

addaleax commented Mar 22, 2017

Fixes: #11954
Refs: #11961

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)
Show outdated Hide outdated lib/dgram.js
else if (!(buffer instanceof Buffer))
throw new TypeError('First argument must be a buffer or string');
} else if (!isUint8Array(buffer)) {
throw new TypeError('First argument must be a buffer, ' +

This comment has been minimized.

@jasnell

jasnell Mar 22, 2017

Member

Since the error message is changing anyway, can you s/buffer/Buffer here to make it consistent with the other error messages thrown in this module?

@jasnell

jasnell Mar 22, 2017

Member

Since the error message is changing anyway, can you s/buffer/Buffer here to make it consistent with the other error messages thrown in this module?

This comment has been minimized.

@addaleax

addaleax Mar 22, 2017

Member

@jasnell Right, done!

@addaleax

addaleax Mar 22, 2017

Member

@jasnell Right, done!

Show outdated Hide outdated test/parallel/test-dgram-send-default-host.js
@@ -16,7 +16,7 @@ const received = [];
client.on('listening', common.mustCall(() => {
const port = client.address().port;
client.send(toSend[0], 0, toSend[0].length, port);
client.send(toSend[1], port);
client.send(new Uint8Array([...toSend[1]]), port);

This comment has been minimized.

@joyeecheung

joyeecheung Mar 24, 2017

Member

This is missing test cases for socket.send(u8a, offset, length, port) and socket.send(buffer, port).

Also, is new Uint8Array([...toSend[1]]) here the same as new Uint8Array(toSend[1])?

@joyeecheung

joyeecheung Mar 24, 2017

Member

This is missing test cases for socket.send(u8a, offset, length, port) and socket.send(buffer, port).

Also, is new Uint8Array([...toSend[1]]) here the same as new Uint8Array(toSend[1])?

This comment has been minimized.

@addaleax

addaleax Mar 24, 2017

Member

@joyeecheung Right, thanks for pointing that out. I’ve updated the file so all the tests are run twice now, once with the original input types and once with Uint8Arrays.

@addaleax

addaleax Mar 24, 2017

Member

@joyeecheung Right, thanks for pointing that out. I’ve updated the file so all the tests are run twice now, once with the original input types and once with Uint8Arrays.

@lpinca

lpinca approved these changes Mar 24, 2017

@addaleax

This comment has been minimized.

Show comment
Hide comment
@addaleax

addaleax Mar 27, 2017

Member

Landed in 2dc1053

Member

addaleax commented Mar 27, 2017

Landed in 2dc1053

@addaleax addaleax closed this Mar 27, 2017

@addaleax addaleax deleted the addaleax:dgram-uint8array branch Mar 27, 2017

addaleax added a commit that referenced this pull request Mar 27, 2017

dgram: support Uint8Array input to send()
Fixes: #11954
Refs: #11961
PR-URL: #11985
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>

@jasnell jasnell referenced this pull request Apr 4, 2017

Closed

8.0.0 Release Proposal #12220

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment