Skip to content

Commit bc439c8

Browse files
committed
Update docstrs. Todo: update util unit tests
1 parent bc183e6 commit bc439c8

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

packages/browser/src/utils/featureFlags.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,16 @@ export function copyFlagsFromScopeToEvent(event: Event): Event {
4343
}
4444

4545
/**
46-
* Creates a feature flags values array in current context if it does not exist
47-
* and inserts the flag into a FeatureFlag array while maintaining ordered LRU
48-
* properties. Not thread-safe. After inserting:
49-
* - `flags` is sorted in order of recency, with the newest flag at the end.
50-
* - No other flags with the same name exist in `flags`.
51-
* - The length of `flags` does not exceed `maxSize`. The oldest flag is evicted
52-
* as needed.
46+
* Inserts a flag into the current scope's context while maintaining ordered LRU properties.
47+
* Not thread-safe. After inserting:
48+
* - The flag buffer is sorted in order of recency, with the newest evaluation at the end.
49+
* - The names in the buffer are always unique.
50+
* - The length of the buffer never exceeds `maxSize`.
5351
*
5452
* @param name Name of the feature flag to insert.
5553
* @param value Value of the feature flag.
5654
* @param maxSize Max number of flags the buffer should store. Default value should always be used in production.
57-
*/
55+
*/
5856
export function insertFlagToScope(name: string, value: unknown, maxSize: number = FLAG_BUFFER_SIZE): void {
5957
const scopeContexts = getCurrentScope().getScopeData().contexts;
6058
if (!scopeContexts.flags) {
@@ -65,7 +63,17 @@ export function insertFlagToScope(name: string, value: unknown, maxSize: number
6563
}
6664

6765
/**
68-
* Exported for tests. Currently only accepts boolean values (otherwise no-op).
66+
* Exported for tests only. Currently only accepts boolean values (otherwise no-op).
67+
* Inserts a flag into a FeatureFlag array while maintaining the following properties:
68+
* - Flags are sorted in order of recency, with the newest evaluation at the end.
69+
* - The flag names are always unique.
70+
* - The length of the array never exceeds `maxSize`.
71+
*
72+
* @param flags The buffer to insert the flag into.
73+
* @param name Name of the feature flag to insert.
74+
* @param value Value of the feature flag.
75+
* @param maxSize Max number of flags the buffer should store. Default value should always be used in production.
76+
* @param allowEviction If true, the oldest flag is evicted when the buffer is full. Otherwise the new flag is dropped.
6977
*/
7078
export function insertToFlagBuffer(flags: FeatureFlag[], name: string, value: unknown, maxSize: number, allowEviction: boolean = true): void {
7179
if (typeof value !== 'boolean') {

0 commit comments

Comments
 (0)