From fe09ccfd68e9fcab455b584e5b2d82f40cd95ae4 Mon Sep 17 00:00:00 2001 From: Seon-Wook Park Date: Sat, 25 Oct 2014 02:32:13 +0200 Subject: [PATCH 1/2] Add visionmedia/debug, a tiny npm package for debugging --- debug/debug-tests.ts | 20 ++++++++++++++++++++ debug/debug.d.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 debug/debug-tests.ts create mode 100644 debug/debug.d.ts diff --git a/debug/debug-tests.ts b/debug/debug-tests.ts new file mode 100644 index 000000000..63a0a3ac4 --- /dev/null +++ b/debug/debug-tests.ts @@ -0,0 +1,20 @@ +/// +/// + +import debug = require("debug"); + +debug.disable(); +debug.enable("DefinitelyTyped:*"); + +var log: debug.Debugger = debug("DefinitelyTyped:log"); + +log("Just text"); +log("Formatted test (%d arg)", 1); +log("Formatted %s (%d args)", "test", 2); + +log("Enabled?: %s", debug.enabled("DefinitelyTyped:log")); +log("Namespace: %s", log.namespace); + +var error: debug.Debugger = debug("DefinitelyTyped:error"); +error.log = console.error.bind(console); +error("This should be printed to stderr"); diff --git a/debug/debug.d.ts b/debug/debug.d.ts new file mode 100644 index 000000000..1a71725a8 --- /dev/null +++ b/debug/debug.d.ts @@ -0,0 +1,30 @@ +// Type definitions for debug +// Project: https://github.com/visionmedia/debug +// Definitions by: Seon-Wook Park +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "debug" { + + function d(namespace: string): d.Debugger; + + module d { + export var log: Function; + + function enable(namespaces: string): void; + function disable(): void; + + function enabled(namespace: string): boolean; + + export interface Debugger { + (formatter: any, ...args: any[]): void; + + enabled: boolean; + log: Function; + namespace: string; + } + } + + export = d; + +} + From 3fd8df8c07b007567dc8b53731e273107e8e18d0 Mon Sep 17 00:00:00 2001 From: Seon-Wook Park Date: Sat, 25 Oct 2014 02:35:20 +0200 Subject: [PATCH 2/2] Add package debug to CONTRIBUTORS.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 84f0c9190..c0bbb6e20 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -67,6 +67,7 @@ All definitions files include a header with the author and editors, so at some p * [Crossfilter](https://github.com/square/crossfilter) (by [Schmulik Raskin](https://github.com/schmuli)) * [crypto-js](https://code.google.com/p/crypto-js/) (by [Gia Bảo @ Sân Đình](https://github.com/giabao)). @see [cryptojs.d.ts repo](https://github.com/giabao/cryptojs.d.ts) * [d3.js](http://d3js.org/) (from TypeScript samples) +* [debug](https://github.com/visionmedia/debug) (by [Seon-Wook Park](https://github.com/swook)) * [dhtmlxGantt](http://dhtmlx.com/docs/products/dhtmlxGantt) (by [Maksim Kozhukh](http://github.com/mkozhukh)) * [dhtmlxScheduler](http://dhtmlx.com/docs/products/dhtmlxScheduler) (by [Maksim Kozhukh](http://github.com/mkozhukh)) * [diff](https://github.com/kpdecker/jsdiff) (by [vvakame](http://github.com/vvakame))