Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hcodes committed Aug 27, 2024
1 parent 8a5f145 commit 05a032f
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
isutf8
======

Quick check if a Node.js Buffer or Uint8Array is UTF-8.
Quick check if a Node.js Buffer or Uint8Array is valid UTF-8.

## Install
`npm install isutf8`
Expand All @@ -15,17 +15,15 @@ Quick check if a Node.js Buffer or Uint8Array is UTF-8.

### CommonJS
```js
'use strict';

const isUtf8 = require('isutf8');

const buf = Buffer.from([0xd0, 0x90]);
console.log(isUtf8(buf)); // => true
console.log(isUtf8(buf)); // => boolean

// or

const arr = new Uint8Array([0xd0, 0x90]);
console.log(isUtf8(arr)); // => true
console.log(isUtf8(arr)); // => boolean

```

Expand All @@ -34,12 +32,12 @@ console.log(isUtf8(arr)); // => true
import isUtf8 from 'isutf8';

const buf = Buffer.from([0xd0, 0x90]);
console.log(isUtf8(buf)); // => true
console.log(isUtf8(buf)); // => boolean

// or

const arr = new Uint8Array([0xd0, 0x90]);
console.log(isUtf8(arr)); // => true
console.log(isUtf8(arr)); // => boolean
```

## License
Expand Down

0 comments on commit 05a032f

Please sign in to comment.