mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 05:21:19 +00: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>
22 lines
481 B
JavaScript
22 lines
481 B
JavaScript
'use strict';
|
|
var assert = require('assert');
|
|
var common = require('../common');
|
|
var dgram = require('dgram');
|
|
|
|
var buf = Buffer.alloc(1024, 42);
|
|
|
|
var socket = dgram.createSocket('udp4');
|
|
var closeEvents = 0;
|
|
socket.send(buf, 0, buf.length, common.PORT, 'localhost');
|
|
|
|
// if close callback is not function, ignore the argument.
|
|
socket.close('bad argument');
|
|
|
|
socket.on('close', function() {
|
|
++closeEvents;
|
|
});
|
|
|
|
process.on('exit', function() {
|
|
assert.equal(closeEvents, 1);
|
|
});
|