# @loopmode/set-clipboard-data

> A promise-based function to set data to the clipboard

Latest version **1.0.2** (published 2021-09-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install @loopmode/set-clipboard-data
pnpm add @loopmode/set-clipboard-data
yarn add @loopmode/set-clipboard-data
bun add @loopmode/set-clipboard-data
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-09-06 |
| First published | 2018-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jovica Aleksic |
| Maintainers | loopmode |

## Links

- npm: https://www.npmjs.com/package/@loopmode/set-clipboard-data
- Repository: https://github.com/loopmode/set-clipboard-data
- Homepage: https://github.com/loopmode/set-clipboard-data#readme
- Issues: https://github.com/loopmode/set-clipboard-data/issues
- npm.io page: https://npm.io/package/@loopmode/set-clipboard-data

## Recent versions

- 1.0.2 (latest) — 2021-09-06
- 1.0.0 — 2018-03-31

## README

# set-clipboard-data

Sets data to the clipboard via `document.execComand("copy")` and returns a promise.

The promise is resolved when the data has been set to the clipboard. This is detected via `document.addEventListener("copy")`.
It is rejected if the clipboard does not contain the specified value after the `copy` event, or if the event is not fired after a specific time (`rejectTimeout` option)

## Usage

```javascript
import setClipboardData from '@loopmode/set-clipboard-data';

async function handleCopyClick() {
    const clipboardValue = await setClipboardData(this.state.currentValue);
    console.log('done!', clipboardValue);
}

```

### Options

Signature:

```javascript
setClipboardData(data = '', { mime = 'text/plain', timeout = 60000 } = {})
```

---
_Source: https://npm.io/package/@loopmode/set-clipboard-data · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
