Module: build-key
Table of contents
Functions
Functions
buildKey
▸ buildKey(keys
, options?
): string
Constructs a storage key using a combination of provided keys and optional formatting parameters. This function is pivotal in creating distinguishable and structured keys for different data stores, allowing for clear separation of concerns within the application's persisted state.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
keys | (ID | KEY )[] | undefined | Array of ID enum members representing the segments of the data store being addressed. |
options | Object | {} | Object with optional delimiter , prefix , and suffix to customize the key format. These formatting options provide flexibility in key generation, catering to potential naming conventions or integration requirements. |
options.delimiter | undefined | string | "-" | - |
options.prefix | undefined | string | "" | - |
options.suffix | undefined | string | "" | - |
Returns
string
A string representing the fully formatted key, incorporating the specified segments and formatting.
Throws
If the keys
array is empty, indicating that at least one key is required for key generation.