Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: fix API autocannon.print #508

Merged
merged 1 commit into from Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 20 additions & 5 deletions README.md
Expand Up @@ -393,13 +393,28 @@ Check out [this example](./samples/track-run.js) to see it in use, as well.

### autocannon.printResult(resultObject[, opts])

Print the result tables to the terminal, programmatically.
Returns a text string containing the result tables.

* `resultObject`: The result object of autocannon. _REQUIRED_.
* `opts`: Configuration options for printing the tables. This can have the following attributes. _OPTIONAL_.
* `outputStream`: The stream to output to. default: `process.stderr`.
* `renderResultsTable`: A truthy value to enable the rendering of the results table. default: `true`.
* `renderLatencyTable`: A truthy value to enable the rendering of the latency table. default: `false`.
* `opts`: Configuration options for generating the tables. These may include the following attributes. _OPTIONAL_.
* `outputStream`: The stream to which output is directed. It is primarily used to check if the terminal supports color. default: `process.stderr`.
* `renderResultsTable`: A truthy value to enable the creation of the results table. default: `true`.
* `renderLatencyTable`: A truthy value to enable the creation of the latency table. default: `false`.

Example:

```js
"use strict";

const { stdout } = require("node:process");
const autocannon = require("autocannon");

function print(result) {
stdout.write(autocannon.printResult(result));
}

autocannon({ url: "http://localhost:3000" }, (err, result) => print(result));
```

### autocannon.aggregateResult(results[, opts])

Expand Down