0.9.1 • Published 2 years ago

text-copier v0.9.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Simple clipboard function, written in TypeScript.

Installation

npm install --save text-copier

Usage

import { copyText } from 'text-copier';

// When user clicks on a button, 
// trigger the function
async function onClick() {
  await copyText('Hello World');
  alert('Copied to clipboard');
}

Error Handling

import { copyText, Clipboard } from 'text-copier';

async function onClick() {
  try {
    await copyText('Hello World');
    alert('Copied to clipboard');
  } catch(event: Clipboard.Event) {
    console.error(event);
  }
}