Private
clientUnique Guid associated with this connection. Used to verify certain things with server
-Sets up the NetworkConnector by populating connector info, setting up event handlers, and doing +
Handles the connection from the client to the server
+Private
clientUnique Guid associated with this connection. Used to verify certain things with server
+Sets up the NetworkConnector by populating connector info, setting up event handlers, and doing one of the following:
MUST ALSO RUN notifyClientConnected() WHEN PROMISE RESOLVES
-Function that handles requests from the connection. Only called when - this connector can handle the request
-Function that returns a clientId to which to send the request based on the - requestType. If requestRouter returns this connector's clientId, localRequestHandler is used
-Function that handles events from the server by accepting an eventType - and an event and emitting the event locally
-Functions that run when network connector events occur - like when clients are disconnected
-Promise that resolves with connector info when finished connecting
-Private
Optional
connectPromise that resolves when the connection is finished or rejects if disconnected before the +
Promise that resolves with connector info when finished connecting
+Private
Optional
connectPromise that resolves when the connection is finished or rejects if disconnected before the connection finishes
-Whether this connector is setting up or has finished setting up its connection and is ready to +
Whether this connector is setting up or has finished setting up its connection and is ready to communicate on the network
-Information about the connector. Populated by the server while connecting
-Disconnects from the connection:
+Information about the connector. Populated by the server while connecting
+Disconnects from the connection:
Sends an event to other processes. Does NOT run the local event subscriptions as they should be +
Sends an event to other processes. Does NOT run the local event subscriptions as they should be run by NetworkEventEmitter after sending on network.
-Unique network event type for coordinating between processes
-Event to emit on the network
-Private
handleFunction that handles incoming webSocket messages of type Event. Runs the eventHandler provided +
Private
handleFunction that handles incoming webSocket messages of type Event. Runs the eventHandler provided in connect()
Event message to handle
-Private
handleFunction that handles incoming webSocket messages and locally sent messages of type Request. +
Private
handleFunction that handles incoming webSocket messages and locally sent messages of type Request. Runs the requestHandler provided in connect() and sends a message with the response
Request message to handle
Whether this message is coming from the server and we should definitely handle it locally or if it is a locally sent request and we should send to the server if we don't have a local handler
-Private
handleFunction that handles webSocket messages of type Response. Resolves the request associated with +
Private
handleFunction that handles webSocket messages of type Response. Resolves the request associated with the received response message
Response message to resolve
-Private
Optional
localFunction to call when we receive an event. Handles events from the connection by emitting the +
Private
Optional
localFunction to call when we receive an event. Handles events from the connection by emitting the event locally
-Private
Optional
localFunction to call when we receive a request that is registered on this connector. Handles +
Private
Optional
localFunction to call when we receive a request that is registered on this connector. Handles requests from the connection and returns a response to send back
-Private
messageAll message subscriptions - emitters that emit an event each time a message with a specific +
Private
messageAll message subscriptions - emitters that emit an event each time a message with a specific message type comes in
-Notify the server that this client has received its connectorInfo and is ready to go.
+Notify the server that this client has received its connectorInfo and is ready to go.
MUST RUN AFTER connect() WHEN ITS PROMISE RESOLVES
TODO: Is this necessary?
-Private
onReceives and appropriately publishes server webSocket messages
+Private
onReceives and appropriately publishes server webSocket messages
WebSocket message information
Whether this message is from this connector instead of from someone else
-Send a request to the server/a client and resolve after receiving a response
-The type of request
+Send a request to the server/a client and resolve after receiving a response
+The type of request
Contents to send in the request
Promise that resolves with the response message
-Private
Optional
requestFunction to call when we are sending a request. Returns a clientId to which to send the request +
Private
Optional
requestFunction to call when we are sending a request. Returns a clientId to which to send the request based on the requestType
-Private
requestsAll requests that are waiting for a response
-Private
sendSend a message to the server via webSocket. Throws if not connected
+Private
requestsAll requests that are waiting for a response
+Private
sendSend a message to the server via webSocket. Throws if not connected
Message to send
-Private
subscribeSubscribes a function to run on webSocket messages of a particular type
+Private
subscribeSubscribes a function to run on webSocket messages of a particular type
The type of message on which to subscribe the function
Function to run with the contents of the webSocket message
Unsubscriber function to run to stop calling the passed-in function on webSocket messages
-Private
Optional
unsubscribeFunction that removes this handleEvent from the connection
-Private
Optional
unsubscribeFunction that removes this initClient handler from the connection
-Private
Optional
unsubscribeFunction that removes this handleRequest from the connection
-Private
Optional
unsubscribeFunction that removes this response handler from the connection
-Private
Optional
webThe webSocket connected to the server
-Generated using TypeDoc
Private
Optional
unsubscribeFunction that removes this handleEvent from the connection
+Private
Optional
unsubscribeFunction that removes this initClient handler from the connection
+Private
Optional
unsubscribeFunction that removes this handleRequest from the connection
+Private
Optional
unsubscribeFunction that removes this response handler from the connection
+Private
Optional
webThe webSocket connected to the server
+Optional
options: ClientRequestArgs | ClientOptionsOptional
protocols: string | string[]Optional
options: ClientRequestArgs | ClientOptionsStatic
Readonly
CLOSEDThe connection is closed.
-Readonly
CLOSEDThe connection is closed.
-Static
Readonly
CLOSINGThe connection is in the process of closing.
-Readonly
CLOSINGThe connection is in the process of closing.
-Static
Readonly
CONNECTINGThe connection is not yet open.
-Readonly
CONNECTINGThe connection is not yet open.
-Static
Readonly
OPENThe connection is open and ready to communicate.
-Readonly
OPENThe connection is open and ready to communicate.
-Readonly
bufferedStatic
Readonly
captureValue: Symbol.for('nodejs.rejection')
Optional
options: ClientRequestArgs | ClientOptionsOptional
protocols: string | string[]Optional
options: ClientRequestArgs | ClientOptionsStatic
Readonly
CLOSEDThe connection is closed.
+Readonly
CLOSEDThe connection is closed.
+Static
Readonly
CLOSINGThe connection is in the process of closing.
+Readonly
CLOSINGThe connection is in the process of closing.
+Static
Readonly
CONNECTINGThe connection is not yet open.
+Readonly
CONNECTINGThe connection is not yet open.
+Static
Readonly
OPENThe connection is open and ready to communicate.
+Readonly
OPENThe connection is open and ready to communicate.
+Readonly
bufferedStatic
Readonly
captureValue: Symbol.for('nodejs.rejection')
See how to write a custom rejection handler
.
v13.4.0, v12.16.0
-Static
captureValue: boolean
+Static
captureValue: boolean
Change the default captureRejections
option on all new EventEmitter
objects.
v13.4.0, v12.16.0
-Static
defaultBy default, a maximum of 10
listeners can be registered for any single
+
Static
defaultBy default, a maximum of 10
listeners can be registered for any single
event. This limit can be changed for individual EventEmitter
instances
using the emitter.setMaxListeners(n)
method. To change the default
for allEventEmitter
instances, the events.defaultMaxListeners
property can be used. If this value is not a positive number, a RangeError
is thrown.
name
property is set to 'MaxListenersExceededWarning'
.
v0.11.2
-Static
Readonly
errorThis symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular'error'
listeners are called.
Static
Readonly
errorThis symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular'error'
listeners are called.
Installing a listener using this symbol does not change the behavior once an'error'
event is emitted. Therefore, the process will still crash if no
regular 'error'
listener is installed.
v13.6.0, v12.17.0
-Readonly
extensionsReadonly
isIndicates whether the websocket is paused
-Readonly
protocolReadonly
readyThe current state of the connection
-Readonly
urlOptional
[captureRest
...args: AnyRestStatic
addReadonly
extensionsReadonly
isIndicates whether the websocket is paused
+Readonly
protocolReadonly
readyThe current state of the connection
+Readonly
urlOptional
[captureRest
...args: AnyRestStatic
addExperimental
Listens once to the abort
event on the provided signal
.
Listening to the abort
event on abort signals is unsafe and may
lead to resource leaks since another third party with the signal can
call e.stopImmediatePropagation()
. Unfortunately Node.js cannot change
@@ -108,28 +108,28 @@
Returns a disposable so that it may be unsubscribed from more easily.
import { addAbortListener } from 'node:events';
function example(signal) {
let disposable;
try {
signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
disposable = addAbortListener(signal, (e) => {
// Do something when signal is aborted.
});
} finally {
disposable?.[Symbol.dispose]();
}
}
-Disposable that removes the abort
listener.
Disposable that removes the abort
listener.
v20.5.0
-Optional
options: EventListenerOptionsOptional
options: EventListenerOptionsOptional
options: EventListenerOptionsOptional
options: EventListenerOptionsRest
...args: any[]Synchronously calls each of the listeners registered for the event namedeventName
, in the order they were registered, passing the supplied arguments
+
Optional
options: EventListenerOptionsOptional
options: EventListenerOptionsOptional
options: EventListenerOptionsOptional
options: EventListenerOptionsRest
...args: any[]Synchronously calls each of the listeners registered for the event namedeventName
, in the order they were registered, passing the supplied arguments
to each.
Returns true
if the event had listeners, false
otherwise.
import { EventEmitter } from 'node:events';
const myEmitter = new EventEmitter();
// First listener
myEmitter.on('event', function firstListener() {
console.log('Helloooo! first listener');
});
// Second listener
myEmitter.on('event', function secondListener(arg1, arg2) {
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
});
// Third listener
myEmitter.on('event', function thirdListener(...args) {
const parameters = args.join(', ');
console.log(`event with parameters ${parameters} in third listener`);
});
console.log(myEmitter.listeners('event'));
myEmitter.emit('event', 1, 2, 3, 4, 5);
// Prints:
// [
// [Function: firstListener],
// [Function: secondListener],
// [Function: thirdListener]
// ]
// Helloooo! first listener
// event with parameters 1, 2 in second listener
// event with parameters 1, 2, 3, 4, 5 in third listener
-Rest
...args: AnyRestv0.1.26
-Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbol
s.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
v6.0.0
-Static
getStatic
getReturns a copy of the array of listeners for the event named eventName
.
For EventEmitter
s this behaves exactly the same as calling .listeners
on
the emitter.
For EventTarget
s this is the only way to get the event listeners for the
event target. This is useful for debugging and diagnostic purposes.
import { getEventListeners, EventEmitter } from 'node:events';
{
const ee = new EventEmitter();
const listener = () => console.log('Events are fun');
ee.on('foo', listener);
console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
}
{
const et = new EventTarget();
const listener = () => console.log('Events are fun');
et.addEventListener('foo', listener);
console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
}
-v15.2.0, v14.17.0
-Static
getStatic
getReturns the currently set max amount of listeners.
For EventEmitter
s this behaves exactly the same as calling .getMaxListeners
on
the emitter.
For EventTarget
s this is the only way to get the max event listeners for the
@@ -137,28 +137,28 @@
the max set, the EventTarget will print a warning.
import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';
{
const ee = new EventEmitter();
console.log(getMaxListeners(ee)); // 10
setMaxListeners(11, ee);
console.log(getMaxListeners(ee)); // 11
}
{
const et = new EventTarget();
console.log(getMaxListeners(et)); // 10
setMaxListeners(11, et);
console.log(getMaxListeners(et)); // 11
}
-v19.9.0
-Returns the current max listener value for the EventEmitter
which is either
set by emitter.setMaxListeners(n)
or defaults to defaultMaxListeners.
v1.0.0
-Static
listenerStatic
listenerA class method that returns the number of listeners for the given eventName
registered on the given emitter
.
import { EventEmitter, listenerCount } from 'node:events';
const myEmitter = new EventEmitter();
myEmitter.on('event', () => {});
myEmitter.on('event', () => {});
console.log(listenerCount(myEmitter, 'event'));
// Prints: 2
-The emitter to query
-The event name
+The emitter to query
+The event name
v0.9.12
Since v3.2.0 - Use listenerCount
instead.
Returns the number of listeners listening for the event named eventName
.
+
Returns the number of listeners listening for the event named eventName
.
If listener
is provided, it will return how many times the listener is found
in the list of the listeners of the event.
The name of the event being listened for
-Optional
listener: FunctionThe event handler function
+The name of the event being listened for
+Optional
listener: FunctionThe event handler function
v3.2.0
-Returns a copy of the array of listeners for the event named eventName
.
Returns a copy of the array of listeners for the event named eventName
.
server.on('connection', (stream) => {
console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')));
// Prints: [ [Function] ]
-v0.1.26
-Rest
...args: any[]Static
onimport { on, EventEmitter } from 'node:events';
import process from 'node:process';
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
});
for await (const event of on(ee, 'foo')) {
// The execution of this inner block is synchronous and it
// processes one event at a time (even with await). Do not use
// if concurrent execution is required.
console.log(event); // prints ['bar'] [42]
}
// Unreachable here
+
v0.1.26
+Rest
...args: any[]Static
onimport { on, EventEmitter } from 'node:events';
import process from 'node:process';
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
});
for await (const event of on(ee, 'foo')) {
// The execution of this inner block is synchronous and it
// processes one event at a time (even with await). Do not use
// if concurrent execution is required.
console.log(event); // prints ['bar'] [42]
}
// Unreachable here
Returns an AsyncIterator
that iterates eventName
events. It will throw
if the EventEmitter
emits 'error'
. It removes all listeners when
@@ -167,10 +167,10 @@
Since v3.2.0 - Use listenerCount
instead.
An AbortSignal
can be used to cancel waiting on events:
import { on, EventEmitter } from 'node:events';
import process from 'node:process';
const ac = new AbortController();
(async () => {
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
});
for await (const event of on(ee, 'foo', { signal: ac.signal })) {
// The execution of this inner block is synchronous and it
// processes one event at a time (even with await). Do not use
// if concurrent execution is required.
console.log(event); // prints ['bar'] [42]
}
// Unreachable here
})();
process.nextTick(() => ac.abort());
-The name of the event being listened for
-Optional
options: StaticEventEmitterOptionsthat iterates eventName
events emitted by the emitter
The name of the event being listened for
+Optional
options: StaticEventEmitterOptionsthat iterates eventName
events emitted by the emitter
v13.6.0, v12.16.0
-Rest
...args: any[]Static
onceRest
...args: any[]Static
onceCreates a Promise
that is fulfilled when the EventEmitter
emits the given
event or that is rejected if the EventEmitter
emits 'error'
while waiting.
The Promise
will resolve with an array of all the arguments emitted to the
given event.
Since v3.2.0 - Use listenerCount
instead.
An AbortSignal
can be used to cancel waiting for the event:
import { EventEmitter, once } from 'node:events';
const ee = new EventEmitter();
const ac = new AbortController();
async function foo(emitter, event, signal) {
try {
await once(emitter, event, { signal });
console.log('event emitted!');
} catch (error) {
if (error.name === 'AbortError') {
console.error('Waiting for the event was canceled!');
} else {
console.error('There was an error', error.message);
}
}
}
foo(ee, 'foo', ac.signal);
ac.abort(); // Abort waiting for the event
ee.emit('foo'); // Prints: Waiting for the event was canceled!
-Optional
options: StaticEventEmitterOptionsv11.13.0, v10.16.0
-Optional
options: StaticEventEmitterOptionsRest
...args: any[]Pause the websocket causing it to stop emitting events. Some events can still be +
Optional
options: StaticEventEmitterOptionsv11.13.0, v10.16.0
+Optional
options: StaticEventEmitterOptionsRest
...args: any[]Adds the listener
function to the beginning of the listeners array for the
+
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.
The name of the event.
-The callback function
-Rest
...args: any[]v6.0.0
-Adds a one-timelistener
function for the event named eventName
to the beginning of the listeners array. The next time eventName
is triggered, this
+
The name of the event.
+The callback function
+Rest
...args: any[]v6.0.0
+Adds a one-timelistener
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.
The name of the event.
-The callback function
-Rest
...args: any[]v6.0.0
-Returns a copy of the array of listeners for the event named eventName
,
+
The name of the event.
+The callback function
+Rest
...args: any[]v6.0.0
+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');
-v9.4.0
-Removes all listeners, or those of the specified eventName
.
It is bad practice to remove listeners added elsewhere in the code,
particularly when the EventEmitter
instance was created by some other
component or module (e.g. sockets or file streams).
Returns a reference to the EventEmitter
, so that calls can be chained.
Optional
eventName: string | symbolv0.1.26
-Rest
...args: any[]Rest
...args: any[]Optional
cb: ((err?) => void)Optional
err: ErrorOptional
binary?: booleanOptional
compress?: booleanOptional
fin?: booleanOptional
mask?: booleanOptional
cb: ((err?) => void)Optional
err: ErrorStatic
setOptional
cb: ((err?) => void)Optional
err: ErrorOptional
binary?: booleanOptional
compress?: booleanOptional
fin?: booleanOptional
mask?: booleanOptional
cb: ((err?) => void)Optional
err: ErrorStatic
setimport { setMaxListeners, EventEmitter } from 'node:events';
const target = new EventTarget();
const emitter = new EventEmitter();
setMaxListeners(5, target, emitter);
-Optional
n: numberA non-negative number. The maximum number of listeners per EventTarget
event.
Rest
...eventTargets: (EventEmitter<DefaultEventMap> | _DOMEventTarget)[]v15.4.0
-By default EventEmitter
s will print a warning if more than 10
listeners are
+
Optional
n: numberA non-negative number. The maximum number of listeners per EventTarget
event.
Rest
...eventTargets: (EventEmitter<DefaultEventMap> | _DOMEventTarget)[]v15.4.0
+By default EventEmitter
s 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 toInfinity
(or 0
) to indicate an unlimited number of listeners.
Returns a reference to the EventEmitter
, so that calls can be chained.
v0.3.5
-Generated using TypeDoc
v0.3.5
+Static
Readonly
captureValue: Symbol.for('nodejs.rejection')
Static
Readonly
captureValue: Symbol.for('nodejs.rejection')
See how to write a custom rejection handler
.
v13.4.0, v12.16.0
-Static
captureValue: boolean
+Static
captureValue: boolean
Change the default captureRejections
option on all new EventEmitter
objects.
v13.4.0, v12.16.0
-Static
defaultBy default, a maximum of 10
listeners can be registered for any single
+
Static
defaultBy default, a maximum of 10
listeners can be registered for any single
event. This limit can be changed for individual EventEmitter
instances
using the emitter.setMaxListeners(n)
method. To change the default
for allEventEmitter
instances, the events.defaultMaxListeners
property can be used. If this value is not a positive number, a RangeError
is thrown.
name
property is set to 'MaxListenersExceededWarning'
.
v0.11.2
-Static
Readonly
errorThis symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular'error'
listeners are called.
Static
Readonly
errorThis symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular'error'
listeners are called.
Installing a listener using this symbol does not change the behavior once an'error'
event is emitted. Therefore, the process will still crash if no
regular 'error'
listener is installed.
v13.6.0, v12.17.0
-Optional
[captureRest
...args: AnyRestStatic
addOptional
[captureRest
...args: AnyRestStatic
addExperimental
Listens once to the abort
event on the provided signal
.
Listening to the abort
event on abort signals is unsafe and may
lead to resource leaks since another third party with the signal can
call e.stopImmediatePropagation()
. Unfortunately Node.js cannot change
@@ -77,28 +77,28 @@
Returns a disposable so that it may be unsubscribed from more easily.
import { addAbortListener } from 'node:events';
function example(signal) {
let disposable;
try {
signal.addEventListener('abort', (e) => e.stopImmediatePropagation());
disposable = addAbortListener(signal, (e) => {
// Do something when signal is aborted.
});
} finally {
disposable?.[Symbol.dispose]();
}
}
-Disposable that removes the abort
listener.
Disposable that removes the abort
listener.
v20.5.0
-Rest
...args: any[]Synchronously calls each of the listeners registered for the event namedeventName
, in the order they were registered, passing the supplied arguments
+
Rest
...args: any[]Synchronously calls each of the listeners registered for the event namedeventName
, in the order they were registered, passing the supplied arguments
to each.
Returns true
if the event had listeners, false
otherwise.
import { EventEmitter } from 'node:events';
const myEmitter = new EventEmitter();
// First listener
myEmitter.on('event', function firstListener() {
console.log('Helloooo! first listener');
});
// Second listener
myEmitter.on('event', function secondListener(arg1, arg2) {
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
});
// Third listener
myEmitter.on('event', function thirdListener(...args) {
const parameters = args.join(', ');
console.log(`event with parameters ${parameters} in third listener`);
});
console.log(myEmitter.listeners('event'));
myEmitter.emit('event', 1, 2, 3, 4, 5);
// Prints:
// [
// [Function: firstListener],
// [Function: secondListener],
// [Function: thirdListener]
// ]
// Helloooo! first listener
// event with parameters 1, 2 in second listener
// event with parameters 1, 2, 3, 4, 5 in third listener
-Rest
...args: AnyRestv0.1.26
-Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbol
s.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
v6.0.0
-Static
getStatic
getReturns a copy of the array of listeners for the event named eventName
.
For EventEmitter
s this behaves exactly the same as calling .listeners
on
the emitter.
For EventTarget
s this is the only way to get the event listeners for the
event target. This is useful for debugging and diagnostic purposes.
import { getEventListeners, EventEmitter } from 'node:events';
{
const ee = new EventEmitter();
const listener = () => console.log('Events are fun');
ee.on('foo', listener);
console.log(getEventListeners(ee, 'foo')); // [ [Function: listener] ]
}
{
const et = new EventTarget();
const listener = () => console.log('Events are fun');
et.addEventListener('foo', listener);
console.log(getEventListeners(et, 'foo')); // [ [Function: listener] ]
}
-v15.2.0, v14.17.0
-Static
getStatic
getReturns the currently set max amount of listeners.
For EventEmitter
s this behaves exactly the same as calling .getMaxListeners
on
the emitter.
For EventTarget
s this is the only way to get the max event listeners for the
@@ -106,28 +106,28 @@
the max set, the EventTarget will print a warning.
import { getMaxListeners, setMaxListeners, EventEmitter } from 'node:events';
{
const ee = new EventEmitter();
console.log(getMaxListeners(ee)); // 10
setMaxListeners(11, ee);
console.log(getMaxListeners(ee)); // 11
}
{
const et = new EventTarget();
console.log(getMaxListeners(et)); // 10
setMaxListeners(11, et);
console.log(getMaxListeners(et)); // 11
}
-v19.9.0
-Returns the current max listener value for the EventEmitter
which is either
set by emitter.setMaxListeners(n)
or defaults to defaultMaxListeners.
v1.0.0
-Static
listenerStatic
listenerA class method that returns the number of listeners for the given eventName
registered on the given emitter
.
import { EventEmitter, listenerCount } from 'node:events';
const myEmitter = new EventEmitter();
myEmitter.on('event', () => {});
myEmitter.on('event', () => {});
console.log(listenerCount(myEmitter, 'event'));
// Prints: 2
-The emitter to query
-The event name
+The emitter to query
+The event name
v0.9.12
Since v3.2.0 - Use listenerCount
instead.
Returns the number of listeners listening for the event named eventName
.
+
Returns the number of listeners listening for the event named eventName
.
If listener
is provided, it will return how many times the listener is found
in the list of the listeners of the event.
The name of the event being listened for
-Optional
listener: FunctionThe event handler function
+The name of the event being listened for
+Optional
listener: FunctionThe event handler function
v3.2.0
-Returns a copy of the array of listeners for the event named eventName
.
Returns a copy of the array of listeners for the event named eventName
.
server.on('connection', (stream) => {
console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')));
// Prints: [ [Function] ]
-v0.1.26
-Static
onimport { on, EventEmitter } from 'node:events';
import process from 'node:process';
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
});
for await (const event of on(ee, 'foo')) {
// The execution of this inner block is synchronous and it
// processes one event at a time (even with await). Do not use
// if concurrent execution is required.
console.log(event); // prints ['bar'] [42]
}
// Unreachable here
+
v0.1.26
+Static
onimport { on, EventEmitter } from 'node:events';
import process from 'node:process';
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
});
for await (const event of on(ee, 'foo')) {
// The execution of this inner block is synchronous and it
// processes one event at a time (even with await). Do not use
// if concurrent execution is required.
console.log(event); // prints ['bar'] [42]
}
// Unreachable here
Returns an AsyncIterator
that iterates eventName
events. It will throw
if the EventEmitter
emits 'error'
. It removes all listeners when
@@ -136,10 +136,10 @@
Since v3.2.0 - Use listenerCount
instead.
An AbortSignal
can be used to cancel waiting on events:
import { on, EventEmitter } from 'node:events';
import process from 'node:process';
const ac = new AbortController();
(async () => {
const ee = new EventEmitter();
// Emit later on
process.nextTick(() => {
ee.emit('foo', 'bar');
ee.emit('foo', 42);
});
for await (const event of on(ee, 'foo', { signal: ac.signal })) {
// The execution of this inner block is synchronous and it
// processes one event at a time (even with await). Do not use
// if concurrent execution is required.
console.log(event); // prints ['bar'] [42]
}
// Unreachable here
})();
process.nextTick(() => ac.abort());
-The name of the event being listened for
-Optional
options: StaticEventEmitterOptionsthat iterates eventName
events emitted by the emitter
The name of the event being listened for
+Optional
options: StaticEventEmitterOptionsthat iterates eventName
events emitted by the emitter
v13.6.0, v12.16.0
-Static
onceStatic
onceCreates a Promise
that is fulfilled when the EventEmitter
emits the given
event or that is rejected if the EventEmitter
emits 'error'
while waiting.
The Promise
will resolve with an array of all the arguments emitted to the
given event.
Since v3.2.0 - Use listenerCount
instead.
An AbortSignal
can be used to cancel waiting for the event:
import { EventEmitter, once } from 'node:events';
const ee = new EventEmitter();
const ac = new AbortController();
async function foo(emitter, event, signal) {
try {
await once(emitter, event, { signal });
console.log('event emitted!');
} catch (error) {
if (error.name === 'AbortError') {
console.error('Waiting for the event was canceled!');
} else {
console.error('There was an error', error.message);
}
}
}
foo(ee, 'foo', ac.signal);
ac.abort(); // Abort waiting for the event
ee.emit('foo'); // Prints: Waiting for the event was canceled!
-Optional
options: StaticEventEmitterOptionsv11.13.0, v10.16.0
-Optional
options: StaticEventEmitterOptionsAdds the listener
function to the beginning of the listeners array for the
+
Optional
options: StaticEventEmitterOptionsv11.13.0, v10.16.0
+Optional
options: StaticEventEmitterOptionsAdds 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.
The name of the event.
-The callback function
-Rest
...args: any[]v6.0.0
-Adds a one-timelistener
function for the event named eventName
to the beginning of the listeners array. The next time eventName
is triggered, this
+
The name of the event.
+The callback function
+Rest
...args: any[]v6.0.0
+Adds a one-timelistener
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.
The name of the event.
-The callback function
-Rest
...args: any[]v6.0.0
-Returns a copy of the array of listeners for the event named eventName
,
+
The name of the event.
+The callback function
+Rest
...args: any[]v6.0.0
+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');
-v9.4.0
-Removes all listeners, or those of the specified eventName
.
It is bad practice to remove listeners added elsewhere in the code,
particularly when the EventEmitter
instance was created by some other
component or module (e.g. sockets or file streams).
Returns a reference to the EventEmitter
, so that calls can be chained.
Optional
eventName: string | symbolv0.1.26
-Rest
...args: any[]Static
setRest
...args: any[]Static
setimport { setMaxListeners, EventEmitter } from 'node:events';
const target = new EventTarget();
const emitter = new EventEmitter();
setMaxListeners(5, target, emitter);
-Optional
n: numberA non-negative number. The maximum number of listeners per EventTarget
event.
Rest
...eventTargets: (EventEmitter<DefaultEventMap> | _DOMEventTarget)[]v15.4.0
-By default EventEmitter
s will print a warning if more than 10
listeners are
+
Optional
n: numberA non-negative number. The maximum number of listeners per EventTarget
event.
Rest
...eventTargets: (EventEmitter<DefaultEventMap> | _DOMEventTarget)[]v15.4.0
+By default EventEmitter
s 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 toInfinity
(or 0
) to indicate an unlimited number of listeners.
Returns a reference to the EventEmitter
, so that calls can be chained.
v0.3.5
-Generated using TypeDoc
v0.3.5
+Handles the endpoint and connections from the server to the clients
-Private
clientThe webSocket clients that are connected and information about them
-Sets up the NetworkConnector by populating connector info, setting up event handlers, and doing +
Handles the endpoint and connections from the server to the clients
+Private
clientThe webSocket clients that are connected and information about them
+Sets up the NetworkConnector by populating connector info, setting up event handlers, and doing one of the following:
MUST ALSO RUN notifyClientConnected() WHEN PROMISE RESOLVES
-Function that handles requests from the connection. Only called when - this connector can handle the request
-Function that returns a clientId to which to send the request based on the - requestType. If requestRouter returns this connector's clientId, localRequestHandler is used
-Function that handles events from the server by accepting an eventType - and an event and emitting the event locally
-Functions that run when network connector events occur - like when clients are disconnected
-Promise that resolves with connector info when finished connecting
-Private
Optional
connectPromise that resolves when finished starting the server or rejects if disconnected before the +
Promise that resolves with connector info when finished connecting
+Private
Optional
connectPromise that resolves when finished starting the server or rejects if disconnected before the server finishes
-Whether this connector is setting up or has finished setting up its connection and is ready to +
Whether this connector is setting up or has finished setting up its connection and is ready to communicate on the network
-Information about the connector. Populated by the server while connecting
-Disconnects from the connection:
+Information about the connector. Populated by the server while connecting
+Disconnects from the connection:
Private
disconnectCloses connection and unregisters a client webSocket when it has disconnected
-Sends an event to other processes. Does NOT run the local event subscriptions as they should be +
Private
disconnectCloses connection and unregisters a client webSocket when it has disconnected
+Sends an event to other processes. Does NOT run the local event subscriptions as they should be run by NetworkEventEmitter after sending on network.
-Unique network event type for coordinating between processes
-Event to emit on the network
-Private
getGet the clientId for a certain webSocket. Throws if not found
-Private
getGet the client socket for a certain clientId. Throws if not found
-Private
getAttempts to get the client socket for a certain clientGuid. Returns undefined if not found. +
Private
getGet the clientId for a certain webSocket. Throws if not found
+Private
getGet the client socket for a certain clientId. Throws if not found
+Private
getAttempts to get the client socket for a certain clientGuid. Returns undefined if not found. This does not throw because it will likely be very common that we do not have a clientId for a certain clientGuid as connecting clients will often supply old clientGuids.
-Private
handleFunction that handles webSocket messages of type ClientConnect. Mark the connection fully +
Private
handleFunction that handles webSocket messages of type ClientConnect. Mark the connection fully connected and notify that a client connected or reconnected
Message from the client about the connection
ClientId of the client who is sending this ClientConnect message
-Private
handleFunction that handles incoming webSocket messages of type Event. Runs the eventHandler provided +
Private
handleFunction that handles incoming webSocket messages of type Event. Runs the eventHandler provided in connect() and forwards the event to other clients
Event message to handle
-Private
handleFunction that handles incoming webSocket messages and locally sent messages of type Request. +
Private
handleFunction that handles incoming webSocket messages and locally sent messages of type Request. Handles the request and sends a response if we have a handler or forwards to the appropriate client
Request to handle
Who sent this message
-Private
handleFunction that handles webSocket messages of type Response. Resolves the request associated with +
Private
handleFunction that handles webSocket messages of type Response. Resolves the request associated with the received response message or forwards to appropriate client
Response message to resolve
Responding client
-Private
Optional
localFunction to call when we receive an event. Handles events from connections and emits the event +
Private
Optional
localFunction to call when we receive an event. Handles events from connections and emits the event locally
-Private
Optional
localFunction to call when we receive a request that is registered on this connector. Handles +
Private
Optional
localFunction to call when we receive a request that is registered on this connector. Handles requests from connections and returns a response to send back
-Private
messageAll message subscriptions - emitters that emit an event each time a message with a specific +
Private
messageAll message subscriptions - emitters that emit an event each time a message with a specific message type comes in
-Private
Optional
networkFunctions to run when network connector events occur like when clients are disconnected
-Private
nextThe next client id to use for a new connection. Starts at 1 because the server is 0
-Notify the server that this client has received its connectorInfo and is ready to go.
+Private
Optional
networkFunctions to run when network connector events occur like when clients are disconnected
+Private
nextThe next client id to use for a new connection. Starts at 1 because the server is 0
+Notify the server that this client has received its connectorInfo and is ready to go.
MUST RUN AFTER connect() WHEN ITS PROMISE RESOLVES
TODO: Is this necessary?
-Private
onRegisters an incoming webSocket connection and sends connection info with InitClient. Does not +
Private
onRegisters an incoming webSocket connection and sends connection info with InitClient. Does not consider the client fully connected yet until they respond and tell us they connected with ClientConnect
-Private
onHandles when client connection disconnects. Unregisters and such
-Private
onReceives and appropriately publishes webSocket messages
+Private
onHandles when client connection disconnects. Unregisters and such
+Private
onReceives and appropriately publishes webSocket messages
WebSocket message information
Whether this message is from this connector instead of from someone else
-Send a request to the server/a client and resolve after receiving a response
-The type of request
+Send a request to the server/a client and resolve after receiving a response
+The type of request
Contents to send in the request
Promise that resolves with the response message
-Private
Optional
requestFunction to call when we are sending a request. Returns a clientId to which to send the request +
Private
Optional
requestFunction to call when we are sending a request. Returns a clientId to which to send the request based on the requestType
-Private
requestsAll requests that are waiting for a response
-Private
sendSend a message to a client via webSocket. Throws if not connected
+Private
requestsAll requests that are waiting for a response
+Private
sendSend a message to a client via webSocket. Throws if not connected
Message to send
The client to which to send the message. TODO: determine if we can intuit this instead
-Private
subscribeSubscribes a function to run on webSocket messages of a particular type
+Private
subscribeSubscribes a function to run on webSocket messages of a particular type
The type of message on which to subscribe the function
Function to run with the contents of the webSocket message
Unsubscriber function to run to stop calling the passed-in function on webSocket messages
-Private
Optional
unsubscribeFunction that removes this clientConnect handler from connections
-Private
Optional
unsubscribeFunction that removes this handleEvent from the connection
-Private
Optional
unsubscribeFunction that removes this handleRequest from connections
-Private
Optional
unsubscribeFunction that removes this response handler from connections
-Private
Optional
webThe webSocket connected to the server
-Generated using TypeDoc
Private
Optional
unsubscribeFunction that removes this clientConnect handler from connections
+Private
Optional
unsubscribeFunction that removes this handleEvent from the connection
+Private
Optional
unsubscribeFunction that removes this handleRequest from connections
+Private
Optional
unsubscribeFunction that removes this response handler from connections
+Private
Optional
webThe webSocket connected to the server
+Execution tokens can be passed into API calls to provide context about their identity
-Readonly
nameReadonly
nonceReadonly
typeGenerated using TypeDoc
Execution tokens can be passed into API calls to provide context about their identity
+Readonly
nameReadonly
nonceReadonly
typeThis wraps the browser's WebSocket implementation to provide +
This wraps the browser's WebSocket implementation to provide better control over internet access. It is isomorphic with the standard WebSocket, so it should act as a drop-in replacement.
Note that the Node WebSocket implementation is different and not wrapped here.
-Optional
protocols: string | string[]Readonly
CLOSEDReadonly
CLOSINGReadonly
CONNECTINGReadonly
OPENOptional
code: numberOptional
reason: stringGenerated using TypeDoc
Optional
protocols: string | string[]Readonly
CLOSEDReadonly
CLOSINGReadonly
CONNECTINGReadonly
OPENOptional
code: numberOptional
reason: stringThis wraps the browser's XMLHttpRequest implementation to +
This wraps the browser's XMLHttpRequest implementation to provide better control over internet access. It is isomorphic with the standard XMLHttpRequest, so it should act as a drop-in replacement.
Note that Node doesn't have a native implementation, so this is only for the renderer.
-Readonly
DONEReadonly
HEADERS_Readonly
LOADINGReadonly
OPENEDReadonly
UNSENTOptional
async: booleanOptional
username: null | stringOptional
password: null | stringOptional
body: null | Document | XMLHttpRequestBodyInitGenerated using TypeDoc
Readonly
DONEReadonly
HEADERS_Readonly
LOADINGReadonly
OPENEDReadonly
UNSENTOptional
async: booleanOptional
username: null | stringOptional
password: null | stringOptional
body: null | Document | XMLHttpRequestBodyInitAbstract
Abstract class that provides a placeholder notifyUpdate
for data provider engine classes. If a
+
Abstract
Abstract class that provides a placeholder notifyUpdate
for data provider engine classes. If a
data provider engine class extends this class, it doesn't have to specify its own notifyUpdate
function in order to use notifyUpdate
.
IDataProviderEngine for more information on extending this class.
-Optional
updateInstructions: DataProviderUpdateInstructions<TDataTypes>Generated using TypeDoc
Optional
updateInstructions: DataProviderUpdateInstructions<TDataTypes>Networked version of EventEmitter - accepts subscriptions to an event and runs the subscription +
Networked version of EventEmitter - accepts subscriptions to an event and runs the subscription callbacks when the event is emitted. Events on NetworkEventEmitters can be emitted across processes. They are coordinated between processes by their type. Use eventEmitter.event(callback) to subscribe to the event. Use eventEmitter.emit(event) to run the subscriptions. Generally, this @@ -7,36 +7,36 @@
WARNING: Do not use this class directly outside of NetworkService, or it will not do what you expect. Use NetworkService.createNetworkEventEmitter.
WARNING: You cannot emit events with complex types on the network.
-Creates a NetworkEventEmitter
-Callback that accepts the event and emits it to other processes
-Callback that unlinks this emitter from the network
-Private
networkCallback that runs when the emitter is disposed - should handle unlinking from the network
-Private
networkCallback that sends the event to other processes on the network when it is emitted
-Subscribes a function to run when this event is emitted.
+Creates a NetworkEventEmitter
+Callback that accepts the event and emits it to other processes
+Callback that unlinks this emitter from the network
+Private
networkCallback that runs when the emitter is disposed - should handle unlinking from the network
+Private
networkCallback that sends the event to other processes on the network when it is emitted
+Subscribes a function to run when this event is emitted.
Function to run with the event when it is emitted
Unsubscriber function to run to stop calling the passed-in function when the event is emitted
event
-Event for listeners to subscribe to. Subscribes a function to run when this event is emitted. +
Event for listeners to subscribe to. Subscribes a function to run when this event is emitted.
Use like const unsubscriber = event(callback)
Unsubscriber function to run to stop calling the passed-in function when the event is emitted
-Protected
assertProtected
disposeDisposes of this event, preparing it to release from memory. Added here so children can +
Protected
assertProtected
disposeProtected
emitProtected
emitFunction that runs the subscriptions for the event. Added here so children can override emit and still call the base functionality. See NetworkEventEmitter.emit for example
-Runs only the subscriptions for the event that are on this process. Does not send over network
-Event data to provide to subscribed callbacks
-Generated using TypeDoc
Runs only the subscriptions for the event that are on this process. Does not send over network
+Event data to provide to subscribed callbacks
+Abstract
Abstract class that provides default implementations of a number of IProjectDataProvider +
Abstract
Abstract class that provides default implementations of a number of IProjectDataProvider
functions including all the Setting
and ExtensionData
-related methods. Extensions can create
their own Project Data Provider Engine classes and implement this class to meet the requirements
of MandatoryProjectDataTypes automatically by passing these calls through to the Project
@@ -8,36 +8,36 @@
If a Project Data Provider Engine class extends this class, it doesn't have to specify its own
notifyUpdate
function in order to use notifyUpdate
.
IProjectDataProviderEngine for more information on extending this class.
-Protected
constructorCreate a ProjectDataProviderEngine
instance
The project id this Project Data Provider represents for which it serves data
-Protected
Readonly
projectProtected
Readonly
projectProtected
Readonly
projectPrivate
psiPrivate
psiProtected
constructorCreate a ProjectDataProviderEngine
instance
The project id this Project Data Provider represents for which it serves data
+Protected
Readonly
projectProtected
Readonly
projectProtected
Readonly
projectPrivate
psiPrivate
psiProtected
getGet the ProjectStorageExtensionDataScope for this project for the specified +
Protected
getGet the ProjectStorageExtensionDataScope for this project for the specified
ExtensionDataScope. This can be used when passing ExtensionData
-related calls to the
Project Storage Interpreter.
Information about what data is being referenced by the calling extension given +
Information about what data is being referenced by the calling extension given to this Project Data Provider
Information about what data is being referenced by the calling extension that this Project Data Provider should give to its Project Storage Interpreter
-Protected
getGet the ProjectStorageSettingDataScope for this project for the specified project +
Protected
getGet the ProjectStorageSettingDataScope for this project for the specified project setting. This can be used when passing setting-related calls to the Project Storage Interpreter.
-The string id of the project setting to get a setting data scope for
+The string id of the project setting to get a setting data scope for
ProjectStorageSettingDataScope
for this project for the specified project setting
Optional
updateInstructions: DataProviderUpdateInstructions<ProjectDataTypes[ProjectType] & { Generated using TypeDoc
Optional
updateInstructions: DataProviderUpdateInstructions<ProjectDataTypes[ProjectType] & { Generated using TypeDoc
Whether this connector is setting up or has finished setting up its connection and is ready to +
Whether this connector is setting up or has finished setting up its connection and is ready to communicate on the network
-This connector has finished setting up its connection - has connectorInfo and such
-This connector is attempting to connect to the network and retrieve connectorInfo
-This connector is not connected to the network
-Generated using TypeDoc
This connector has finished setting up its connection - has connectorInfo and such
+This connector is attempting to connect to the network and retrieve connectorInfo
+This connector is not connected to the network
+Generated using TypeDoc
Generated using TypeDoc
The type of code that defines a webview's content
-This webview is a raw HTML/JS/CSS webview.
-This webview is a React webview. It must specify its component by setting it to +
The type of code that defines a webview's content
+This webview is a raw HTML/JS/CSS webview.
+This webview is a React webview. It must specify its component by setting it to
globalThis.webViewComponent
This webview's content is fetched from the url specified (iframe src
attribute). Note that
+
This webview's content is fetched from the url specified (iframe src
attribute). Note that
webViews of this type cannot access the papi
because they cannot be on the same origin as the
parent window.
Generated using TypeDoc
Generated using TypeDoc
This is just an alias for internet.fetch
-Optional
init: RequestInitThis is just an alias for internet.fetch
-Optional
init: RequestInitGenerated using TypeDoc
This is just an alias for internet.fetch
+Optional
init: RequestInitThis is just an alias for internet.fetch
+Optional
init: RequestInitThis is just an alias for internet.fetch
-Optional
init: RequestInitThis is just an alias for internet.fetch
-Optional
init: RequestInitGenerated using TypeDoc
This is just an alias for internet.fetch
+Optional
init: RequestInitThis is just an alias for internet.fetch
+Optional
init: RequestInitGenerated using TypeDoc
Optional
options: DuplexOptionsGenerated using TypeDoc
Optional
options: DuplexOptionsGenerated using TypeDoc
This is only intended to be called by the extension service. This service cannot call into the +
Generated using TypeDoc
Copies a file from one location to another. Creates the path to the destination if it does not +
Copies a file from one location to another. Creates the path to the destination if it does not exist
-The location of the file to copy
-The uri to the file to create as a copy of the source file
-Optional
mode: numberBitwise modifiers that affect how the copy works. See +
The location of the file to copy
+The uri to the file to create as a copy of the source file
+Optional
mode: numberBitwise modifiers that affect how the copy works. See
fsPromises.copyFile
for
more information
Generated using TypeDoc
Create a directory in the file system if it does not exist. Does not throw if it already exists.
-Remove a directory and all its contents recursively from the file system
-Delete a file if it exists
-Get stats about the file or directory. Note that BigInts are used instead of ints to avoid. +
Get stats about the file or directory. Note that BigInts are used instead of ints to avoid. https://en.wikipedia.org/wiki/Year_2038_problem
-URI of file or directory
+URI of file or directory
Promise that resolves to object of type https://nodejs.org/api/fs.html#class-fsstats if file or directory exists, undefined if it doesn't
-Generated using TypeDoc
Reads a directory and returns lists of entries in the directory by entry type.
-URI of directory.
-Optional
entryFilter: ((entryName) => boolean)Function to filter out entries in the directory based on their names.
-Map of entry type to list of uris for each entry in the directory with that type.
-Generated using TypeDoc
Reads a directory and returns lists of entries in the directory by entry type.
+URI of directory.
+Optional
entryFilter: ((entryName) => boolean)Function to filter out entries in the directory based on their names.
+Map of entry type to list of uris for each entry in the directory with that type.
+Read a binary file
-Read a text file
-Generated using TypeDoc
Write data to a file
-URI of file
-String or Buffer to write into the file
+Generated using TypeDoc
Create a cryptographically secure nonce that is at least 128 bits long. See nonce spec at +
Create a cryptographically secure nonce that is at least 128 bits long. See nonce spec at https://w3c.github.io/webappsec-csp/#security-nonces
-Optional
numberOfBytes: numberCryptographically secure, pseudo-randomly generated value encoded as a string
-Generated using TypeDoc
Optional
numberOfBytes: numberCryptographically secure, pseudo-randomly generated value encoded as a string
+Generated using TypeDoc
Gets the platform-specific user Platform.Bible folder for this application
+Generated using TypeDoc
Rest
...args: []Resolves the uri to a path
-Combines the uri passed in with the paths passed in to make one uri
-Uri to start from
-Rest
...paths: string[]Paths to combine into the uri
+Generated using TypeDoc
Generated using TypeDoc
Set the functionality of submitting and canceling dialogs. This should be called specifically by +
Set the functionality of submitting and canceling dialogs. This should be called specifically by
dialog.service-host.ts
immediately on startup and by nothing else. This is only here to
mitigate a dependency cycle
Functions from the dialog service host for resolving and rejecting +
Functions from the dialog service host for resolving and rejecting dialogs
-Generated using TypeDoc
Create a useData(...).DataType(selector, defaultValue, options)
hook for a specific subset of
+
Create a useData(...).DataType(selector, defaultValue, options)
hook for a specific subset of
data providers as supported by useDataProviderHook
Hook that gets a data provider from a specific subset of data +
Hook that gets a data provider from a specific subset of data providers
-Rest
...args: TUseDataProviderParamsuseData
hook for getting data from a data provider
Generated using TypeDoc
Rest
...args: TUseDataProviderParamsuseData
hook for getting data from a data provider
This function takes in a getNetworkObject function and creates a hook with that function in it +
This function takes in a getNetworkObject function and creates a hook with that function in it which will return a network object
-A function that takes in an id string and returns a network object
-Rest
...args: THookParamsOptional
mapParametersToNetworkObjectSource: ((...args) => undefined | string | NetworkObject<object>)Function that takes the parameters passed into the hook +
A function that takes in an id string and returns a network object
+Rest
...args: THookParamsOptional
mapParametersToNetworkObjectSource: ((...args) => undefined | string | NetworkObject<object>)Function that takes the parameters passed into the hook
and returns the networkObjectSource
associated with those parameters. Defaults to taking the
first parameter passed into the hook and using that as the networkObjectSource
.
networkObjectSource
is string name of the network object to get OR networkObject
(result of this hook, if you want this hook to just return the network object again)Rest
...args: THookParamsA function that takes in a networkObjectSource and returns a NetworkObject
-Rest
...args: THookParamsGenerated using TypeDoc
Rest
...args: THookParamsA function that takes in a networkObjectSource and returns a NetworkObject
+Rest
...args: THookParamsuseData<DataProviderName extends DataProviderNames>(
dataProviderSource: DataProviderName | DataProviders[DataProviderName] | undefined,
).DataType(
selector: DataProviderTypes[DataProviderName][DataType]['selector'],
defaultValue: DataProviderTypes[DataProviderName][DataType]['getData'],
subscriberOptions?: DataProviderSubscriberOptions,
) => [
DataProviderTypes[DataProviderName][DataType]['getData'],
(
| ((
newData: DataProviderTypes[DataProviderName][DataType]['setData'],
) => Promise<DataProviderUpdateInstructions<DataProviderTypes[DataProviderName]>>)
| undefined
),
boolean,
]
+default | papi-dts Function default
- default<DataProviderName>(dataProviderSource): {
[TDataType in string | number | symbol]: ((selector, defaultValue, subscriberOptions?) => [DataProviderTypes[DataProviderName][TDataType]["getData"], undefined | ((newData) => Promise<DataProviderUpdateInstructions<DataProviderTypes[DataProviderName]>>), boolean])
} useData<DataProviderName extends DataProviderNames>(
dataProviderSource: DataProviderName | DataProviders[DataProviderName] | undefined,
).DataType(
selector: DataProviderTypes[DataProviderName][DataType]['selector'],
defaultValue: DataProviderTypes[DataProviderName][DataType]['getData'],
subscriberOptions?: DataProviderSubscriberOptions,
) => [
DataProviderTypes[DataProviderName][DataType]['getData'],
(
| ((
newData: DataProviderTypes[DataProviderName][DataType]['setData'],
) => Promise<DataProviderUpdateInstructions<DataProviderTypes[DataProviderName]>>)
| undefined
),
boolean,
]
React hook to use data from a data provider. Subscribes to run a callback on a data provider's
data with specified selector on the specified data type that data provider serves.
@@ -29,4 +29,4 @@
isLoading
: whether the data with the data type and selector is awaiting retrieval from the data
provider
-Type Parameters
Parameters
dataProviderSource: undefined | DataProviderName | DataProviders[DataProviderName]
Returns {
[TDataType in string | number | symbol]: ((selector, defaultValue, subscriberOptions?) => [DataProviderTypes[DataProviderName][TDataType]["getData"], undefined | ((newData) => Promise<DataProviderUpdateInstructions<DataProviderTypes[DataProviderName]>>), boolean])
}
Generated using TypeDoc
\ No newline at end of file
+
Gets a data provider with specified provider name
-String name of the data provider to get OR dataProvider (result of +
Gets a data provider with specified provider name
+String name of the data provider to get OR dataProvider (result of useDataProvider, if you want this hook to just return the data provider again)
Undefined if the data provider has not been retrieved, data provider if it has been retrieved and is not disposed, and undefined again if the data provider is disposed
-Generated using TypeDoc
Gets an array of data providers based on an array of input sources
-Array containing string names of the data providers to get OR data +
Gets an array of data providers based on an array of input sources
+Array containing string names of the data providers to get OR data providers themselves (i.e., the results of useDataProvider/useDataProviderMulti) if you want this hook to return the data providers again. It is fine to have a mix of strings and data providers in the array.
@@ -9,4 +9,4 @@dataProviderSources
. Each item in the array will be (a) undefined if the data provider has
not been retrieved or has been disposed, or (b) a data provider if it has been retrieved and is
not disposed.
-Generated using TypeDoc
Enables using papi.dialogs.showDialog
in React more easily. Returns a callback to run that will
+
Enables using papi.dialogs.showDialog
in React more easily. Returns a callback to run that will
open a dialog with the provided dialogType
and options
then run the resolveCallback
with
the dialog response or rejectCallback
if there is an error. By default, only one dialog can be
open at a time.
options.shouldOpenMultipleDialogs
to true
and add a counter to the options
when calling the
callback. Then resolveCallback
will be resolved with that options object including your
counter.
-Dialog type you want to show on the screen
+Dialog type you want to show on the screen
Note: this parameter is internally assigned to a ref
, so changing it will not cause any hooks
to re-run with its new value. This means that updating this parameter will not cause a new
callback to be returned. However, because of the nature of calling dialogs, this has no adverse
effect on the functionality of this hook. Calling the callback will always use the latest
dialogType
.
Various options for configuring the dialog that shows and this hook. If an +
Various options for configuring the dialog that shows and this hook. If an
options
parameter is also provided to the returned showDialog
callback, those
callback-provided options
merge over these hook-provided options
Note: this parameter is internally assigned to a ref
, so changing it will not cause any hooks
@@ -20,7 +20,7 @@
callback to be returned. However, because of the nature of calling dialogs, this has no adverse
effect on the functionality of this hook. Calling the callback will always use the latest
options
.
(response, dialogType, options)
The function that will be called if the
+
(response, dialogType, options)
The function that will be called if the
dialog request resolves properly
response
- the resolved value of the dialog call. Either the user's response or undefined
if
@@ -36,7 +36,7 @@
callback to be returned. However, because of the nature of calling dialogs, this has no adverse
effect on the functionality of this hook. When the dialog resolves, it will always call the
latest resolveCallback
.
-(error, dialogType, options)
The function that will be called if the
+
(error, dialogType, options)
The function that will be called if the
dialog request throws an error
error
- the error thrown while calling the dialogrejectCallback
.
-showDialog(options?)
- callback to run to show the dialog to prompt the user for a
+
showDialog(options?)
- callback to run to show the dialog to prompt the user for a
response
optionsOverrides?
- options
object you may specify that will merge over the options
you
@@ -59,7 +59,7 @@
specify as many or as few properties here as you want to overwrite the properties in the
options
you provide to the hookOptional
optionOverrides: Partial<DialogOptions & UseDialogCallbackOptions>Enables using papi.dialogs.showDialog
in React more easily. Returns a callback to run that will
+
Optional
optionOverrides: Partial<DialogOptions & UseDialogCallbackOptions>Enables using papi.dialogs.showDialog
in React more easily. Returns a callback to run that will
open a dialog with the provided dialogType
and options
then run the resolveCallback
with
the dialog response or rejectCallback
if there is an error. By default, only one dialog can be
open at a time.
options.shouldOpenMultipleDialogs
to true
and add a counter to the options
when calling the
callback. Then resolveCallback
will be resolved with that options object including your
counter.
-Dialog type you want to show on the screen
+Dialog type you want to show on the screen
Note: this parameter is internally assigned to a ref
, so changing it will not cause any hooks
to re-run with its new value. This means that updating this parameter will not cause a new
callback to be returned. However, because of the nature of calling dialogs, this has no adverse
effect on the functionality of this hook. Calling the callback will always use the latest
dialogType
.
Various options for configuring the dialog that shows and this hook. If an +
Various options for configuring the dialog that shows and this hook. If an
options
parameter is also provided to the returned showDialog
callback, those
callback-provided options
merge over these hook-provided options
Note: this parameter is internally assigned to a ref
, so changing it will not cause any hooks
@@ -81,7 +81,7 @@
callback to be returned. However, because of the nature of calling dialogs, this has no adverse
effect on the functionality of this hook. Calling the callback will always use the latest
options
.
(response, dialogType, options)
The function that will be called if the
+
(response, dialogType, options)
The function that will be called if the
dialog request resolves properly
response
- the resolved value of the dialog call. Either the user's response or undefined
if
@@ -97,7 +97,7 @@
callback to be returned. However, because of the nature of calling dialogs, this has no adverse
effect on the functionality of this hook. When the dialog resolves, it will always call the
latest resolveCallback
.
-showDialog(options?)
- callback to run to show the dialog to prompt the user for a
+
showDialog(options?)
- callback to run to show the dialog to prompt the user for a
response
optionsOverrides?
- options
object you may specify that will merge over the options
you
@@ -105,4 +105,4 @@
specify as many or as few properties here as you want to overwrite the properties in the
options
you provide to the hookOptional
optionOverrides: Partial<DialogOptions & UseDialogCallbackOptions>Generated using TypeDoc
Optional
optionOverrides: Partial<DialogOptions & UseDialogCallbackOptions>useProjectData<ProjectType extends ProjectTypes>(
projectType: ProjectType,
projectDataProviderSource: string | ProjectDataProviders[ProjectType] | undefined,
).DataType(
selector: ProjectDataTypes[ProjectType][DataType]['selector'],
defaultValue: ProjectDataTypes[ProjectType][DataType]['getData'],
subscriberOptions?: DataProviderSubscriberOptions,
) => [
ProjectDataTypes[ProjectType][DataType]['getData'],
(
| ((
newData: ProjectDataTypes[ProjectType][DataType]['setData'],
) => Promise<DataProviderUpdateInstructions<ProjectDataTypes[ProjectType]>>)
| undefined
),
boolean,
]
+default | papi-dts Function default
- default<ProjectType>(projectType, projectDataProviderSource): {
[TDataType in string | number | symbol]: ((selector, defaultValue, subscriberOptions?) => [ProjectDataTypes[ProjectType][TDataType]["getData"], undefined | ((newData) => Promise<DataProviderUpdateInstructions<ProjectDataTypes[ProjectType]>>), boolean])
} useProjectData<ProjectType extends ProjectTypes>(
projectType: ProjectType,
projectDataProviderSource: string | ProjectDataProviders[ProjectType] | undefined,
).DataType(
selector: ProjectDataTypes[ProjectType][DataType]['selector'],
defaultValue: ProjectDataTypes[ProjectType][DataType]['getData'],
subscriberOptions?: DataProviderSubscriberOptions,
) => [
ProjectDataTypes[ProjectType][DataType]['getData'],
(
| ((
newData: ProjectDataTypes[ProjectType][DataType]['setData'],
) => Promise<DataProviderUpdateInstructions<ProjectDataTypes[ProjectType]>>)
| undefined
),
boolean,
]
React hook to use data from a Project Data Provider. Subscribes to run a callback on a Project
Data Provider's data with specified selector on the specified data type that the Project Data
@@ -37,4 +37,4 @@
isLoading
: whether the data with the data type and selector is awaiting retrieval from the data
provider
-Type Parameters
ProjectType extends keyof ProjectDataProviders
Parameters
projectType: ProjectType
projectDataProviderSource: undefined | string | ProjectDataProviders[ProjectType]
Returns {
[TDataType in string | number | symbol]: ((selector, defaultValue, subscriberOptions?) => [ProjectDataTypes[ProjectType][TDataType]["getData"], undefined | ((newData) => Promise<DataProviderUpdateInstructions<ProjectDataTypes[ProjectType]>>), boolean])
}
Generated using TypeDoc
\ No newline at end of file
+
Gets a project data provider with specified provider name
-Indicates what you expect the projectType
to be for the project with the
+
Gets a project data provider with specified provider name
+Indicates what you expect the projectType
to be for the project with the
specified id. The TypeScript type for the returned Project Data Provider will have the Project
Data Provider type associated with this projectType
. If this argument does not match the
project's actual projectType
(according to its metadata), a warning will be logged
String name of the id of the project to get OR +
String name of the id of the project to get OR projectDataProvider (result of useProjectDataProvider, if you want this hook to just return the data provider again)
undefined
if the Project Data Provider has not been retrieved, the requested Project
Data Provider if it has been retrieved and is not disposed, and undefined again if the Project
Data Provider is disposed
Generated using TypeDoc
Gets, sets and resets a project setting on the papi for a specified project. Also notifies +
Gets, sets and resets a project setting on the papi for a specified project. Also notifies subscribers when the project setting changes and gets updated when the project setting is changed by others.
-Indicates what you expect the projectType
to be for the project with the
+
Indicates what you expect the projectType
to be for the project with the
specified id. The TypeScript type for the returned Project Data Provider will have the Project
Data Provider type associated with this projectType
. If this argument does not match the
project's actual projectType
(according to its metadata), a warning will be logged
projectDataProviderSource
String name of the id of the project
+
projectDataProviderSource
String name of the id of the project
to get OR projectDataProvider (result of useProjectDataProvider
if you want to consolidate
and only get the Project Data Provider once)
The string id of the project setting to interact with
+The string id of the project setting to interact with
WARNING: MUST BE STABLE - const or wrapped in useState, useMemo, etc. The reference must not be updated every render
-The initial value to return while first awaiting the project setting value
-Optional
subscriberOptions: DataProviderSubscriberOptionsVarious options to adjust how the subscriber emits updates
+The initial value to return while first awaiting the project setting value
+Optional
subscriberOptions: DataProviderSubscriberOptionsVarious options to adjust how the subscriber emits updates
Note: this parameter is internally assigned to a ref
, so changing it will not cause any hooks
to re-run with its new value. This means that subscriberOptions
will be passed to the data
provider's subscribe<data_type>
method as soon as possible and will not be updated again
@@ -31,4 +31,4 @@
When subscription callback function is called with an update that has an unexpected message type
-Generated using TypeDoc
Gets, sets and resets a setting on the papi. Also notifies subscribers when the setting changes +
Gets, sets and resets a setting on the papi. Also notifies subscribers when the setting changes and gets updated when the setting is changed by others.
-The string id that is used to identify the setting that will be stored on the papi
+The string id that is used to identify the setting that will be stored on the papi
WARNING: MUST BE STABLE - const or wrapped in useState, useMemo, etc. The reference must not be updated every render
-The initial value to return while first awaiting the setting value
-Optional
subscriberOptions: DataProviderSubscriberOptionsVarious options to adjust how the subscriber emits updates
+The initial value to return while first awaiting the setting value
+Optional
subscriberOptions: DataProviderSubscriberOptionsVarious options to adjust how the subscriber emits updates
Note: this parameter is internally assigned to a ref
, so changing it will not cause any hooks
to re-run with its new value. This means that subscriberOptions
will be passed to the data
provider's subscribe<data_type>
method as soon as possible and will not be updated again
@@ -18,4 +18,4 @@
When subscription callback function is called with an update that has an unexpected message type
-Generated using TypeDoc
Generated using TypeDoc
Get the data type for a data provider function based on its name
-Name of data provider function e.g. getVerse
Get the data type for a data provider function based on its name
+Name of data provider function e.g. getVerse
Data type for that data provider function e.g. Verse
Generated using TypeDoc
Generated using TypeDoc
Creates a function that is a command function with a baked commandName. This is also nice because +
Creates a function that is a command function with a baked commandName. This is also nice because you get TypeScript type support using this function.
-Command name for command function
+Command name for command function
Function to call with arguments of command that sends the command and resolves with the result of the command
-Rest
...args: Parameters<CommandHandlers[CommandName]>Generated using TypeDoc
Rest
...args: Parameters<CommandHandlers[CommandName]>Generated using TypeDoc
Register a command on the papi to be handled here
-Command name to register for handling here
+Register a command on the papi to be handled here
+Command name to register for handling here
Function to run when the command is invoked
+Function to run when the command is invoked
True if successfully registered, throws with error message if not
-Generated using TypeDoc
Send a command to the backend.
-Rest
...args: Parameters<CommandHandlers[CommandName]>Generated using TypeDoc
Send a command to the backend.
+Rest
...args: Parameters<CommandHandlers[CommandName]>Generated using TypeDoc
Sets up the ConnectionService by connecting to the server and setting up event handlers
-Function that handles requests from the server by accepting a +
Sets up the ConnectionService by connecting to the server and setting up event handlers
+Function that handles requests from the server by accepting a requestType and a ComplexRequest and returning a Promise of a Complex Response
-Function that determines the appropriate clientId to which to send +
Function that determines the appropriate clientId to which to send requests of the given type
-Function that handles events from the server by accepting an eventType +
Function that handles events from the server by accepting an eventType and an event and emitting the event locally
-Functions that run when network connector events occur like when +
Functions that run when network connector events occur like when clients are disconnected
Promise that resolves when finished connecting
-Generated using TypeDoc
Generated using TypeDoc
Sends an event to other processes. Does NOT run the local event subscriptions as they should be +
Sends an event to other processes. Does NOT run the local event subscriptions as they should be run by NetworkEventEmitter after sending on network.
-Unique network event type for coordinating between processes
-Event to emit on the network
-Generated using TypeDoc
Unique network event type for coordinating between processes
+Event to emit on the network
+Generated using TypeDoc
Send a request to the server and resolve after receiving a response
-The type of request
-Contents to send in the request
+Send a request to the server and resolve after receiving a response
+The type of request
+Contents to send in the request
Promise that resolves with the response message
-Generated using TypeDoc
Get a data provider that has previously been set up
-Name of the desired data provider
+Get a data provider that has previously been set up
+Name of the desired data provider
The data provider with the given name if one exists, undefined otherwise
-Generated using TypeDoc
Creates a data provider to be shared on the network layering over the provided data provider +
Creates a data provider to be shared on the network layering over the provided data provider engine.
-Name this data provider should be called on the network
-The object to layer over with a new data provider object
-Optional
dataProviderType: stringString to send in a network event to clarify what type of data provider +
Name this data provider should be called on the network
+The object to layer over with a new data provider object
+Optional
dataProviderType: stringString to send in a network event to clarify what type of data provider
is represented by this engine. For generic data providers, the default value of dataProvider
can be used. For data provider types that have multiple instances (e.g., project data
providers), a unique type name should be used to distinguish from generic data providers.
Optional
dataProviderAttributes: { Optional object that will be sent in a network event to provide +
Optional
dataProviderAttributes: { Optional object that will be sent in a network event to provide additional metadata about the data provider represented by this engine.
WARNING: registering a dataProviderEngine mutates the provided object. Its notifyUpdate
and
set
methods are layered over to facilitate data provider subscriptions.
The data provider including control over disposing of it. Note that this data provider is a new object distinct from the data provider engine passed in.
-Generated using TypeDoc
Format a string of a service message
-Message from the service
-Name of the service to show in the log
-Optional
tag: stringOptional tag at the end of the service name
+Format a string of a service message
+Message from the service
+Name of the service to show in the log
+Optional
tag: stringOptional tag at the end of the service name
Formatted string of a service message
-Generated using TypeDoc
Creates a NetworkConnector for the client or the server depending on where you're running
+Creates a NetworkConnector for the client or the server depending on where you're running
NetworkConnector
-Generated using TypeDoc
Event that fires when a new object has been created on the network (locally or remotely). The +
Event that fires when a new object has been created on the network (locally or remotely). The event contains information about the new network object.
-Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Creates an event emitter that works properly over the network. Other connections receive this +
Creates an event emitter that works properly over the network. Other connections receive this event when it is emitted.
WARNING: You can only create a network event emitter once per eventType to prevent hijacked event emitters.
WARNING: You cannot emit events with complex types on the network.
-Unique network event type for coordinating between connections
+Unique network event type for coordinating between connections
Event emitter whose event works between connections
-Generated using TypeDoc
Creates a function that is a request function with a baked requestType. This is also nice because +
Creates a function that is a request function with a baked requestType. This is also nice because you get TypeScript type support using this function.
-RequestType for request function
+RequestType for request function
Function to call with arguments of request that performs the request and resolves with the response contents
-Generated using TypeDoc
Gets the network event with the specified type. Creates the emitter if it does not exist
-Unique network event type for coordinating between connections
+Gets the network event with the specified type. Creates the emitter if it does not exist
+Unique network event type for coordinating between connections
Event for the event type that runs the callback provided when the event is emitted
-Generated using TypeDoc
Generated using TypeDoc
Event that emits with clientId when a client connects
-Generated using TypeDoc
Event that emits with clientId when a client connects
+Event that emits with clientId when a client disconnects
-Generated using TypeDoc
Event that emits with clientId when a client disconnects
+Register a local request handler to run on requests.
-The type of request on which to register the handler
-Function to register to run on requests
-Optional
handlerType: RequestHandlerTypeType of handler function - indicates what type of parameters and what return +
Register a local request handler to run on requests.
+The type of request on which to register the handler
+Function to register to run on requests
+Optional
handlerType: RequestHandlerTypeType of handler function - indicates what type of parameters and what return type the handler has
Promise that resolves if the request successfully registered and unsubscriber function to run to stop the passed-in function from handling requests
-Optional
handlerType: RequestHandlerTypeOptional
handlerType: RequestHandlerTypeGenerated using TypeDoc
Optional
handlerType: RequestHandlerTypeOptional
handlerType: RequestHandlerTypeSend a request on the network and resolve the response contents.
-The type of request
-Rest
...args: TParamArguments to send in the request (put in request.contents)
+Send a request on the network and resolve the response contents.
+The type of request
+Rest
...args: TParamArguments to send in the request (put in request.contents)
Promise that resolves with the response message
-Generated using TypeDoc
Generated using TypeDoc
Get a Project Data Provider for the given project ID.
-Indicates what you expect the projectType
to be for the project with the
+
Get a Project Data Provider for the given project ID.
+Indicates what you expect the projectType
to be for the project with the
specified id. The TypeScript type for the returned project data provider will have the project
data provider type associated with this project type. If this argument does not match the
project's actual projectType
(according to its metadata), a warning will be logged
ID for the project to load
+ID for the project to load
Data provider with types that are associated with the given project type
const pdp = await get('ParatextStandard', 'ProjectID12345');
pdp.getVerse(new VerseRef('JHN', '1', '1'));
-Generated using TypeDoc
Add a new Project Data Provider Factory to PAPI that uses the given engine. There must not be an +
Add a new Project Data Provider Factory to PAPI that uses the given engine. There must not be an existing factory already that handles the same project type or this operation will fail.
-Type of project that pdpEngineFactory supports
-Used in a ProjectDataProviderFactory to create ProjectDataProviders
+Type of project that pdpEngineFactory supports
+Used in a ProjectDataProviderFactory to create ProjectDataProviders
Promise that resolves to a disposable object when the registration operation completes
-Generated using TypeDoc
Generated using TypeDoc
Gets which kind of process this is (main, renderer, extension-host)
+Gets which kind of process this is (main, renderer, extension-host)
ProcessType for this process
-Generated using TypeDoc
Determine if running on a client process (renderer, extension-host) or on the server.
+Generated using TypeDoc
Determine if running on the extension host
+Generated using TypeDoc
Determine if running on the renderer process
+Generated using TypeDoc
Determine if running on the server process (main)
+Generated using TypeDoc
Creates a safe version of a register function that returns a Promise
Function that does some kind of async registration and returns an +
Creates a safe version of a register function that returns a Promise
Function that does some kind of async registration and returns an unsubscriber and a promise that resolves when the registration is finished
-Rest
...args: TParamWhether the service associated with this safe UnsubscriberAsync function is +
Rest
...args: TParamWhether the service associated with this safe UnsubscriberAsync function is initialized
-Promise that resolves when the service is finished initializing
+Promise that resolves when the service is finished initializing
Safe version of an unsafe function that returns a promise to an UnsubscriberAsync (meaning it will wait to register until the service is initialized)
-Rest
...args: TParamGenerated using TypeDoc
Rest
...args: TParamSplit a request message requestType string into its parts
-Generated using TypeDoc
Split a request message requestType string into its parts
+Get a message that says the module import was rejected and to try a similar api if available.
-Name of require
d module that was rejected
Generated using TypeDoc
Create a nonce that is at least 128 bits long and should be (is not currently) cryptographically +
Create a nonce that is at least 128 bits long and should be (is not currently) cryptographically random. See nonce spec at https://w3c.github.io/webappsec-csp/#security-nonces
WARNING: THIS IS NOT CURRENTLY CRYPTOGRAPHICALLY SECURE! TODO: Make this cryptographically random! Use some polymorphic library that works in all contexts? https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues only works in browser
-Generated using TypeDoc
Create a request message requestType string from a category and a directive
-The general category of request
-Specific identifier for this type of request
+Create a request message requestType string from a category and a directive
+The general category of request
+Specific identifier for this type of request
Full requestType for use in network calls
-Generated using TypeDoc
Gets the updatable properties on this WebView's WebView definition
+Gets the updatable properties on this WebView's WebView definition
@returns updatable properties this WebView's WebView definition or undefined if not found for some reason
-Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Updates this WebView with the specified properties
+Updates this WebView with the specified properties
@param updateInfo
properties to update on the WebView. Any unspecified properties will stay
the same
@returns true if successfully found the WebView to update; false otherwise
@example
updateWebViewDefinition({ title: `Hello ${name}` });
-Generated using TypeDoc
Generated using TypeDoc
A React hook for working with a state object tied to a webview. Returns a WebView state value and +
A React hook for working with a state object tied to a webview. Returns a WebView state value and
a function to set it. Use similarly to useState
.
Only used in WebView iframes.
@param stateKey
Key of the state value to use. The webview state holds a unique value per
@@ -24,4 +24,4 @@
@example
const [lastPersonSeen, setLastPersonSeen] = useWebViewState('lastSeen', 'No one');
-Generated using TypeDoc
A function that each React WebView extension must provide for Paranext to display it. Only used +
A function that each React WebView extension must provide for Paranext to display it. Only used in WebView iframes.
-Optional
context: anyOptional
contextLets you specify which legacy context is consumed by +
Optional
context: anyOptional
contextLets you specify which legacy context is consumed by this component.
Optional
defaultUsed to define default values for the props accepted by +
Optional
defaultUsed to define default values for the props accepted by the component.
type Props = { name?: string }
const MyComponent: FC<Props> = (props) => {
return <div>{props.name}</div>
}
MyComponent.defaultProps = {
name: 'John Doe'
}
-Optional
displayUsed in debugging messages. You might want to set it +
Optional
displayUsed in debugging messages. You might want to set it explicitly if you want to display a different name for debugging purposes.
const MyComponent: FC = () => {
return <div>Hello!</div>
}
MyComponent.displayName = 'MyAwesomeComponent'
-Optional
propUsed to declare the types of the props accepted by the +
Optional
propUsed to declare the types of the props accepted by the component. These types will be checked during rendering and in development only.
We recommend using TypeScript instead of checking prop types at runtime.
Generated using TypeDoc
Generated using TypeDoc
Type declarations provided for use in Platform.Bible extensions
+Type declarations provided for use in Platform.Bible extensions
This is a types package that provides type declarations for papi
and other important interfaces through which extensions interact with Platform.Bible.
The documentation includes a variety of types to support different aspects of the project. For extension development, the most crucial sections to focus on are:
paranext-core
.npm install
in paranext-core
) In paranext-core/lib/papi-dts
, run npm install
to install published dependencies.Generated using TypeDoc
Interface for all extensions to implement
-Sets up this extension! Runs when paranext wants this extension to activate. For example, +
Interface for all extensions to implement
+Sets up this extension! Runs when paranext wants this extension to activate. For example, activate() should register commands for this extension
-Sets up this extension! Runs when paranext wants this extension to activate. For example, -activate() should register commands for this extension
-Data and utilities that are specific to this particular extension
-Data and utilities that are specific to this particular extension
-Optional
deactivateDeactivate anything in this extension that is not covered by the registrations in the context +
Data and utilities that are specific to this particular extension
+Optional
deactivateDeactivate anything in this extension that is not covered by the registrations in the context object given to activate().
Promise that resolves to true if successfully deactivated
-Generated using TypeDoc
Generated using TypeDoc
Optional
ALPNCallbackIf set, this will be called when a client opens a connection using the ALPN extension. +
Optional
ALPNCallbackIf set, this will be called when a client opens a connection using the ALPN extension.
One argument will be passed to the callback: an object containing servername
and protocols
fields,
respectively containing the server name from the SNI extension (if any) and an array of
ALPN protocol name strings. The callback must return either one of the strings listed in protocols
,
@@ -45,18 +45,10 @@
to reject the connection with a fatal alert. If a string is returned that does not match one of
the client's ALPN protocols, an error will be thrown.
This option cannot be used with the ALPNProtocols
option, and setting both options will throw an error.
If set, this will be called when a client opens a connection using the ALPN extension.
-One argument will be passed to the callback: an object containing servername
and protocols
fields,
-respectively containing the server name from the SNI extension (if any) and an array of
-ALPN protocol name strings. The callback must return either one of the strings listed in protocols
,
-which will be returned to the client as the selected ALPN protocol, or undefined
,
-to reject the connection with a fatal alert. If a string is returned that does not match one of
-the client's ALPN protocols, an error will be thrown.
-This option cannot be used with the ALPNProtocols
option, and setting both options will throw an error.
Optional
agentOptional
caOptionally override the trusted CA certificates. Default is to trust +
Optional
agentOptional
caOptionally override the trusted CA certificates. Default is to trust the well-known CAs curated by Mozilla. Mozilla's CAs are completely replaced when CAs are explicitly specified using this option.
-Optional
certCert chains in PEM format. One cert chain should be provided per +
Optional
certCert chains in PEM format. One cert chain should be provided per private key. Each cert chain should consist of the PEM formatted certificate for a provided private key, followed by the PEM formatted intermediate certificates (if any), in order, and not @@ -65,26 +57,26 @@ be in the same order as their private keys in key. If the intermediate certificates are not provided, the peer will not be able to validate the certificate, and the handshake will fail.
-Optional
ciphersCipher suite specification, replacing the default. For more +
Optional
ciphersCipher suite specification, replacing the default. For more information, see modifying the default cipher suite. Permitted ciphers can be obtained via tls.getCiphers(). Cipher names must be uppercased in order for OpenSSL to accept them.
-Optional
clientName of an OpenSSL engine which can provide the client certificate.
-Optional
crlPEM formatted CRLs (Certificate Revocation Lists).
-Optional
dhparam'auto'
or custom Diffie-Hellman parameters, required for non-ECDHE perfect forward secrecy.
+
Optional
clientName of an OpenSSL engine which can provide the client certificate.
+Optional
crlPEM formatted CRLs (Certificate Revocation Lists).
+Optional
dhparam'auto'
or custom Diffie-Hellman parameters, required for non-ECDHE perfect forward secrecy.
If omitted or invalid, the parameters are silently discarded and DHE ciphers will not be available.
ECDHE-based perfect forward secrecy will still be available.
Optional
ecdhA string describing a named curve or a colon separated list of curve +
Optional
ecdhA string describing a named curve or a colon separated list of curve NIDs or names, for example P-521:P-384:P-256, to use for ECDH key agreement. Set to auto to select the curve automatically. Use crypto.getCurves() to obtain a list of available curve names. On recent releases, openssl ecparam -list_curves will also display the name and description of each available elliptic curve. Default: tls.DEFAULT_ECDH_CURVE.
-Optional
familyOptional
followOptional
handshakeOptional
headersOptional
honorAttempt to use the server's cipher suite preferences instead of the +
Optional
familyOptional
followOptional
handshakeOptional
headersOptional
honorAttempt to use the server's cipher suite preferences instead of the client's. When true, causes SSL_OP_CIPHER_SERVER_PREFERENCE to be set in secureOptions
-Optional
hostOptional
keyPrivate keys in PEM format. PEM allows the option of private keys +
Optional
hostOptional
keyPrivate keys in PEM format. PEM allows the option of private keys
being encrypted. Encrypted keys will be decrypted with
options.passphrase. Multiple keys using different algorithms can be
provided either as an array of unencrypted key strings or buffers,
@@ -92,13 +84,13 @@
passphrase:
Optional
localOptional
maxOptional
maxOptional
maxOptionally set the maximum TLS version to allow. One +
Optional
localOptional
maxOptional
maxOptional
maxOptionally set the maximum TLS version to allow. One
of 'TLSv1.3'
, 'TLSv1.2'
, 'TLSv1.1'
, or 'TLSv1'
. Cannot be specified along with the
secureProtocol
option, use one or the other.
Default: 'TLSv1.3'
, unless changed using CLI options. Using
--tls-max-v1.2
sets the default to 'TLSv1.2'
. Using --tls-max-v1.3
sets the default to
'TLSv1.3'
. If multiple of the options are provided, the highest maximum is used.
Optional
minOptionally set the minimum TLS version to allow. One +
Optional
minOptionally set the minimum TLS version to allow. One
of 'TLSv1.3'
, 'TLSv1.2'
, 'TLSv1.1'
, or 'TLSv1'
. Cannot be specified along with the
secureProtocol
option, use one or the other. It is not recommended to use
less than TLSv1.2, but it may be required for interoperability.
@@ -106,8 +98,8 @@
--tls-v1.0
sets the default to 'TLSv1'
. Using --tls-v1.1
sets the default to
'TLSv1.1'
. Using --tls-min-v1.3
sets the default to
'TLSv1.3'. If multiple of the options are provided, the lowest minimum is used.
Optional
originOptional
passphraseShared passphrase used for a single private key and/or a PFX.
-Optional
perOptional
pfxPFX or PKCS12 encoded private key and certificate chain. pfx is an +
Optional
originOptional
passphraseShared passphrase used for a single private key and/or a PFX.
+Optional
perOptional
pfxPFX or PKCS12 encoded private key and certificate chain. pfx is an
alternative to providing key and cert individually. PFX is usually
encrypted, if it is, passphrase will be used to decrypt it. Multiple
PFX can be provided either as an array of unencrypted PFX buffers,
@@ -115,15 +107,15 @@
passphrase:
Optional
privateName of an OpenSSL engine to get private key from. Should be used +
Optional
privateName of an OpenSSL engine to get private key from. Should be used together with privateKeyIdentifier.
-Optional
privateIdentifier of a private key managed by an OpenSSL engine. Should be +
Optional
privateIdentifier of a private key managed by an OpenSSL engine. Should be used together with privateKeyEngine. Should not be set together with key, because both options define a private key in different ways.
-Optional
protocolOptional
protocolOptional
rejectOptional
secureOptionally affect the OpenSSL protocol behavior, which is not +
Optional
protocolOptional
protocolOptional
rejectOptional
secureOptionally affect the OpenSSL protocol behavior, which is not usually necessary. This should be used carefully if at all! Value is a numeric bitmask of the SSL_OP_* options from OpenSSL Options
-Optional
secureLegacy mechanism to select the TLS protocol version to use, it does +
Optional
secureLegacy mechanism to select the TLS protocol version to use, it does not support independent control of the minimum and maximum version, and does not support limiting the protocol to TLSv1.3. Use minVersion and maxVersion instead. The possible values are listed as @@ -132,15 +124,15 @@ any TLS protocol version up to TLSv1.3. It is not recommended to use TLS versions less than 1.2, but it may be required for interoperability. Default: none, see minVersion.
-Optional
sessionOpaque identifier used by servers to ensure session state is not +
Optional
sessionOpaque identifier used by servers to ensure session state is not shared between applications. Unused by clients.
-Optional
sessionThe number of seconds after which a TLS session created by the +
Optional
sessionThe number of seconds after which a TLS session created by the server will no longer be resumable. See Session Resumption for more information. Default: 300.
-Optional
sigalgsColon-separated list of supported signature algorithms. The list +
Optional
sigalgsColon-separated list of supported signature algorithms. The list can contain digest algorithms (SHA256, MD5 etc.), public key algorithms (RSA-PSS, ECDSA etc.), combination of both (e.g 'RSA+SHA384') or TLS v1.3 scheme names (e.g. rsa_pss_pss_sha512).
-Optional
skipUTF8Optional
ticket48-bytes of cryptographically strong pseudo-random data. +
Optional
skipUTF8Optional
ticket48-bytes of cryptographically strong pseudo-random data. See Session Resumption for more information.
-Optional
checkOptional
generateGenerated using TypeDoc
Optional
checkOptional
generateGenerated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Generated using TypeDoc
Optional
clientOptional
clientOptional
concurrencyOptional
serverOptional
serverOptional
thresholdOptional
zlibOptional
chunkOptional
dictionary?: DataView | Buffer | Buffer[]Optional
finishOptional
flush?: numberOptional
info?: booleanOptional
level?: numberOptional
memOptional
strategy?: numberOptional
windowOptional
zlibGenerated using TypeDoc
Optional
clientOptional
clientOptional
concurrencyOptional
serverOptional
serverOptional
thresholdOptional
zlibOptional
chunkOptional
dictionary?: DataView | Buffer | Buffer[]Optional
finishOptional
flush?: numberOptional
info?: booleanOptional
level?: numberOptional
memOptional
strategy?: numberOptional
windowOptional
zlibOptional
WebOptional
backlogOptional
clientOptional
handleOptional
hostOptional
maxOptional
noOptional
pathOptional
perOptional
portOptional
serverOptional
skipUTF8Optional
verifyGenerated using TypeDoc
Optional
WebOptional
backlogOptional
clientOptional
handleOptional
hostOptional
maxOptional
noOptional
pathOptional
perOptional
portOptional
serverOptional
skipUTF8Optional
verifyReadonly
CLOSEDThe connection is closed.
-Readonly
CLOSINGThe connection is in the process of closing.
-Readonly
CONNECTINGThe connection is not yet open.
-Readonly
OPENThe connection is open and ready to communicate.
-Readonly
bufferedReadonly
extensionsReadonly
isIndicates whether the websocket is paused
-Readonly
protocolReadonly
readyThe current state of the connection
-Readonly
urlOptional
[captureRest
...args: AnyRestOptional
options: EventListenerOptionsOptional
options: EventListenerOptionsOptional
options: EventListenerOptionsOptional
options: EventListenerOptionsRest
...args: any[]Synchronously calls each of the listeners registered for the event namedeventName
, in the order they were registered, passing the supplied arguments
+
Readonly
CLOSEDThe connection is closed.
+Readonly
CLOSINGThe connection is in the process of closing.
+Readonly
CONNECTINGThe connection is not yet open.
+Readonly
OPENThe connection is open and ready to communicate.
+Readonly
bufferedReadonly
extensionsReadonly
isIndicates whether the websocket is paused
+Readonly
protocolReadonly
readyThe current state of the connection
+Readonly
urlOptional
[captureRest
...args: AnyRestOptional
options: EventListenerOptionsOptional
options: EventListenerOptionsOptional
options: EventListenerOptionsOptional
options: EventListenerOptionsRest
...args: any[]Synchronously calls each of the listeners registered for the event namedeventName
, in the order they were registered, passing the supplied arguments
to each.
Returns true
if the event had listeners, false
otherwise.
import { EventEmitter } from 'node:events';
const myEmitter = new EventEmitter();
// First listener
myEmitter.on('event', function firstListener() {
console.log('Helloooo! first listener');
});
// Second listener
myEmitter.on('event', function secondListener(arg1, arg2) {
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
});
// Third listener
myEmitter.on('event', function thirdListener(...args) {
const parameters = args.join(', ');
console.log(`event with parameters ${parameters} in third listener`);
});
console.log(myEmitter.listeners('event'));
myEmitter.emit('event', 1, 2, 3, 4, 5);
// Prints:
// [
// [Function: firstListener],
// [Function: secondListener],
// [Function: thirdListener]
// ]
// Helloooo! first listener
// event with parameters 1, 2 in second listener
// event with parameters 1, 2, 3, 4, 5 in third listener
-Rest
...args: AnyRestv0.1.26
-Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbol
s.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
v6.0.0
-Returns the number of listeners listening for the event named eventName
.
+
Returns the number of listeners listening for the event named eventName
.
If listener
is provided, it will return how many times the listener is found
in the list of the listeners of the event.
The name of the event being listened for
-Optional
listener: FunctionThe event handler function
+The name of the event being listened for
+Optional
listener: FunctionThe event handler function
v3.2.0
-Returns a copy of the array of listeners for the event named eventName
.
Returns a copy of the array of listeners for the event named eventName
.
server.on('connection', (stream) => {
console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')));
// Prints: [ [Function] ]
-v0.1.26
-Rest
...args: any[]Rest
...args: any[]Rest
...args: any[]Rest
...args: any[]Rest
...args: any[]Rest
...args: any[]Adds the listener
function to the beginning of the listeners array for the
+
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.
The name of the event.
-The callback function
-Rest
...args: any[]v6.0.0
-Adds a one-timelistener
function for the event named eventName
to the beginning of the listeners array. The next time eventName
is triggered, this
+
The name of the event.
+The callback function
+Rest
...args: any[]v6.0.0
+Adds a one-timelistener
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.
The name of the event.
-The callback function
-Rest
...args: any[]v6.0.0
-Returns a copy of the array of listeners for the event named eventName
,
+
The name of the event.
+The callback function
+Rest
...args: any[]v6.0.0
+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');
-v9.4.0
-Removes all listeners, or those of the specified eventName
.
It is bad practice to remove listeners added elsewhere in the code,
particularly when the EventEmitter
instance was created by some other
component or module (e.g. sockets or file streams).
Returns a reference to the EventEmitter
, so that calls can be chained.
Optional
eventName: string | symbolv0.1.26
-Rest
...args: any[]Rest
...args: any[]Optional
cb: ((err?) => void)Optional
err: ErrorOptional
binary?: booleanOptional
compress?: booleanOptional
fin?: booleanOptional
mask?: booleanOptional
cb: ((err?) => void)Optional
err: ErrorOptional
cb: ((err?) => void)Optional
err: ErrorOptional
binary?: booleanOptional
compress?: booleanOptional
fin?: booleanOptional
mask?: booleanOptional
cb: ((err?) => void)Optional
err: ErrorBy default EventEmitter
s 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 toInfinity
(or 0
) to indicate an unlimited number of listeners.
Returns a reference to the EventEmitter
, so that calls can be chained.
v0.3.5
-Generated using TypeDoc
v0.3.5
+Optional
[captureRest
...args: AnyRestRest
...args: any[]Synchronously calls each of the listeners registered for the event namedeventName
, in the order they were registered, passing the supplied arguments
+
Optional
[captureRest
...args: AnyRestRest
...args: any[]Synchronously calls each of the listeners registered for the event namedeventName
, in the order they were registered, passing the supplied arguments
to each.
Returns true
if the event had listeners, false
otherwise.
import { EventEmitter } from 'node:events';
const myEmitter = new EventEmitter();
// First listener
myEmitter.on('event', function firstListener() {
console.log('Helloooo! first listener');
});
// Second listener
myEmitter.on('event', function secondListener(arg1, arg2) {
console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
});
// Third listener
myEmitter.on('event', function thirdListener(...args) {
const parameters = args.join(', ');
console.log(`event with parameters ${parameters} in third listener`);
});
console.log(myEmitter.listeners('event'));
myEmitter.emit('event', 1, 2, 3, 4, 5);
// Prints:
// [
// [Function: firstListener],
// [Function: secondListener],
// [Function: thirdListener]
// ]
// Helloooo! first listener
// event with parameters 1, 2 in second listener
// event with parameters 1, 2, 3, 4, 5 in third listener
-Rest
...args: AnyRestv0.1.26
-Returns an array listing the events for which the emitter has registered
listeners. The values in the array are strings or Symbol
s.
import { EventEmitter } from 'node:events';
const myEE = new EventEmitter();
myEE.on('foo', () => {});
myEE.on('bar', () => {});
const sym = Symbol('symbol');
myEE.on(sym, () => {});
console.log(myEE.eventNames());
// Prints: [ 'foo', 'bar', Symbol(symbol) ]
v6.0.0
-Returns the number of listeners listening for the event named eventName
.
+
Returns the number of listeners listening for the event named eventName
.
If listener
is provided, it will return how many times the listener is found
in the list of the listeners of the event.
The name of the event being listened for
-Optional
listener: FunctionThe event handler function
+The name of the event being listened for
+Optional
listener: FunctionThe event handler function
v3.2.0
-Returns a copy of the array of listeners for the event named eventName
.
Returns a copy of the array of listeners for the event named eventName
.
server.on('connection', (stream) => {
console.log('someone connected!');
});
console.log(util.inspect(server.listeners('connection')));
// Prints: [ [Function] ]
-v0.1.26
-Adds the listener
function to the beginning of the listeners array for the
+
v0.1.26
+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.
The name of the event.
-The callback function
-Rest
...args: any[]v6.0.0
-Adds a one-timelistener
function for the event named eventName
to the beginning of the listeners array. The next time eventName
is triggered, this
+
The name of the event.
+The callback function
+Rest
...args: any[]v6.0.0
+Adds a one-timelistener
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.
The name of the event.
-The callback function
-Rest
...args: any[]v6.0.0
-Returns a copy of the array of listeners for the event named eventName
,
+
The name of the event.
+The callback function
+Rest
...args: any[]v6.0.0
+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');
-v9.4.0
-Removes all listeners, or those of the specified eventName
.
It is bad practice to remove listeners added elsewhere in the code,
particularly when the EventEmitter
instance was created by some other
component or module (e.g. sockets or file streams).
Returns a reference to the EventEmitter
, so that calls can be chained.
Optional
eventName: string | symbolv0.1.26
-Rest
...args: any[]Rest
...args: any[]By default EventEmitter
s 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 toInfinity
(or 0
) to indicate an unlimited number of listeners.
Returns a reference to the EventEmitter
, so that calls can be chained.
v0.3.5
-Generated using TypeDoc
v0.3.5
+Delete data previously written that is specific to the user (as identified by the OS) and +
Delete data previously written that is specific to the user (as identified by the OS) and extension (as identified by the ExecutionToken)
-ExecutionToken provided to the extension when activate()
was called
Unique identifier of the data
+ExecutionToken provided to the extension when activate()
was called
Unique identifier of the data
Promise that will resolve if the data is deleted successfully
-Read a binary file from the the extension's installation directory
-ExecutionToken provided to the extension when activate()
was called
Name of the file to be read
+Read a binary file from the the extension's installation directory
+ExecutionToken provided to the extension when activate()
was called
Name of the file to be read
Promise for a Buffer with the contents of the file
-Read a text file from the the extension's installation directory
-ExecutionToken provided to the extension when activate()
was called
Name of the file to be read
+Read a text file from the the extension's installation directory
+ExecutionToken provided to the extension when activate()
was called
Name of the file to be read
Promise for a string with the contents of the file
-
Handles the connection from the client to the server
-