feat: make clipboard more robust and reintroduce contextmenu actions (#7198)

This commit is contained in:
David Luzar 2023-10-28 21:29:28 +02:00 committed by GitHub
parent ec2de7205f
commit ea677d4581
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 611 additions and 193 deletions

View file

@ -917,3 +917,17 @@ export const isRenderThrottlingEnabled = (() => {
return false;
};
})();
/** Checks if value is inside given collection. Useful for type-safety. */
export const isMemberOf = <T extends string>(
/** Set/Map/Array/Object */
collection: Set<T> | readonly T[] | Record<T, any> | Map<T, any>,
/** value to look for */
value: string,
): value is T => {
return collection instanceof Set || collection instanceof Map
? collection.has(value as T)
: "includes" in collection
? collection.includes(value as T)
: collection.hasOwnProperty(value);
};