mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 08:17:05 +00:00
Merge pull request #25791 from Arylo/cli-table
Add type definition for cli-table
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import Table = require('cli-table');
|
||||
|
||||
/**
|
||||
* Example.
|
||||
*/
|
||||
|
||||
/* col widths */
|
||||
const table = new Table({
|
||||
head: ['Rel', 'Change', 'By', 'When'],
|
||||
colWidths: [6, 21, 25, 17]
|
||||
});
|
||||
|
||||
table.push(
|
||||
['v0.1', 'Testing something cool', 'rauchg@gmail.com', '7 minutes ago'],
|
||||
['v0.1', 'Testing something cool', 'rauchg@gmail.com', '8 minutes ago']
|
||||
);
|
||||
|
||||
table.toString();
|
||||
|
||||
/* compact */
|
||||
const table1 = new Table({
|
||||
head: ['Rel', 'Change', 'By', 'When'],
|
||||
colWidths: [6, 21, 25, 17],
|
||||
style : {compact : true, 'padding-left' : 1}
|
||||
});
|
||||
|
||||
table1.push(
|
||||
['v0.1', 'Testing something cool', 'rauchg@gmail.com', '7 minutes ago'],
|
||||
['v0.1', 'Testing something cool', 'rauchg@gmail.com', '8 minutes ago'],
|
||||
[],
|
||||
['v0.1', 'Testing something cool', 'rauchg@gmail.com', '8 minutes ago']
|
||||
);
|
||||
|
||||
/* headless */
|
||||
const headless_table = new Table();
|
||||
headless_table.push(
|
||||
['v0.1', 'Testing something cool', 'rauchg@gmail.com', '7 minutes ago']
|
||||
);
|
||||
/* vertical */
|
||||
const vertical_table = new Table();
|
||||
vertical_table.push(
|
||||
{ "Some Key": "Some Value"},
|
||||
{ "Another much longer key": "And its corresponding longer value"}
|
||||
);
|
||||
/* cross */
|
||||
const cross_table = new Table({ head: ["", "Header #1", "Header #2"] });
|
||||
cross_table.push(
|
||||
{ "Header #3": ["Value 1", "Value 2"] },
|
||||
{ "Header #4": ["Value 3", "Value 4"] }
|
||||
);
|
||||
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
// Type definitions for cli-table 0.3
|
||||
// Project: https://github.com/Automattic/cli-table
|
||||
// Definitions by: AryloYeung <https://github.com/arylo>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
interface TableOptions {
|
||||
chars: Partial<Record<(
|
||||
'top' |
|
||||
'top-mid' |
|
||||
'top-left' |
|
||||
'top-right' |
|
||||
'bottom' |
|
||||
'bottom-mid' |
|
||||
'bottom-left' |
|
||||
'bottom-right' |
|
||||
'left' |
|
||||
'left-mid' |
|
||||
'mid' |
|
||||
'mid-mid' |
|
||||
'right' |
|
||||
'right-mid' |
|
||||
'middle'
|
||||
), string>>;
|
||||
truncate: string;
|
||||
colors: boolean;
|
||||
colWidths: number[];
|
||||
colAligns: Array<"left" | "middle" | "right">;
|
||||
style: Partial<{
|
||||
'padding-left': number;
|
||||
'padding-right': number;
|
||||
head: string[];
|
||||
border: string[];
|
||||
compact: boolean;
|
||||
}>;
|
||||
head: string[];
|
||||
}
|
||||
|
||||
declare class Table extends Array {
|
||||
constructor(options?: Partial<TableOptions>);
|
||||
toString(): string;
|
||||
static version: string;
|
||||
}
|
||||
|
||||
export = Table;
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cli-table-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user