Files
react-native-devtools-frontend/node_modules/@jridgewell/set-array
Nikolay Vitkov 95ea045b3e Update mocha to v11
Bug: none
Change-Id: I48e5e8df59c369ef8bea00bdaa7417f65f24b783
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6494701
Auto-Submit: Nikolay Vitkov <nvitkov@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Reviewed-by: Simon Zünd <szuend@chromium.org>
2025-05-01 23:10:37 -07:00
..
2025-05-01 23:10:37 -07:00
2023-07-18 09:44:36 +00:00
2025-05-01 23:10:37 -07:00
2023-07-18 09:44:36 +00:00

@jridgewell/set-array

Like a Set, but provides the index of the key in the backing array

This is designed to allow synchronizing a second array with the contents of the backing array, like how in a sourcemap sourcesContent[i] is the source content associated with source[i], and there are never duplicates.

Installation

npm install @jridgewell/set-array

Usage

import { SetArray, get, put, pop } from '@jridgewell/set-array';

const sa = new SetArray();

let index = put(sa, 'first');
assert.strictEqual(index, 0);

index = put(sa, 'second');
assert.strictEqual(index, 1);

assert.deepEqual(sa.array, [ 'first', 'second' ]);

index = get(sa, 'first');
assert.strictEqual(index, 0);

pop(sa);
index = get(sa, 'second');
assert.strictEqual(index, undefined);
assert.deepEqual(sa.array, [ 'first' ]);