MCPcopy Create free account
hub / github.com/vercel/examples / selectTargetedOption

Function selectTargetedOption

flags-sdk/openfeature/your-custom-provider.ts:16–23  ·  view source on GitHub ↗

* Selects a value from an array of options based on the targeting key using xxHash32 * @param targetingKey The key to use for targeting * @param options Array of available options * @returns The selected option

(
  flagKey: string,
  targetingKey: string,
  options: T[]
)

Source from the content-addressed store, hash-verified

14 * @returns The selected option
15 */
16function selectTargetedOption<T>(
17 flagKey: string,
18 targetingKey: string,
19 options: T[]
20): T {
21 const index = xxHash32(`${flagKey}:${targetingKey}`) % options.length
22 return options[index]
23}
24
25/**
26 * A custom OpenFeature provider that uses a static configuration.

Callers 3

Calls

no outgoing calls

Tested by

no test coverage detected