The initial value of Object.prototype.constructor is the standard built-in Object constructor.
Static[kStaticprefixedWhether the stream is appending to the file or truncating it
The type of data that can be written to the stream
The file descriptor that is being written to
The file that is being written to
Whether the stream performs a fsyncSync after every write
The maximum length of the internal buffer.
If a write would cause the buffer to exceed this, the data is dropped and a drop event is emitted with it.
The minimum length of the internal buffer that is required to be full before flushing
Whether the directory for file is created if it does not exist
The mode of the file that is being written to
The number of milliseconds between flushes. 0 means no periodic flushes are performed.
Whether the stream is writing synchronously or asynchronously
Whether the stream is currently writing data to the file
Close the stream immediately, without flushing the internal buffer.
Close the stream gracefully, flushing the internal buffer before closing.
Return an array listing the events for which the emitter has registered listeners.
Writes the current buffer to the file if a write was not in progress.
Does nothing if minLength is zero or if it is already writing.
Optionalcb: ((err: Error | null) => void) | nullFlushes the buffered data synchronously. This is a costly operation.
Return the number of listeners listening to a given event.
Adds the listener function to the beginning of the listeners array for the
event named eventName. No checks are made to see if the listener has
already been added. Multiple calls passing the same combination of eventName
and listener will result in the listener being added, and called, multiple
times.
server.prependListener('connection', (stream) => {
console.log('someone connected!');
});
Returns a reference to the EventEmitter, so that calls can be chained.
Adds a one-time listener function for the event named eventName to the
beginning of the listeners array. The next time eventName is triggered, this
listener is removed, and then invoked.
server.prependOnceListener('connection', (stream) => {
console.log('Ah, we have our first user!');
});
Returns a reference to the EventEmitter, so that calls can be chained.
Returns a copy of the array of listeners for the event named eventName,
including any wrappers (such as those created by .once()).
import { EventEmitter } from 'node:events';
const emitter = new EventEmitter();
emitter.once('log', () => console.log('log once'));
// Returns a new Array with a function `onceWrapper` which has a property
// `listener` which contains the original listener bound above
const listeners = emitter.rawListeners('log');
const logFnWrapper = listeners[0];
// Logs "log once" to the console and does not unbind the `once` event
logFnWrapper.listener();
// Logs "log once" to the console and removes the listener
logFnWrapper();
emitter.on('log', () => console.log('log persistently'));
// Will return a new Array with a single function bound by `.on()` above
const newListeners = emitter.rawListeners('log');
// Logs "log persistently" twice
newListeners[0]();
emitter.emit('log');
Remove all listeners, or those of the specified event.
Optionalevent: keyof Utf8StreamEventMapRemove the listeners of a given event.
Optionalfn: (...args: any[]) => voidOptionalcontext: anyOptionalonce: booleanReopen the file in place, useful for log rotation.
Optionalfile: PathLikeBy default EventEmitters will print a warning if more than 10 listeners are
added for a particular event. This is a useful default that helps finding
memory leaks. The emitter.setMaxListeners() method allows the limit to be
modified for this specific EventEmitter instance. The value can be set to
Infinity (or 0) to indicate an unlimited number of listeners.
Returns a reference to the EventEmitter, so that calls can be chained.
When contentMode is utf8, data must be a string. When it is buffer, data must be a Buffer.
Whether the internal buffer is below the high water mark
An optimized UTF-8 stream writer that allows for flushing all of the internal buffering on demand.