Module: lib/preferences

A thin OS wrapper that writes user preferences to a file.

Version:
  • 1.0.0
Author:
Source:

Methods

(static) alwaysUseHeaders() → {boolean}

Source:
Returns:

True if the always-use-headers key is set in the user preferences file.

Type
boolean

(static) file() → {string}

Source:
Returns:

The absolute path to the preferences file.

Type
string

(static) isInteractive() → {boolean}

Source:
Returns:

True if the interactive key is set in the user preferences file.

Type
boolean

(static) loadPreferences() → {object}

Loads preferences into memory synchronously.

Source:
Returns:

Will return an object object if we're unable to load contents from the file system.

Type
object

(static) readPreferences(key) → {boolean}

Attempts to read user preferences and fetch data. Cached in memory the first time we read the preferences.

Parameters:
Name Type Description
key string

The key to search for in the preferences file.

Source:
Returns:

False if no preferences file exists, otherwise the value of the key.

Type
boolean

(async, static) save(key, value, cbopt)

Saves a key and value pair to the preferences file.

Parameters:
Name Type Attributes Description
key string

The key to save.

value *

The JSON-encodable value to set.

cb function <optional>

The callback to execute after the file is written.

Source:

(async, static) truncate(cbopt, errorCallbackopt)

Truncates user preferences.

Parameters:
Name Type Attributes Description
cb function <optional>

The callback to execute is unlinking is successful.

errorCallback function <optional>

The callback to execute in the event of an error.

Source: