@yankeeinlondon/promptly
Version:
An automation tool for prompting your favorite LLMs
20 lines (18 loc) • 465 B
text/typescript
import clipboardy from "clipboardy";
import { ClipboardError } from "~/errors";
/**
* Copies the provided text to the clipboard.
* @param text - The text to copy.
*/
export async function toClipboard(text: string): Promise<true | Error> {
try {
await clipboardy.write(text);
return true;
}
catch (error) {
return new ClipboardError(
`Problem copying content to the clipboard`,
{ underlying: error as string | Error },
);
}
}