Skip to content

Commit

Permalink
doc: fix API autocannon.print (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
casantosmu committed Jan 9, 2024
1 parent 75cbb4d commit ac8169c
Showing 1 changed file with 20 additions and 5 deletions.
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

0 comments on commit ac8169c

Please sign in to comment.