1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-07 12:13:45 +00:00
Files
browser/libs/messaging-internal/src/helpers.ts
2025-07-22 11:47:25 -04:00

20 lines
537 B
TypeScript

import { map } from "rxjs";
import { CommandDefinition, EXTERNAL_SOURCE_TAG } from "@bitwarden/messaging";
export const getCommand = (
commandDefinition: CommandDefinition<Record<string, unknown>> | string,
) => {
if (typeof commandDefinition === "string") {
return commandDefinition;
} else {
return commandDefinition.command;
}
};
export const tagAsExternal = <T extends Record<PropertyKey, unknown>>() => {
return map((message: T) => {
return Object.assign(message, { [EXTERNAL_SOURCE_TAG]: true });
});
};