Constructor
(abstract) new Node(options)
Create a node.
Extends:
- EventEmitter
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
Extends
- EventEmitter
Methods
(private) _bind(obj, event, listener)
Bind to an event on obj
, save listener for removal.
Parameters:
Name | Type | Description |
---|---|---|
obj |
EventEmitter | |
event |
String | |
listener |
function |
- Source:
(private) _init(options)
Initialize node.
Parameters:
Name | Type | Description |
---|---|---|
options |
Object |
- Source:
(private) abort(err)
Emit and log an abort error.
Parameters:
Name | Type | Description |
---|---|---|
err |
Error |
- Source:
(async, private) closePlugins()
Close plugins.
- Source:
(async) ensure() → {Promise}
Ensure prefix directory.
- Source:
Returns:
- Type
- Promise
(private) error(err)
Emit and log an error.
Parameters:
Name | Type | Description |
---|---|---|
err |
Error |
- Source:
(private) genKey() → {Buffer}
Generate identity key.
- Source:
Returns:
- Type
- Buffer
get(name) → {Object|null}
Get a plugin.
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
- Source:
Returns:
- Type
- Object | null
(async, private) handleClose()
Close node. Unbind all events.
- Source:
(async, private) handleOpen()
Open node.
- Source:
(async, private) handlePreclose()
Open node. Bind all events.
- Source:
(async, private) handlePreopen()
Open node. Bind all events.
- Source:
has(name) → {Boolean}
Test whether a plugin is available.
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
- Source:
Returns:
- Type
- Boolean
(private) loadKey() → {Buffer}
Load identity key.
- Source:
Returns:
- Type
- Buffer
(private) loadPlugins()
Load plugins.
- Source:
location(file) → {String}
Create a file path using prefix
.
Parameters:
Name | Type | Description |
---|---|---|
file |
String |
- Source:
Returns:
- Type
- String
(async, private) openPlugins()
Open plugins.
- Source:
require(name) → {Object}
Require a plugin.
Parameters:
Name | Type | Description |
---|---|---|
name |
String |
- Source:
Throws:
-
on onloaded plugin
- Type
- Error
Returns:
- Type
- Object
uptime() → {Number}
Get node uptime in seconds.
- Source:
Returns:
- Type
- Number
use(plugin) → {Object}
Attach a plugin.
Parameters:
Name | Type | Description |
---|---|---|
plugin |
Object |
- Source:
Returns:
Plugin instance.
- Type
- Object