1 # @jridgewell/set-array
3 > Like a Set, but provides the index of the `key` in the backing array
5 This is designed to allow synchronizing a second array with the contents of the backing array, like
6 how in a sourcemap `sourcesContent[i]` is the source content associated with `source[i]`, and there
12 npm install @jridgewell/set-array
18 import { SetArray, get, put, pop } from '@jridgewell/set-array';
20 const sa = new SetArray();
22 let index = put(sa, 'first');
23 assert.strictEqual(index, 0);
25 index = put(sa, 'second');
26 assert.strictEqual(index, 1);
28 assert.deepEqual(sa.array, [ 'first', 'second' ]);
30 index = get(sa, 'first');
31 assert.strictEqual(index, 0);
34 index = get(sa, 'second');
35 assert.strictEqual(index, undefined);
36 assert.deepEqual(sa.array, [ 'first' ]);