text-copier
TypeScript icon, indicating that this package has built-in type declarations

0.9.1 • Public • Published

text-copier npm

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);
  }
}

Package Sidebar

Install

npm i text-copier

Weekly Downloads

2

Version

0.9.1

License

MIT

Unpacked Size

11.1 kB

Total Files

10

Last publish

Collaborators

  • shook-lyngs