mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
Several changes:
* Soft-Deprecate Buffer() constructors
* Add `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()`
* Add `--zero-fill-buffers` command line option
* Add byteOffset and length to `new Buffer(arrayBuffer)` constructor
* buffer.fill('') previously had no effect, now zero-fills
* Update the docs
PR-URL: https://github.com/nodejs/node/pull/4682
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
19 lines
621 B
JavaScript
19 lines
621 B
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
var dgram = require('dgram');
|
|
|
|
// Send a too big datagram. The destination doesn't matter because it's
|
|
// not supposed to get sent out anyway.
|
|
var buf = Buffer.allocUnsafe(256 * 1024);
|
|
var sock = dgram.createSocket('udp4');
|
|
sock.send(buf, 0, buf.length, 12345, '127.0.0.1', common.mustCall(cb));
|
|
function cb(err) {
|
|
assert(err instanceof Error);
|
|
assert.equal(err.code, 'EMSGSIZE');
|
|
assert.equal(err.address, '127.0.0.1');
|
|
assert.equal(err.port, 12345);
|
|
assert.equal(err.message, 'send EMSGSIZE 127.0.0.1:12345');
|
|
sock.close();
|
|
}
|