Files
node/test/parallel/test-process-emit.js
T
cjihrig 5a77c095a6 process: support symbol events
Event emitters support symbols as event names. The process object
assumes that the event name is a string, and examines the first
three characters to check for signals. This causes an exception
if the event name is a symbol. This commit ensures that the
event name is a string before trying to slice() it.

PR-URL: https://github.com/nodejs/node/pull/4798
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Wyatt Preul <wpreul@gmail.com>
2016-01-25 21:33:55 +11:00

21 lines
499 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const sym = Symbol();
process.on('normal', common.mustCall(data => {
assert.strictEqual(data, 'normalData');
}));
process.on(sym, common.mustCall(data => {
assert.strictEqual(data, 'symbolData');
}));
process.on('SIGPIPE', common.mustCall(data => {
assert.strictEqual(data, 'signalData');
}));
process.emit('normal', 'normalData');
process.emit(sym, 'symbolData');
process.emit('SIGPIPE', 'signalData');