Captain is currently in ALPHA. We are happy to get your feedback
Core API
Build Key

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

NameTypeDefault valueDescription
keys(ID | KEY)[]undefinedArray of ID enum members representing the segments of the data store being addressed.
optionsObject{}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.delimiterundefined | string"-"-
options.prefixundefined | string""-
options.suffixundefined | 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.

Defined in

src/shared/build-key.ts:15 (opens in a new tab)