Skip to content

Commit

Permalink
Add section 'Typescript usage' to README
Browse files Browse the repository at this point in the history
Add instructions to install additional type declartions if using
Typescript. Also fixes a few minor typos.
  • Loading branch information
windupbird144 committed Nov 1, 2021
1 parent aa18924 commit 676205a
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions README.md
Expand Up @@ -18,7 +18,7 @@ npm i pino-abstract-transport
```js
import build from 'pino-abstract-transport'

exports default async function (opts) {
export default async function (opts) {
return build(async function (source) {
for await (let obj of source) {
console.log(obj)
Expand All @@ -43,6 +43,20 @@ module.exports = function (opts) {
}
```

## Typescript usage
Install the type definitions for [duplexify](https://github.com/mafintosh/duplexify) and node.

#### Node 16
```
npm i -D @types/node @types/duplexify
```

#### Node < 16
If you are using an older version of node, make sure @types/node is on the same major version as your node version. For example if you are using node 14:
```
npm i -D @types/node@14 @types/duplexify
```

## API

### build(fn, opts) => Stream
Expand All @@ -60,7 +74,7 @@ so they can be concatenated into multiple transports.
In addition to all events emitted by a [`Readable`](https://nodejs.org/api/stream.html#stream_class_stream_readable)
stream, it emits the following events:

* `unknown` where an unparsaeble line is found, both the line and optional error is emitted.
* `unknown` where an unparsable line is found, both the line and optional error is emitted.

#### Options

Expand All @@ -69,7 +83,7 @@ stream, it emits the following events:
* `close(err, cb)` a function that is called to shutdown the transport. It's called both on error and non-error shutdowns.
It can also return a promise. In this case discard the the `cb` argument.

* `parseLine(line)` a function that is used to parse line recieved from `pino`.
* `parseLine(line)` a function that is used to parse line received from `pino`.

## Example

Expand Down

0 comments on commit 676205a

Please sign in to comment.