Skip to content

Commit

Permalink
Merge pull request #7667 from SrTobi/copy-paste
Browse files Browse the repository at this point in the history
added definitions for copy-paste
  • Loading branch information
horiuchi committed Jan 20, 2016
2 parents fdb5ef4 + 5421783 commit aa13a57
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
16 changes: 16 additions & 0 deletions copy-paste/copy-paste-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// <reference path="../node/node.d.ts" />
/// <reference path="copy-paste.d.ts" />

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; });
46 changes: 46 additions & 0 deletions copy-paste/copy-paste.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Type definitions for copy-paste v1.1.3
// Project: https://github.com/xavi-/node-copy-paste
// Definitions by: Tobias Kahlert <https://github.com/SrTobi>
// 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<T>(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<T>(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;
}

0 comments on commit aa13a57

Please sign in to comment.