mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 15:00:26 +00:00
Typings for cli-box (https://github.com/IonicaBizau/node-cli-box).
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import Box = require('cli-box');
|
||||
|
||||
// Create a simple box
|
||||
const b1: Box = Box("20x10");
|
||||
// console.log(b1.toString());
|
||||
|
||||
// Set custom marks
|
||||
const b2: Box = new Box({
|
||||
w: 10
|
||||
, h: 10
|
||||
, stringify: false
|
||||
, marks: {
|
||||
nw: "╔"
|
||||
, n: "══"
|
||||
, ne: "╗"
|
||||
, e: "║"
|
||||
, se: "╝"
|
||||
, s: "══"
|
||||
, sw: "╚"
|
||||
, w: "║"
|
||||
, b: "░░"
|
||||
}
|
||||
});
|
||||
// console.log(b2.stringify());
|
||||
|
||||
// Box with text and use the stringify
|
||||
const b3: Box = Box("20x10", "I will be \u001b[31mdis\u001b[0mplayed inside! \n A\u001b[34mnd I'm in a\u001b[0m new line!");
|
||||
// console.log(b3);
|
||||
|
||||
// Box with aligned text to top-right
|
||||
const b4: Box = Box("30x20", {
|
||||
text: "Box content"
|
||||
, stretch: true
|
||||
, autoEOL: true
|
||||
, vAlign: "top"
|
||||
, hAlign: "right"
|
||||
});
|
||||
// console.log(b4);
|
||||
|
||||
// Full screen box
|
||||
const b5: Box = Box({fullscreen: true, marks: {}}, "Hello World!");
|
||||
// console.log(b5.toString());
|
||||
|
||||
const b5s: string = Box({stringify: true, fullscreen: true, marks: {}}, "Hello World!");
|
||||
const b5ns: Box = Box({stringify: false, fullscreen: true, marks: {}}, "Hello World!");
|
||||
|
||||
const defaults = Box.defaults;
|
||||
Vendored
+70
@@ -0,0 +1,70 @@
|
||||
// Type definitions for cli-box 6.0
|
||||
// Project: https://github.com/IonicaBizau/node-cli-box
|
||||
// Definitions by: Kent Wong <https://github.com/athasach>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/*~ Note that ES6 modules cannot directly export callable functions.
|
||||
*~ This file should be imported using the CommonJS-style:
|
||||
*~ import x = require('someLibrary');
|
||||
*~
|
||||
*~ Refer to the documentation to understand common
|
||||
*~ workarounds for this limitation of ES6 modules.
|
||||
*/
|
||||
|
||||
/*~ This declaration specifies that the function
|
||||
*~ is the exported object from the file
|
||||
*/
|
||||
export = Box;
|
||||
|
||||
type MarksKeys = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'b';
|
||||
type Marks = Record<MarksKeys, string>;
|
||||
|
||||
interface Options {
|
||||
w?: number;
|
||||
width?: number;
|
||||
h?: number;
|
||||
height?: number;
|
||||
fullscreen?: boolean;
|
||||
stringify?: boolean;
|
||||
marks?: Partial<Marks>;
|
||||
}
|
||||
|
||||
interface Text {
|
||||
text?: string;
|
||||
stretch?: boolean;
|
||||
autoEOL?: boolean;
|
||||
hAlign?: 'left' | 'middle' | 'right';
|
||||
vAlign?: 'top' | 'center' | 'bottom';
|
||||
}
|
||||
|
||||
interface Box {
|
||||
stringify(): string;
|
||||
settings: {
|
||||
width: number;
|
||||
height: number;
|
||||
marks: Marks;
|
||||
lines: Array<{
|
||||
text: string;
|
||||
offset: {
|
||||
y: number;
|
||||
}
|
||||
}>
|
||||
};
|
||||
options: {
|
||||
width: number;
|
||||
height: number;
|
||||
marks: Marks;
|
||||
fullscreen: boolean;
|
||||
stringify: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
interface BoxConstructor {
|
||||
new(options: Options | string, text?: Text | string): Box;
|
||||
(options: (Exclude<Options, 'stringify'> & { stringify: true }), text?: Text | string): string;
|
||||
(options: Options | string, text?: Text | string): Box;
|
||||
defaults: { marks: Marks };
|
||||
}
|
||||
|
||||
declare const Box: BoxConstructor;
|
||||
@@ -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",
|
||||
"cli-box-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user