browser.js 393 B

12345678910111213141516
  1. /* eslint-env browser */
  2. 'use strict';
  3. export const write = async text => {
  4. await navigator.clipboard.writeText(text);
  5. };
  6. export const read = async () => navigator.clipboard.readText();
  7. export const readSync = () => {
  8. throw new Error('`.readSync()` is not supported in browsers!');
  9. };
  10. export const writeSync = () => {
  11. throw new Error('`.writeSync()` is not supported in browsers!');
  12. };