Skip to content

Commit 032024e

Browse files
author
Eran Levin
committed
add definition files
1 parent 6a9f02f commit 032024e

File tree

4 files changed

+148
-0
lines changed

4 files changed

+148
-0
lines changed

src/browser.d.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
export=browser
2+
declare namespace browser
3+
{
4+
/**
5+
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
6+
* and the Firebug extension (any Firefox version) are known
7+
* to support "%c" CSS customizations.
8+
*
9+
* TODO: add a `localStorage` variable to explicitly enable/disable colors
10+
*/
11+
function useColors(): boolean;
12+
13+
/**
14+
* Colorize log arguments if enabled.
15+
*
16+
* @api public
17+
*/
18+
function formatArgs(args: string[]): void;
19+
20+
/**
21+
* Save `namespaces`.
22+
*
23+
* @param {String} namespaces
24+
* @api private
25+
*/
26+
function save(namespaces: string): void;
27+
28+
/**
29+
* Load `namespaces`.
30+
*
31+
* @return {String} returns the previously persisted debug modes
32+
* @api private
33+
*/
34+
function load(): string;
35+
36+
/**
37+
* Localstorage attempts to return the localstorage.
38+
*
39+
* This is necessary because safari throws
40+
* when a user disables cookies/localstorage
41+
* and you attempt to access it.
42+
*
43+
* @return {LocalStorage}
44+
* @api private
45+
*/
46+
function localstorage(): Storage;
47+
48+
const formatters: { j: (str:string) => string };
49+
}

src/common.d.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
type DebugNamespace = {
2+
(...args: string[]): void;
3+
namespace: string;
4+
enabled: boolean;
5+
useColors: boolean;
6+
color: number | string;
7+
destroy: () => boolean;
8+
extend: (namespace: string, delimiter: string) => DebugNamespace;
9+
};
10+
11+
type DebugType = {
12+
(namespace: string): DebugNamespace;
13+
debug: DebugType;
14+
default: DebugNamespace;
15+
coerce: <T>(val: T) => T;
16+
disable: () => string;
17+
enable: (namespaces: string) => void;
18+
enabled: (name: string) => boolean;
19+
humanize: (timeInMs:number)=>string;
20+
/**
21+
* Active `debug` instances.
22+
*/
23+
instances: DebugNamespace[];
24+
/**
25+
* The currently active debug mode names, and names to skip.
26+
*/
27+
names: string[];
28+
skips: string[];
29+
/**
30+
* Map of special "%n" handling functions, for the debug "format" argument.
31+
*
32+
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
33+
*/
34+
formatters: {};
35+
selectColor: (namespace: string) => number;
36+
};
37+
38+
/**
39+
* This is the common logic for both the Node.js and web browser
40+
* implementations of `debug()`.
41+
*/
42+
43+
import node = require("node");
44+
import browser = require("browser");
45+
declare function setup(env:typeof node|typeof browser ): DebugType;

src/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Detect Electron renderer / nwjs process, which is node, but we should
3+
* treat as a browser.
4+
*/
5+
import node = require("node");
6+
import browser = require("browser");
7+
type isBrowser=typeof window;
8+
type index=isBrowser extends Object? typeof browser: typeof node;
9+
export=index;

src/node.d.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Module dependencies.
3+
*/
4+
import TTY=require("tty");
5+
import Util=require("util");
6+
7+
declare const tty: typeof TTY;
8+
declare const util: typeof Util;
9+
/**
10+
* Is stdout a TTY? Colored output is enabled when `true`.
11+
*/
12+
declare function useColors(): boolean;
13+
/**
14+
* Adds ANSI color escape codes if enabled.
15+
*
16+
* @api public
17+
*/
18+
declare function formatArgs(args: any): void;
19+
declare function getDate(): string;
20+
/**
21+
* Invokes `util.format()` with the specified arguments and writes to stderr.
22+
*/
23+
declare function log(...args: any[]): boolean;
24+
/**
25+
* Save `namespaces`.
26+
*
27+
* @param {String} namespaces
28+
* @api private
29+
*/
30+
declare function save(namespaces: string): void;
31+
/**
32+
* Load `namespaces`.
33+
*
34+
* @return {String} returns the previously persisted debug modes
35+
* @api private
36+
*/
37+
declare function load(): string;
38+
/**
39+
* Init logic for `debug` instances.
40+
*
41+
* Create a new `inspectOpts` object in case `useColors` is set
42+
* differently for a particular `debug` instance.
43+
*/
44+
declare function init(debug: any): void;
45+
declare const formatters: {o:()=>string,O:()=>string};

0 commit comments

Comments
 (0)