Skip to content

Commit 183d197

Browse files
authored
🤖 Merge PR DefinitelyTyped#73331 Copy paste promises by @devm33
1 parent 0b5e264 commit 183d197

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

types/copy-paste/copy-paste-tests.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as CopyPaste from "copy-paste";
2+
import * as CopyPastePromises from "copy-paste/promises";
23

34
class TestClass {}
45

@@ -16,3 +17,9 @@ strRet = CopyPaste.paste();
1617
CopyPaste.paste((err: Error, content: string) => {
1718
return;
1819
});
20+
21+
let promiseStrRet: Promise<string> = CopyPastePromises.copy("content");
22+
23+
let promiseObjRet: Promise<TestClass> = CopyPastePromises.copy.json(new TestClass());
24+
25+
promiseStrRet = CopyPastePromises.paste();

types/copy-paste/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@types/copy-paste",
4-
"version": "1.1.9999",
4+
"version": "2.1.9999",
55
"projects": [
66
"https://github.com/xavi-/node-copy-paste"
77
],

types/copy-paste/promises.d.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Asynchronously replaces the current contents of the clip board with text.
3+
*
4+
* @param {T} content Takes either a string, array, object, or readable stream.
5+
* @return {Promise<T>} Resolves with the copied text when complete.
6+
*/
7+
export declare function copy<T>(content: T): Promise<T>;
8+
9+
export declare namespace copy {
10+
/**
11+
* Asynchronously replaces the current contents of the clip board with a JSON string of an object.
12+
*
13+
* @param {T} obj The object to copy as JSON.
14+
* @return {Promise<T>} Resolves with the copied object when complete.
15+
*/
16+
function json<T>(obj: T): Promise<T>;
17+
}
18+
19+
/**
20+
* Asynchronously returns the current contents of the system clip board.
21+
*
22+
* @return {Promise<string>} Resolves with the current contents of the system clip board.
23+
*/
24+
export declare function paste(): Promise<string>;

0 commit comments

Comments
 (0)