2016-05-10 5 views
0

Canaryデベロッパーツールは、console.tableconsole.dirのような素晴らしい機能を提供しています。これらの機能は、オブジェクトで利用可能なさまざまな機能とプロパティに関する詳細を示します。Node.jsコンソールでオブジェクトAPIを検出する方法は?

Node.js REPLでこれが何とか可能かどうかを知りたいと思います。私は、ブラウザの開発者向けツールで素晴らしい仕事いくつかの組み合わせを試してみた:

> console.dir(Promise) 
[Function: Promise] 
undefined 
> console.log(Promise) 
[Function: Promise] 
undefined 
> Promise 
[Function: Promise] 
> console.table(Promise) 
TypeError: console.table is not a function 
    at repl:1:9 
    at REPLServer.defaultEval (repl.js:248:27) 
    at bound (domain.js:280:14) 
    at REPLServer.runBound [as eval] (domain.js:293:12) 
    at REPLServer.<anonymous> (repl.js:412:12) 
    at emitOne (events.js:82:20) 
    at REPLServer.emit (events.js:169:7) 
    at REPLServer.Interface._onLine (readline.js:210:10) 
    at REPLServer.Interface._line (readline.js:549:8) 
    at REPLServer.Interface._ttyWrite (readline.js:826:14) 

私はMDNやNode.jsのドキュメントを開くことなくノード内のこれらの機能などについてのアクセスおよびドキュメントを入手するにはどうすればよいですか?

答えて

2

Promiseのプロパティはすべて列挙できないため、ノードのログからはデフォルトでは非表示になっています。あなたはそれらを表示するためにshowHidden option of Node's console.dirを使用することができます。

showHidden - if true then the object's non-enumerable and symbol properties will be shown too. Defaults to false .

あなたがconsole.dir(Promise, { showHidden: true })を実行すると、オブジェクトのすべてのプロパティが表示されます。

+0

これは素晴らしい作品です! http://pastebin.com/raw/VaxxL0BGありがとう:) –

+0

Hmm、 '> console.dir(文字列、{showHidden:true})'私に 'TypeError:シンボル値を数値に変換できません。 –

関連する問題