diff --git a/doc/api/errors.md b/doc/api/errors.md index 52fa7a1c145fc3..096bf4219df5f7 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -2045,6 +2045,16 @@ valid. The imported module string is an invalid URL, package name, or package subpath specifier. + + +### `ERR_INVALID_NOTIFICATION` + + + +The notification ID is not valid. + ### `ERR_INVALID_OBJECT_DEFINE_PROPERTY` diff --git a/doc/api/process.md b/doc/api/process.md index e30639f6a006f3..cb6050a25d0a4a 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -2328,6 +2328,19 @@ The references returned by `process.getBuiltinModule(id)` always point to the built-in module corresponding to `id` even if users modify [`require.cache`][] so that `require(id)` returns something else. +## `process.getNotifications()` + + + +> Stability: 1 - Experimental + +* Returns: {Array} A list of notifications registered in the current thread. + +Return the list of all notifications registered in the current thread via +[`process.registerNotification(callback)`](#processregisternotificationcallback). + ## `process.getegid()` + +> Stability: 1 - Experimental + +* `id` {bigint}: The notification ID + +Triggers the notification previously registered via [`process.registerNotification(callback)`](#processregisternotificationcallback). + +It will throw an error if the notification is not found. It is safe to invoke a notification +registered in the same thread. + ## `process.permission` + +> Stability: 1 - Experimental + +* `callback` {Function} A function to execute when the notification is received. +* Returns: {bigint} The notification ID + +Register a callback associated to a notification. + +A notification is a number which can be safely transferred and used in other threads to trigger +the associated callback via [`process.notify(id`)](#processnotifyid). + +The notification can be unregistered using [`process.unregisterNotification(id)`](#processunregisternotificationid). + ## `process.release` + +> Stability: 1 - Experimental + +* `id` {number} + +Unregister a notification previously registered with [`process.registerNotification(callback)`](#processregisternotificationcallback). + +It will throw an error if the notification is not found. The notification must be unregistered from the same thread +that registered it. + ## `process.uptime()`