Skip to content

Commit 2f75c82

Browse files
authored
Update README.md
1 parent 3a3cf9c commit 2f75c82

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Quick check if a Node.js Buffer or Uint8Array is UTF-8.
1111
`npm install isutf8`
1212

1313
## Usage
14+
15+
### commonjs
1416
```js
1517
'use strict';
1618

@@ -26,5 +28,18 @@ console.log(isUtf8(arr)); // => true
2628

2729
```
2830

31+
### ES Modules or TypeScript
32+
```js
33+
import isUtf8 from 'isutf8';
34+
35+
const buf = Buffer.from([0xd0, 0x90]);
36+
console.log(isUtf8(buf)); // => true
37+
38+
// or
39+
40+
const arr = new Uint8Array([0xd0, 0x90]);
41+
console.log(isUtf8(arr)); // => true
42+
```
43+
2944
## License
3045
[MIT License](./LICENSE)

0 commit comments

Comments
 (0)