clipboard-utility
v1.0.5
Published
A REALLY LIGHTWEIGHT utility to proceed with text copy in a browser. Less than 1KB
Downloads
3
Readme
Clipboard utility
It's a utility to proceed with text copy in a browser.
It's LESS than 1KB and NO DEPENDENCIES.
Check below for more details.
Release notes
If something has stopped working and you probably did update of package recently, consider checking out our releases and changes between them.
Check out available markups across all the versions in our wiki.
Installation
npm i clipboard-utility --save
How to use
1st scenario
const copy = require('clipboard-utility')`
const text = copy('something to be copied!')
text -> { success: true, value: 'something to be copied!' }
2nd scenario
const copy = require('clipboard-utility')`
const text = copy('something to be copied!', ({ success, value }) => {
if (!success) {
// early quit
}
// e.g
history.push({ pathname: value })
})
In both scenarios, value is placed in a CLIPBOARD .
Response
As a result of copy operation we are going to get an object as response.
Types
success
Returned when copy execution is proceeded flawlessly.
{
sucess: false,
value: 'Message that actually has been copied'
}
error
Returned when copy execution has failed at some point.
{
type: false,
value: 'Error message that has been thrown'
}