Merge pull request #31816 from mike-north/treeify

[new package] Types for treeify
This commit is contained in:
Sheetal Nandi
2019-01-02 12:26:18 -08:00
committed by GitHub
4 changed files with 83 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
// Type definitions for tress 1.0
// Project: https://github.com/notatestuser/treeify
// Definitions by: Mike North <https://github.com/mike-north>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export interface TreeObject {
[k: string]: TreeValue;
}
export type TreeValue = string | TreeObject;
export function asTree(
treeObj: TreeObject,
showValues: boolean,
hideFunctions: boolean
): string;
export function asLines(
treeObj: TreeObject,
showValues: boolean,
lineCallback: (line: string) => void
): string;
export function asLines(
treeObj: TreeObject,
showValues: boolean,
hideFunctions: boolean,
lineCallback: (line: string) => void
): string;
+35
View File
@@ -0,0 +1,35 @@
import * as treeify from 'treeify';
function log(s: string): void {}
treeify.asTree(
{
apples: 'gala', // ├─ apples: gala
oranges: 'mandarin' // └─ oranges: mandarin
},
true,
true
);
treeify.asLines(
{
apples: 'gala', // ├─ apples: gala
oranges: 'mandarin', // ├─ oranges: mandarin
grapes: { // └─ grapes
seedless: 'Thompson, Selma Pete', // ├─ seedless: Thompson, Selma Pete
seeded: 'concord' // └─ seeded: Concord
}
},
true,
log
);
treeify.asLines(
{
apples: 'gala', // ├─ apples: gala
oranges: 'mandarin' // └─ oranges: mandarin
},
true,
false,
log
);
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": []
},
"files": ["index.d.ts", "treeify-tests.ts"]
}
+4
View File
@@ -0,0 +1,4 @@
{
"extends": "dtslint/dt.json",
"rules": {}
}