Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach committed Aug 20, 2023
1 parent a54d869 commit 7fc80b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ Sets Windows clipboard content to the given text or a PNG image.
Name | Type | Required | Description | Example
--- | --- | --- | --- | ---
b64Content | string | yes | Base64-encoded content of the clipboard to be set | `QXBwaXVt`
contentType | 'text' or 'image' | no | Set to 'text' in order to set the given text to the clipboard (the default value). Set to 'image' if `b64Content` contains a base64-encoded payload of a PNG image. | image
contentType | 'plaintext' or 'image' | no | Set to 'plaintext' in order to set the given text to the clipboard (the default value). Set to 'image' if `b64Content` contains a base64-encoded payload of a PNG image. | image

### windows: getClipboard

Expand All @@ -326,7 +326,7 @@ Retrieves Windows clipboard content.

Name | Type | Required | Description | Example
--- | --- | --- | --- | ---
contentType | 'text' or 'image' | no | Set to 'text' in order to set the given text to the clipboard (the default value). Set to 'image' to retrieve a base64-encoded payload of a PNG image. | image
contentType | 'plaintext' or 'image' | no | Set to 'plaintext' in order to set the given text to the clipboard (the default value). Set to 'image' to retrieve a base64-encoded payload of a PNG image. | image

#### Returns

Expand Down
8 changes: 3 additions & 5 deletions lib/commands/clipboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const commands = {};
*/

/**
* @type {Record<ContentTypeEnum, ContentTypeEnum>}
* @type { Record<ContentTypeEnum, ContentTypeEnum>}
*/
const CONTENT_TYPE = Object.freeze({
plaintext: 'plaintext',
Expand All @@ -35,10 +35,8 @@ commands.windowsSetClipboard = async function windowsSetClipboard (opts = {}) {
b64Content,
contentType = CONTENT_TYPE.plaintext,
} = requireArgs(['b64Content'], opts);
if (b64Content && Buffer.from(b64Content, 'base64').toString('base64') !== b64Content || !b64Content) {
throw new errors.InvalidArgumentError(
`The 'b64Content' argument must be a valid non-empty base64-encoded string`
);
if (b64Content && Buffer.from(b64Content, 'base64').toString('base64') !== b64Content) {
throw new errors.InvalidArgumentError(`The 'b64Content' argument must be a valid base64-encoded string`);
}
switch (contentType) {
case CONTENT_TYPE.plaintext:
Expand Down

0 comments on commit 7fc80b4

Please sign in to comment.