Skip to content

Commit

Permalink
update name and example
Browse files Browse the repository at this point in the history
  • Loading branch information
krisselden committed Feb 2, 2016
1 parent 3b49944 commit 56087e9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
chrome-devtools-client
======================
chrome-debugging-client
=======================

Example:

```js
import { createSession } from "./index";

createSession(async (session) => {
let process = await session.spawn("canary");
let client = session.createAPIClient("localhost", process.remoteDebuggingPort);
let version = await client.version();
console.log(JSON.stringify(version, null, 2));
let tabs = await client.listTabs();
let tab = tabs[0];
await client.activateTab(tab.id);
let debugging = await session.openDebuggingProtocol(tab.webSocketDebuggerUrl);
await debugging.send("HeapProfiler.enable", {});
let buffer = "";
debugging.on("HeapProfiler.addHeapSnapshotChunk", (evt) => {
buffer += evt.chunk;
});
await debugging.send("HeapProfiler.takeHeapSnapshot", {});
return JSON.parse(buffer);
}).then((data) => {
console.log(data.snapshot.meta);
}).catch((err) => {
console.error(err);
});
```
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"name": "chrome-devtools-client",
"name": "chrome-debugging-client",
"version": "0.1.0",
"description": "Chrome DevTools client",
"description": "Chrome debugging client",
"keywords": [
"chrome",
"debugging",
"protocol"
],
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
Expand All @@ -19,5 +24,6 @@
"devDependencies": {
"tslint": "^3.3.0",
"typescript": "^1.8.0"
}
},
"engine": "node >= 4.0.0"
}
4 changes: 2 additions & 2 deletions test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ createSession(async (session) => {
let debugging = await session.openDebuggingProtocol(tab.webSocketDebuggerUrl);
await debugging.send("HeapProfiler.enable", {});
let buffer = "";
debugging.on("HeapProfiler.addHeapSnapshotChunk", (evt: {chunk: string}) => {
debugging.on("HeapProfiler.addHeapSnapshotChunk", (evt) => {
buffer += evt.chunk;
});
await debugging.send("HeapProfiler.takeHeapSnapshot", {});
return JSON.parse(buffer);
}).then((data) => {
console.log(data.snapshot.meta)
console.log(data.snapshot.meta);
}).catch((err) => {
console.error(err);
});

0 comments on commit 56087e9

Please sign in to comment.