createEnum does not take an array
This commit is contained in:
parent
ed913ca24b
commit
3aead4eae2
2 changed files with 4 additions and 1 deletions
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
import anotherjson from "../../../lib/another-json/index.js";
|
import anotherjson from "../../../lib/another-json/index.js";
|
||||||
import {createEnum} from "../../utils/enum.js";
|
import {createEnum} from "../../utils/enum.js";
|
||||||
|
|
||||||
export const DecryptionSource = createEnum(["Sync", "Timeline", "Retry"]);
|
export const DecryptionSource = createEnum("Sync", "Timeline", "Retry");
|
||||||
|
|
||||||
// use common prefix so it's easy to clear properties that are not e2ee related during session clear
|
// use common prefix so it's easy to clear properties that are not e2ee related during session clear
|
||||||
export const SESSION_KEY_PREFIX = "e2ee:";
|
export const SESSION_KEY_PREFIX = "e2ee:";
|
||||||
|
|
|
@ -17,6 +17,9 @@ limitations under the License.
|
||||||
export function createEnum(...values) {
|
export function createEnum(...values) {
|
||||||
const obj = {};
|
const obj = {};
|
||||||
for (const value of values) {
|
for (const value of values) {
|
||||||
|
if (typeof value !== "string") {
|
||||||
|
throw new Error("Invalid enum value name" + value?.toString());
|
||||||
|
}
|
||||||
obj[value] = value;
|
obj[value] = value;
|
||||||
}
|
}
|
||||||
return Object.freeze(obj);
|
return Object.freeze(obj);
|
||||||
|
|
Reference in a new issue