1.0.6 • Published 7 years ago

assign-uniform v1.0.6

Weekly downloads
10
License
MIT
Repository
github
Last release
7 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

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago