
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
copy-paste
Advanced tools
A command line utility that allows read/write (i.e copy/paste) access to the system clipboard.
A command line utility that allows read/write (i.e copy/paste) access to the system clipboard. It does this by wrapping pbcopy/pbpaste
(for OSX), xclip
(for Linux, FreeBSD, and OpenBSD), and clip
(for Windows). Currently works with node.js v0.8+.
When require("copy-paste")
is executed, an object with the following properties is returned:
copy(text[, callback])
: asynchronously replaces the current contents of the clip board with text
. Takes either a string, array, object, or readable stream. Returns the same value passed in. Optional callback will fire when the copy operation is complete.copy.json(obj[, callback])
: asynchronously replaces the current contents of the clip board with the JSON string of obj
. Returns the same value passed in. Optional callback will fire when the copy operation is complete.paste([callback])
: if no callback is provided, paste
synchronously returns the current contents of the system clip board. Otherwise, the contents of the system clip board are passed to the callback as the second parameter. The first one being a potential error.require("copy-paste").global()
: adds copy
and paste
to the global namespace. Returns an object with copy
and paste
as properties.Example usage:
const { copy, paste } = require("copy-paste");
copy("some text", (err, text) => {
// "some text" is in your clipboard
});
paste((err, text) => {
// complete...
});
const text = paste(); // Synchronous paste
copy({ hello: "world" }) // Asynchronous copy
For modern JavaScript applications, you can use the promise-based interface by requiring the promises
submodule:
const clipboard = require('copy-paste/promises');
The promise-based API provides the following methods:
copy(text)
: Returns a promise that resolves with the copied text when the operation is completecopy.json(obj)
: Returns a promise that resolves with the copied JSON string when the operation is completepaste()
: Returns a promise that resolves with the clipboard contents when the operation is completeExample usage with async/await:
const { copy, paste } = require('copy-paste/promises');
// Copy text
await copy('Hello World');
// Copy JSON
await copy.json({ hello: 'world' });
// Paste text
const text = await paste();
The easiest way to get node-copy-paste is with npm:
npm install copy-paste
Alternatively you can clone this git repository:
git clone git://github.com/xavi-/node-copy-paste.git
I'm hoping to add various fallbacks for instances when xclip
or clip
is not avaiable (see experimental-fallbacks branch). Also this library needs to be more thoroughly tested on windows.
This project is released under The MIT License.
FAQs
A command line utility that allows read/write (i.e copy/paste) access to the system clipboard.
The npm package copy-paste receives a total of 40,342 weekly downloads. As such, copy-paste popularity was classified as popular.
We found that copy-paste demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.