Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clippie

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clippie - npm Package Compare versions

Comparing version 1.0.3 to 2.0.0

22

index.js
export async function clippie(content) {
if (content instanceof Blob) {
const item = new ClipboardItem({[content.type]: content}); // eslint-disable-line no-undef
await navigator.clipboard.write([item]);
} else {
try {
await navigator.clipboard.writeText(content);
} catch {
return fallback(content);
try {
if (content instanceof Blob) {
const item = new ClipboardItem({[content.type]: content}); // eslint-disable-line no-undef
await navigator.clipboard.write([item]);
} else {
try {
await navigator.clipboard.writeText(content);
} catch {
return fallback(content);
}
}
return true;
} catch {
return false;
}
return true;
}

@@ -14,0 +18,0 @@

{
"name": "clippie",
"version": "1.0.3",
"version": "2.0.0",
"description": "Teeny-tiny browser clipboard copy",

@@ -5,0 +5,0 @@ "author": "silverwind",

# clippie
[![](https://img.shields.io/npm/v/clippie.svg?style=flat)](https://www.npmjs.org/package/clippie) [![](https://img.shields.io/npm/dm/clippie.svg)](https://www.npmjs.org/package/clippie) [![](https://img.shields.io/bundlephobia/minzip/clippie.svg)](https://bundlephobia.com/package/clippie)
`clippie` copies text and blobs to clipboard in Browsers. It relies on modern APIs that require a secure origin but also includes a fallback so it works on insecure origins.
`clippie` copies text and images to clipboard in Browsers. Text copy works on both secure and insecure origins, image copy requires a secure origin.

@@ -14,4 +14,4 @@ ## Usage

// copy blob, also works with images
const success = await clippie(new Blob("text to copy", "text/plain"));
// copy image
const success = await clippie(imageBlob);
```

@@ -24,4 +24,4 @@

Returns `true` when sucessful. Will throw all exceptions except when it falls back to another method.
Returns `true` when sucessful and `false` when not. Will never throw.
© [silverwind](https://github.com/silverwind), distributed under BSD licence
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc