From 5421783adfaf9b99e9274f4488cfc0ee73f17a56 Mon Sep 17 00:00:00 2001 From: SrTobi Date: Sat, 16 Jan 2016 00:30:37 +0100 Subject: [PATCH] added copy-paste --- copy-paste/copy-paste-tests.ts | 16 ++++++++++++ copy-paste/copy-paste.d.ts | 46 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 copy-paste/copy-paste-tests.ts create mode 100644 copy-paste/copy-paste.d.ts diff --git a/copy-paste/copy-paste-tests.ts b/copy-paste/copy-paste-tests.ts new file mode 100644 index 000000000..400c32a2a --- /dev/null +++ b/copy-paste/copy-paste-tests.ts @@ -0,0 +1,16 @@ +/// +/// + +import * as CopyPaste from 'copy-paste'; + +class TestClass {} + +let strRet: string = CopyPaste.copy("content"); +strRet = CopyPaste.copy("content", (err: Error) => { return; }); + + +let objRet: TestClass = CopyPaste.copy(new TestClass()); +objRet = CopyPaste.copy(new TestClass(), (err: Error) => { return; }); + +strRet = CopyPaste.paste(); +CopyPaste.paste((err: Error, content: string) => { return; }); \ No newline at end of file diff --git a/copy-paste/copy-paste.d.ts b/copy-paste/copy-paste.d.ts new file mode 100644 index 000000000..a8a844b5b --- /dev/null +++ b/copy-paste/copy-paste.d.ts @@ -0,0 +1,46 @@ +// Type definitions for copy-paste v1.1.3 +// Project: https://github.com/xavi-/node-copy-paste +// Definitions by: Tobias Kahlert +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'copy-paste' { + + export type CopyCallback = (err: Error) => void; + export type PasteCallback = (err: Error, content: string) => void; + + /** + * Asynchronously replaces the current contents of the clip board with text. + * + * @param {T} content Takes either a string, array, object, or readable stream. + * @return {T} Returns the same value passed in. + */ + export function copy(content: T): T; + + /** + * Asynchronously replaces the current contents of the clip board with text. + * + * @param {T} content Takes either a string, array, object, or readable stream. + * @param {CopyCallback} callback will fire when the copy operation is complete. + * @return {T} Returns the same value passed in. + */ + export function copy(content: T, callback: CopyCallback): T; + + + /** + * Synchronously returns the current contents of the system clip board. + * + * Note: The synchronous version of paste is not always availabled. + * An error message is shown if the synchronous version of paste is used on an unsupported platform. + * The asynchronous version of paste is always available. + * + * @return {string} Returns the current contents of the system clip board. + */ + export function paste(): string; + + /** + * Asynchronously returns the current contents of the system clip board. + * + * @param {PasteCallback} callback The contents of the system clip board are passed to the callback as the second parameter. + */ + export function paste(callback: PasteCallback): void; +} \ No newline at end of file