Skip to content

Commit 329042c

Browse files
committed
improve README
1 parent fbf1aa8 commit 329042c

File tree

1 file changed

+15
-30
lines changed

1 file changed

+15
-30
lines changed

README.md

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ npm install rtp.js
1616

1717
- [API documentation](https://versatica.github.io/rtp.js)
1818

19-
- All RTP and RTCP classes, types and packet related helpers are exported by the `packets` module.
19+
- All RTP and RTCP classes, types and packet related helpers are exported by the `packets` module:
2020

2121
```ts
22-
import * as packets from 'rtp.js/packets';
23-
24-
const {
22+
import {
2523
isRtp,
2624
isRtcp,
2725
RtpPacket,
@@ -41,21 +39,15 @@ npm install rtp.js
4139
ExtendedJitterReportsPacket,
4240
GenericPacket,
4341
// etc.
44-
} = packets;
45-
```
46-
47-
```ts
48-
import { RtpPacket } from 'rtp.js/packets';
42+
} from 'rtp.js/packets';
4943

5044
const rtpPacket = new RtpPacket();
5145
```
5246

53-
- The `utils` module exports some generic helpers and utilities.
47+
- The `utils` module exports some generic helpers and utilities:
5448

5549
```ts
56-
import * as utils from 'rtp.js/utils';
57-
58-
const {
50+
import {
5951
padTo4Bytes,
6052
nodeBufferToDataView,
6153
dataViewToNodeBuffer,
@@ -68,36 +60,29 @@ npm install rtp.js
6860
stringToDataView,
6961
getStringByteLength,
7062
// etc.
71-
} = utils;
72-
```
73-
74-
```ts
75-
import { stringToDataView } from 'rtp.js/utils';
63+
} from 'rtp.js/utils';
7664

77-
const view = utils.stringToDataView('fooœæ€ñ#¢∞Ω©bar');
65+
const view = stringToDataView('fooœæ€ñ#¢∞Ω©bar');
7866
```
7967

8068
- CommonJS is also supported:
8169

8270
```ts
83-
const packets = require('rtp.js/packets');
84-
const utils = require('rtp.js/utils');
71+
const { RtpPacket /* etc. */ } = require('rtp.js/packets');
72+
const { padTo4Bytes /* etc. */ } = require('rtp.js/utils');
8573
```
8674

87-
```ts
88-
const { RtpPacket } = require('rtp.js/packets');
89-
90-
const rtpPacket = new RtpPacket();
91-
```
92-
93-
- Single entry point ("main" or "module" entries in `package.json`) is also possible for backwards compatibility:
75+
- Single entry point ("main" or "module" entries in `package.json`) is also supported for backwards compatibility:
9476

9577
```ts
9678
// Using ESM:
97-
import { packets, utils } from 'rtp.js';
79+
import { packets as rtpJsPackets, utils as rtpJsUtils } from 'rtp.js';
9880

9981
// Using CJS:
100-
const { packets, utils } = require('rtp.js');
82+
const { packets: rtpJsPackets, utils: rtpJsUtils } = require('rtp.js');
83+
84+
const { RtpPacket /* etc. */ } = rtpJsPackets;
85+
const { padTo4Bytes /* etc. */ } = rtpJsUtils;
10186
```
10287

10388
## Note about TypeScript

0 commit comments

Comments
 (0)