1.0.6 • Published 6 years ago

assign-uniform v1.0.6

Weekly downloads
10
License
MIT
Repository
github
Last release
6 years ago

Deterministic Uniform Assignment in Nodejs

Deterministically select an index for accessing an array. Primarily used for a/b testing.

Implementation adapted from Facebook's planout library.

Example

import assign from "assign-uniform";

const myArray = ["a", "b", "c"];

// a consistent identifier to be used for future assignment
const userId = "my-user-id";

// a unique salt for this array to assure independent assignments
const saltString = "myArray";

const i = assign(`${userId}.${saltString}`, myArray.length);

const deterministicAssignment = myArray[i];

Assuring independent assignments

If you are running uniform assignment across multiple arrays, for example running multiple a/b tests, and would like the arrays to be independent from each other (and probably you do); then it is important that each independent array has a unique salt that is part of the hash string.

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago