Merge pull request #28024 from ffflorian/websequencediagrams

Add types for websequencediagrams
This commit is contained in:
Benjamin Lichtman
2018-08-20 09:07:18 -07:00
committed by GitHub
4 changed files with 59 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
// Type definitions for websequencediagrams 0.1
// Project: https://github.com/hildjj/node-websequencediagrams
// Definitions by: Florian Keller <https://github.com/ffflorian>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
export type OutputType = 'png' | 'svg' | 'pdf';
export type Style = 'default' | 'earth' | 'modern-blue' | 'mscgen' | 'omegapple' | 'qsd' | 'rose' | 'roundgreen' | 'napkin' | 'magazine' | 'vs2010' | 'patent';
export type diagramCallback = (error: Error | null, buffer?: Buffer, mimeType?: string) => void;
export type diagramUrlCallback = (error: Error | null, url?: string) => void;
export const root: string;
export const styles: Style[];
export function diagram(description: string | Buffer, style: Style | null, format: OutputType | null, callback: diagramCallback): void;
export function diagram_url(description: string | Buffer, style: Style | null, format: OutputType | null, callback: diagramUrlCallback): void;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"websequencediagrams-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,18 @@
import * as wsd from 'websequencediagrams';
wsd.diagram('Alice->Bob: message', 'modern-blue', 'png', (error, buffer, mimeType) => {
if (error) {
console.error(error);
} else {
console.log('Received MIME type:', mimeType);
console.log('Received Buffer:', buffer);
}
});
wsd.diagram_url('Alice->Bob: message', 'modern-blue', 'png', (error, url) => {
if (error) {
console.error(error);
} else {
console.log('Received URL:', url);
}
});