@@ -43,18 +43,16 @@ export function copyFlagsFromScopeToEvent(event: Event): Event {
43
43
}
44
44
45
45
/**
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`.
53
51
*
54
52
* @param name Name of the feature flag to insert.
55
53
* @param value Value of the feature flag.
56
54
* @param maxSize Max number of flags the buffer should store. Default value should always be used in production.
57
- */
55
+ */
58
56
export function insertFlagToScope ( name : string , value : unknown , maxSize : number = FLAG_BUFFER_SIZE ) : void {
59
57
const scopeContexts = getCurrentScope ( ) . getScopeData ( ) . contexts ;
60
58
if ( ! scopeContexts . flags ) {
@@ -65,7 +63,17 @@ export function insertFlagToScope(name: string, value: unknown, maxSize: number
65
63
}
66
64
67
65
/**
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.
69
77
*/
70
78
export function insertToFlagBuffer ( flags : FeatureFlag [ ] , name : string , value : unknown , maxSize : number , allowEviction : boolean = true ) : void {
71
79
if ( typeof value !== 'boolean' ) {
0 commit comments