-
-
Initializes this AliasedNameStore, optionally with pre-loading data.
Parameters:
Name |
Type |
Description |
id |
string
|
The id of this AliasedNameStore. |
opts |
Object
|
Options for this AliasedNameStore.
Properties
|
- Implements:
- See:
-
-
delete(key, opts) → {boolean}
-
Removes an item from this AliasedNameStore. The methods delete and remove are identical.
Parameters:
Name |
Type |
Description |
key |
string
|
classes.common.AliasedName.AliasedName
|
The key to lookup a value for. All related keys will
also be removed with the value. |
opts |
Object
|
Options for loading data into this AliasedNameStore
Properties
Name |
Type |
Description |
safety |
boolean
|
NOT IMPLEMENTED: Whether to check if a value under the
key exists before attempting to delete it. |
|
Returns:
boolean
- True on success
- To Do:
-
- Implement safety deletion check.
-
filter(cb) → {Array}
-
Similar to Array#filter. Calls the callback provided on every AliasedName stored inside this, and stores those values where cb
returns true.
Parameters:
Name |
Type |
Description |
cb |
function
|
Callback called on every element in this storage. First arg is the
item, second arg is its AliasedName key, and third is this storage.
Function must return truthy for the value to be included in result. |
Returns:
Array
- Filtered results of values from this AliasedNameStore.
Example
Example usage of filtering.
filtered_arr = store.filter((item, name) => item.prop === 'value' && name.AKA() === 'something');
-
forEach(cb) → {undefined}
-
Similar to Array#forEach. Calls the callback provided on every AliasedName stored inside this. The methods each and forEach are
identical.
Parameters:
Name |
Type |
Description |
cb |
function
|
Callback called on every element in this storage. First argument is the
item, second arg is its AliasedName key, and third is this storage. |
Throws:
-
Aborts if an invalid name object has been found in this._map. AliasedNameStores should only store objects with an
AliasedName #name property. The ID keys and stringified name aliases do not apply - we loop through this._name_set.
-
-
Type
-
Error
Returns:
undefined
-
get(key, opts) → {*|undefined}
-
Parameters:
Name |
Type |
Description |
key |
string
|
classes.common.AliasedName.AliasedName
|
The key to lookup a value for. |
opts |
Object
|
Options for this get operation.
Properties
Name |
Type |
Description |
fuzzy_options |
boolean
|
NOT IMPLEMENTED: Whether to get using fuzzy options. |
|
Returns:
*
|
undefined
- The value stored that matches key, otherwise undefined.
- See:
-
- classes.common.AliasedName.AliasedName#set
- To Do:
-
-
get_all(keys, opts) → {Array.<(*|Object)>}
-
Returns:
Array.<(*|Object)>
- The value stored that matches each key.
- To Do:
-
-
insert(item, opts) → {boolean}
-
Adds an item to this AliasedNameStore. Retrieval of the item can be done by calling
classes.common.AliasedName.AliasedNameStore#get
and passing in item.name, item.name.name, any alias in item.name.for_every_alias,
and item.id if the id exists on the item. The methods set and insert are identical.
Parameters:
Name |
Type |
Description |
item |
interfaces.IDNameCreatable
|
The IDNameCreatable to add. Item must have a name property with an classes.common.AliasedName.AliasedName |
opts |
Object
|
Options for loading data into this AliasedNameStore
Properties
Name |
Type |
Description |
safety |
boolean
|
Whether to check data to load as being TrackingSet compatible |
|
Returns:
boolean
- True on success
- See:
-
-
-
Loads data in bulk into an AliasedNameStore
Parameters:
Name |
Type |
Description |
data |
TrackingSet
|
Array
|
Set
|
Takes a TrackingSet compatible dataset. |
opts |
Object
|
Options for loading data into this AliasedNameStore.
Properties
Name |
Type |
Description |
safety |
boolean
|
Whether to check data to load as being TrackingSet compatible. |
|
- See:
-
-
map(cb) → {Array}
-
Similar to Array#map. Calls the callback provided on every AliasedName stored inside this, and stores the return values.
Parameters:
Name |
Type |
Description |
cb |
function
|
Callback called on every element in this storage. First arg is the
item, second arg is its AliasedName key, and third is this storage. |
Returns:
Array
- Filtered results of values from this AliasedNameStore.
Example
Example usage of filtering.
filtered_arr = store.filter((item, name) => item.prop === 'value' && name.AKA() === 'something');
-
mget(keys, opts) → {Array.<(*|Object)>}
-
Returns:
Array.<(*|Object)>
- The value stored that matches each key.
- To Do:
-
-
remove(key, opts) → {boolean}
-
Removes an item from this AliasedNameStore. The methods delete and remove are identical.
Parameters:
Name |
Type |
Description |
key |
string
|
classes.common.AliasedName.AliasedName
|
The key to lookup a value for. All related keys will
also be removed with the value. |
opts |
Object
|
Options for loading data into this AliasedNameStore
Properties
Name |
Type |
Description |
safety |
boolean
|
NOT IMPLEMENTED: Whether to check if a value under the
key exists before attempting to delete it. |
|
Returns:
boolean
- True on success
- To Do:
-
- Implement safety deletion check.
-
safe_get(key, opts) → {*|Object}
-
Parameters:
Name |
Type |
Description |
key |
string
|
classes.common.AliasedName.AliasedName
|
The key to lookup a value for. |
opts |
Object
|
Options for this get operation.
Properties
Name |
Type |
Description |
fuzzy_options |
boolean
|
NOT IMPLEMENTED: Whether to get using fuzzy options. |
|
Returns:
*
|
Object
- The value stored that matches key, otherwise an empty object {}.
- To Do:
-
-
safe_mget(keys, opts) → {Array.<(*|Object)>}
-
Returns:
Array.<(*|Object)>
- The value stored that matches each key.
- To Do:
-
-
set(item, opts) → {boolean}
-
Adds an item to this AliasedNameStore. Retrieval of the item can be done by calling
classes.common.AliasedName.AliasedNameStore#get
and passing in item.name, item.name.name, any alias in item.name.for_every_alias,
and item.id if the id exists on the item. The methods set and insert are identical.
Parameters:
Name |
Type |
Description |
item |
interfaces.IDNameCreatable
|
The IDNameCreatable to add. Item must have a name property with an classes.common.AliasedName.AliasedName |
opts |
Object
|
Options for loading data into this AliasedNameStore
Properties
Name |
Type |
Description |
safety |
boolean
|
Whether to check data to load as being TrackingSet compatible |
|
Returns:
boolean
- True on success
- See:
-
-
values(that) → {function}
-
Returns a values iterator for this AliasedNameStore.
Returns:
function
- The values iterator
Example
Example usage of looping through store.values() or implicit for/of with Symbol.iterator.
Array.from(store.values()).map(e => e.some_property_on_each_value);
for (const v of store) {}
for (const v of store.values()) {}
-
-
Generates an AliasedNameStore class. Called internally within the AliasedName sub-folder assembly.
Parameters:
Name |
Type |
Description |
deps |
Object
|
Dependencies of the AliasedNameStore.
Properties
|