Let users customize the preferred reaction palette

This commit is contained in:
Evan Hahn 2021-09-09 11:29:01 -05:00 committed by GitHub
parent 7a5385e00a
commit f28456c160
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 1788 additions and 124 deletions

16
ts/util/replaceIndex.ts Normal file
View file

@ -0,0 +1,16 @@
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
export function replaceIndex<T>(
arr: ReadonlyArray<T>,
index: number,
newItem: T
): Array<T> {
if (!(index in arr)) {
throw new RangeError(`replaceIndex: ${index} out of range`);
}
const result = [...arr];
result[index] = newItem;
return result;
}