From 0baafbd4c62f6922b85e14a99eb804dc8cf2b22e Mon Sep 17 00:00:00 2001 From: surunzi Date: Sun, 4 Sep 2016 14:55:44 +0800 Subject: [PATCH] Add: Console api doc --- README.md | 16 ++++++++-------- doc/Tool_Api.md | 16 +++++++++++++++- package.json | 2 +- src/Network/Network.es6 | 2 +- src/lib/JsonViewer.es6 | 2 +- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 9e4c4ac..29b3156 100644 --- a/README.md +++ b/README.md @@ -33,14 +33,14 @@ javascript:(function () { var script = document.createElement('script'); script. ## Features -* Console: Display JavaScript logs. -* Elements: Check dom state. -* Network: Show performance timing, ajax requests status. -* Resource: Show localStorage, cookie information. -* Info: Show url, user agent info. -* Snippets: Include snippets used most often. -* Sources: Html, js, css source viewer. -* Features: Browser feature detections. +* [Console](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#console): Display JavaScript logs. +* [Elements](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#elements): Check dom state. +* [Network](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#network): Show performance timing, ajax requests status. +* [Resource](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#resources): Show localStorage, cookie information. +* [Info](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#info): Show url, user agent info. +* [Snippets](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#snippets): Include snippets used most often. +* [Sources](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#sources): Html, js, css source viewer. +* [Features](https://github.com/liriliri/eruda/blob/master/doc/Tool_Api.md#features): Browser feature detections. ## Install diff --git a/doc/Tool_Api.md b/doc/Tool_Api.md index e6992e8..d341702 100644 --- a/doc/Tool_Api.md +++ b/doc/Tool_Api.md @@ -1,7 +1,21 @@ # Tool Api +Each default tool provided by eruda can be accessed by `eruda.get('Tool Name')`. + ## Console +Displays console logs. Implementation detail follows the [console api spec](https://github.com/DeveloperToolsWG/console-object/blob/master/api.md). + +### log, error, info, warn, dir, time/timeEnd, clear, count, assert, table + +All these methods can be used in the same way as window.console object. + +```javascript +var console = eruda.get('console'); +console.log('eruda is a console for %s.', 'mobile browsers'); +console.table([{test: 1}, {test: 2, test2: 3}], 'test'); +``` + ## Elements ## Network @@ -16,4 +30,4 @@ ## Features -## Settings \ No newline at end of file +## Settings diff --git a/package.json b/package.json index 5a70085..1a424a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eruda", - "version": "1.1.1", + "version": "1.1.2", "description": "Console for Mobile Browsers", "main": "eruda.js", "scripts": { diff --git a/src/Network/Network.es6 b/src/Network/Network.es6 index 5c39bc4..8f4fb6c 100644 --- a/src/Network/Network.es6 +++ b/src/Network/Network.es6 @@ -220,7 +220,7 @@ export default class Network extends Tool data.push(getData('Total', navigationStart, loadEventEnd)); data.push(getData('Network/Server', navigationStart, responseStart)); - data.push(getData('App cache', fetchStart, domainLookupStart)); + data.push(getData('App Cache', fetchStart, domainLookupStart)); data.push(getData('DNS', domainLookupStart, domainLookupEnd)); data.push(getData('TCP', connectStart, connectEnd)); data.push(getData('Time to First Byte', requestStart, responseStart)); diff --git a/src/lib/JsonViewer.es6 b/src/lib/JsonViewer.es6 index 981377e..5e5fbb3 100644 --- a/src/lib/JsonViewer.es6 +++ b/src/lib/JsonViewer.es6 @@ -126,6 +126,6 @@ function createEl(key, val, firstLevel) } -const LIGHTER_KEY = ['__proto__', 'constructor', 'toString', 'valueOf']; +const LIGHTER_KEY = ['__proto__', 'constructor', 'toString', 'valueOf', 'length']; var encode = str => util.escape(util.toStr(str)); \ No newline at end of file