From 845d001fe507b2b4ac8ad9dc85fb1bea51e2e568 Mon Sep 17 00:00:00 2001 From: pokutuna Date: Sat, 22 Jun 2019 15:54:24 +0900 Subject: [PATCH] Added new definitions for asciichart (#36273) --- types/asciichart/asciichart-tests.ts | 16 ++++++++++++++++ types/asciichart/index.d.ts | 13 +++++++++++++ types/asciichart/tsconfig.json | 23 +++++++++++++++++++++++ types/asciichart/tslint.json | 1 + 4 files changed, 53 insertions(+) create mode 100644 types/asciichart/asciichart-tests.ts create mode 100644 types/asciichart/index.d.ts create mode 100644 types/asciichart/tsconfig.json create mode 100644 types/asciichart/tslint.json diff --git a/types/asciichart/asciichart-tests.ts b/types/asciichart/asciichart-tests.ts new file mode 100644 index 0000000000..5c06e98dbb --- /dev/null +++ b/types/asciichart/asciichart-tests.ts @@ -0,0 +1,16 @@ +import * as asciichart from 'asciichart'; + +asciichart.plot([1, 2, 3]); +asciichart.plot([1, 2, 3], {}); +asciichart.plot([1, 2, 3], { offset: 4 }); +asciichart.plot([1, 2, 3], { padding: ' > ' }); +asciichart.plot([1, 2, 3], { height: 10 }); +asciichart.plot([1, 2, 3], { format: x => x.toFixed(1) }); +asciichart.plot([1, 2, 3], { format: (x, i) => (i === 2 ? ' * ' : x.toFixed(2)) }); + +asciichart.plot([1, 2, 3], { + offset: 4, + padding: ' >', + height: 10, + format: (x, i) => (i === 2 ? ' * ' : x.toFixed(2)), +}); diff --git a/types/asciichart/index.d.ts b/types/asciichart/index.d.ts new file mode 100644 index 0000000000..f2978b273a --- /dev/null +++ b/types/asciichart/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for asciichart 1.5 +// Project: https://github.com/kroitor/asciichart +// Definitions by: pokutuna +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface PlotConfig { + offset?: number; + padding?: string; + height?: number; + format?: (x: number, i: number) => string; +} + +export function plot(series: ReadonlyArray, cfg?: PlotConfig): string; diff --git a/types/asciichart/tsconfig.json b/types/asciichart/tsconfig.json new file mode 100644 index 0000000000..a81c3b1478 --- /dev/null +++ b/types/asciichart/tsconfig.json @@ -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", + "asciichart-tests.ts" + ] +} diff --git a/types/asciichart/tslint.json b/types/asciichart/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/asciichart/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }