Constructor
+ + + +new ObsMultiAJSON(collection)
+ + + + + + +Creates an instance of ObsMultiAJSON.
+Parameters:
+ + +Name | + + +Type | + + + + + +Description | +
---|---|---|
collection |
+
+
+ + + +Object + + + + | + + + + + +The collection of items to be managed. |
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- Source: +
- + + + + + + + +
Members
+ + + +data_path
+ + + + +Gets the data path for storing .ajson files, appending '/multi' to the base path.
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- Source: +
- + + + + + + + +
Methods
+ + + + + + + +(async) _save(forceopt)
+ + + + + + +Asynchronously saves modified collection items to their respective .ajson files.
+Parameters:
+ + +Name | + + +Type | + + +Attributes | + + + +Default | + + +Description | +
---|---|---|---|---|
force |
+
+
+ + + +boolean + + + + | + + +
+
+ <optional> + + + + + + |
+
+
+
+ + + false + + | + + +Forces the save operation even if it's currently flagged as saving. |
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- Source: +
- + + + + + + + +
(async) load()
+ + + + + + +Asynchronously loads collection items from .ajson files within the specified data path. +It ensures that only .ajson files are processed and handles JSON parsing and item instantiation.
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- Source: +
- + + + + + + + +
save()
+ + + + + + +Schedules a save operation to prevent multiple saves happening at the same time.
+-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- Source: +
- + + + + + + + +
(async) validate_save(new_file_path, old_file_path) → {Promise.<boolean>}
+ + + + + + +Validates the save operation by comparing the file sizes of the new and old files.
+Parameters:
+ + +Name | + + +Type | + + + + + +Description | +
---|---|---|
new_file_path |
+
+
+ + + +string + + + + | + + + + + +Path to the new file. |
+
old_file_path |
+
+
+ + + +string + + + + | + + + + + +Path to the old file. |
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- Source: +
- + + + + + + + +
Returns:
+ + +-
+
- True if the new file size is at least 50% of the old file size, otherwise false. +
-
+
- + Type + +
- + +Promise.<boolean> + + + +