Constructor
# new DuSettings(namespaceopt, fileopt)
Constructs a new DuSettings instance.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
namespace |
string
|
<optional> |
DuESF.scriptName | A namespace to group your settings. |
file |
File
|
string
|
<optional> |
Folder.myDocuments/namespace/namespace_settings.json | The file to store the settings |
Properties:
Name | Type | Description |
---|---|---|
namespace |
string
|
A namespace to group your settings. |
file |
File
|
The file to store the settings |
data |
Object
|
The settings as a js object |
Methods
# get(key, defaultValueopt) → {*}
Gets a value from the settings. The key can be a path separated by /
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key |
string
|
The setting to get | ||
defaultValue |
*
|
<optional> |
null | The default value if the key is not set in the settings |
The value
*
# reset()
Reset the settings to their default values (removes the settings file!)
# save() → {boolean}
Saves data to the file.
Warning: DuESF does not check if it has write access on the files, you should check that first using methods specific to the host application.
Warning: DuESF does not check if it has write access on the files, you should check that first using methods specific to the host application.
true if the file has been correctly written
boolean
# set()
Sets a value to the settings. The key can be a path separated by /
Properties:
Name | Type | Description |
---|---|---|
key |
string
|
The setting to set |
value |
*
|
The value to set |
# setFile(file)
Sets the file to be used to save the settings
Parameters:
Name | Type | Description |
---|---|---|
file |
File
|
string
|
The file or path to the file |