[qrcode]improve types of qrcode@1.2.0 (#23289)

* [qrcode]improve types of qrcode@1.2.0

Add toDataURL with promise as response

* [qrcode]improve types of qrcode@1.2.0

- add similar methods for toCanvas
- method with short signature comes before method with long signature

* [qrcode]improve types of qrcode@1.2.0

- toFile promise
- toFileStream promise
- toString promise
This commit is contained in:
ArtworkAD
2018-01-31 12:25:06 -08:00
committed by Sheetal Nandi
parent c08ff42c62
commit 2b7d8a255e
+70
View File
@@ -127,65 +127,127 @@ export interface QRCode {
*/
export function create(text: string | QRCodeSegment[], options: QRCodeOptions): QRCode;
/**
* Draws qr code symbol to canvas.
*/
export function toCanvas(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[]): Promise<any>;
/**
* Draws qr code symbol to canvas.
*/
export function toCanvas(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[], callback: (error: Error) => void): void;
/**
* Draws qr code symbol to canvas.
*/
export function toCanvas(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[], options: QRCodeOptions): Promise<any>;
/**
* Draws qr code symbol to canvas.
*/
export function toCanvas(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[], options: QRCodeOptions, callback: (error: Error) => void): void;
/**
* Draws qr code symbol to canvas.
*/
export function toCanvas(text: string | QRCodeSegment[]): Promise<any>;
/**
* Draws qr code symbol to canvas.
*/
export function toCanvas(text: string | QRCodeSegment[], callback: (error: Error, canvas: HTMLCanvasElement) => void): void;
/**
* Draws qr code symbol to canvas.
*/
export function toCanvas(text: string | QRCodeSegment[], options: QRCodeOptions): Promise<any>;
/**
* Draws qr code symbol to canvas.
*/
export function toCanvas(text: string | QRCodeSegment[], options: QRCodeOptions, callback: (error: Error, canvas: HTMLCanvasElement) => void): void;
/**
* Draws qr code symbol to node canvas.
*/
export function toCanvas(canvas: any, text: string | QRCodeSegment[]): Promise<any>;
/**
* Draws qr code symbol to node canvas.
*/
export function toCanvas(canvas: any, text: string | QRCodeSegment[], callback: (error: Error) => void): void;
/**
* Draws qr code symbol to node canvas.
*/
export function toCanvas(canvas: any, text: string | QRCodeSegment[], options: QRCodeOptions): Promise<any>;
/**
* Draws qr code symbol to node canvas.
*/
export function toCanvas(canvas: any, text: string | QRCodeSegment[], options: QRCodeOptions, callback: (error: Error) => void): void;
/**
* Returns a Data URI containing a representation of the QR Code image.
*/
export function toDataURL(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[]): Promise<any>;
/**
* Returns a Data URI containing a representation of the QR Code image.
*/
export function toDataURL(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[], callback: (error: Error, url: string) => void): void;
/**
* Returns a Data URI containing a representation of the QR Code image.
*/
export function toDataURL(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[], options: QRCodeToDataURLOptions): Promise<any>;
/**
* Returns a Data URI containing a representation of the QR Code image.
*/
export function toDataURL(canvasElement: HTMLCanvasElement, text: string | QRCodeSegment[], options: QRCodeToDataURLOptions, callback: (error: Error, url: string) => void): void;
/**
* Returns a Data URI containing a representation of the QR Code image.
*/
export function toDataURL(text: string | QRCodeSegment[]): Promise<any>;
/**
* Returns a Data URI containing a representation of the QR Code image.
*/
export function toDataURL(text: string | QRCodeSegment[], callback: (error: Error, url: string) => void): void;
/**
* Returns a Data URI containing a representation of the QR Code image.
*/
export function toDataURL(text: string | QRCodeSegment[], options: QRCodeToDataURLOptions): Promise<any>;
/**
* Returns a Data URI containing a representation of the QR Code image.
*/
export function toDataURL(text: string | QRCodeSegment[], options: QRCodeToDataURLOptions, callback: (error: Error, url: string) => void): void;
/**
* Returns a string representation of the QR Code.
* If choosen output format is svg it will returns a string containing xml code.
*/
export function toString(text: string | QRCodeSegment[]): Promise<any>;
/**
* Returns a string representation of the QR Code.
* If choosen output format is svg it will returns a string containing xml code.
*/
export function toString(text: string | QRCodeSegment[], callback: (error: Error, string: string) => void): void;
/**
* Returns a string representation of the QR Code.
* If choosen output format is svg it will returns a string containing xml code.
*/
export function toString(text: string | QRCodeSegment[], options: QRCodeToStringOptions): Promise<any>;
/**
* Returns a string representation of the QR Code.
* If choosen output format is svg it will returns a string containing xml code.
*/
export function toString(text: string | QRCodeSegment[], options: QRCodeToStringOptions, callback: (error: Error, string: string) => void): void;
/**
* Saves QR Code to image file.
* If options.type is not specified, the format will be guessed from file extension.
* Recognized extensions are png, svg, txt.
*/
export function toFile(path: string, text: string | QRCodeSegment[]): Promise<any>;
/**
* Saves QR Code to image file.
* If options.type is not specified, the format will be guessed from file extension.
* Recognized extensions are png, svg, txt.
*/
export function toFile(path: string, text: string | QRCodeSegment[], callback: (error: Error) => void): void;
/**
* Saves QR Code to image file.
* If options.type is not specified, the format will be guessed from file extension.
* Recognized extensions are png, svg, txt.
*/
export function toFile(path: string, text: string | QRCodeSegment[], options: QRCodeToFileOptions): Promise<any>;
/**
* Saves QR Code to image file.
* If options.type is not specified, the format will be guessed from file extension.
@@ -193,10 +255,18 @@ export function toFile(path: string, text: string | QRCodeSegment[], callback: (
*/
export function toFile(path: string, text: string | QRCodeSegment[], options: QRCodeToFileOptions, callback: (error: Error) => void): void;
/**
* Writes QR Code image to stream. Only works with png format for now.
*/
export function toFileStream(stream: stream.Writable, text: string | QRCodeSegment[]): Promise<any>;
/**
* Writes QR Code image to stream. Only works with png format for now.
*/
export function toFileStream(stream: stream.Writable, text: string | QRCodeSegment[], callback: (error: Error) => void): void;
/**
* Writes QR Code image to stream. Only works with png format for now.
*/
export function toFileStream(stream: stream.Writable, text: string | QRCodeSegment[], options: QRCodeOptions): Promise<any>;
/**
* Writes QR Code image to stream. Only works with png format for now.
*/