Class: RegistryFile

core.RegistryFile

Class representing a file-backed registry database. The registry is held in memory and synchronized with its file when modified.

The registry database is a hierarchical key-value store with the keys being paths with / as delimiter, e.g.

  • /server/address
  • /server/port
  • /server/rpc/endpoint
  • /users/userA/password
  • /users/userB/password

The values may be any JSON-serializable data (string, number, object, array).

Please note that all access methods are asynchronous and return a Promise object that does not resolve before the registry is ready.

new core.RegistryFile ()

Properties:
Name Type Description
filesystem core.Filesystem

(default: null) The filesystem to write to.

modified bool

[readonly] true while the registry has unsaved modifications.

path string

(default: "") The path of the registry file on the filesystem.

ready bool

[readonly] true when the registry is ready to use, i.e. it has synchronized with the file.

Extends

Methods

info (key)object async

Returns information about the given key, or null if the key does not exist.

Name Type Description
key string

The key to retrieve the information from.

Returns:
Type Description
object The information object { type, description }.

list (folderKey)Array.<string> async

Lists the contents of the given folder key.

Name Type Description
folderKey string

The key to list the contents of.

Returns:
Type Description
Array.<string> The names of the content items.

read (key, defaultValue)any async

Reads the given key. Returns the defaultValue if the key was not found.

Name Type Description
key string

The key to read.

defaultValue any

The default value to return if the key was not found.

Returns:
Type Description
any The key's value.

readSync (key, defaultValue)any

Synchronous version of core.RegistryFile#read. This method is not part of the registry interface and only provides valid results once the registry has the ready flag set to true.

Name Type Description
key string

The key to read.

defaultValue any

The default value to return if the key was not found.

Returns:
Type Description
any The key's value.

remove (key) async

Removes the given key.

Name Type Description
key string

The key to remove.

write (key, value, description) async

Writes the given key. If the key does not yet exist, it will be created.

Name Type Description
key string

The key.

value any

The value to write.

description string optional

An optional description text.

Events

core.RegistryFile.event:changeValue

Is triggered when the value of a key has changed.

Name Type Description
key string

The key that was changed.