Skip to content

Commit

Permalink
style: 🎨 format code with prettier (#2)
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in cad9e49 according to the output
from prettier.

Details: https://deepsource.io/gh/MinecraftJS/BufWrapper/transform/7bb25fdb-2a18-4790-87c3-eb1833ed8694/

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
  • Loading branch information
deepsource-autofix[bot] authored Mar 30, 2022
1 parent cad9e49 commit 38814da
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
Encode and decode data using buffers

# Features

Encore and decode:

- Varint
- String
- Int
Expand All @@ -16,11 +18,15 @@ Encore and decode:
# Documentation

## Installation

Install the package:

```bash
$ npm install @minecraftjs/bufwrapper # Not available now
```

And then import it in your JavaScript/TypeScript file

```ts
const BufWrapper = require('@minecraft-js/bufwrapper'); // CommonJS

Expand All @@ -30,10 +36,13 @@ import BufWrapper from '@minecraft-js/bufwrapper'; // ES6
## Writing a buffer

First, instantiate a new BufWrapper

```js
const buf = new BufWrapper();
```

And then you can use any method to write data into it

```js
buf.writeInt(42);
buf.writeString('Hello World');
Expand All @@ -43,12 +52,16 @@ buf.writeLong(123456789);
## Reading a buffer

To read a buffer content, you need to instantiate a new BufWrapper and pass the buffer to the constructor

```js
// Buffer with dummy data
const buffer = Buffer.from('0000002a0b48656c6c6f20576f726c6400000000075bcd15', 'hex');
const buffer = Buffer.from(
'0000002a0b48656c6c6f20576f726c6400000000075bcd15',
'hex'
);

const buf = new BufWrapper();
buf.readInt(); // 42
buf.readString(); // 'Hello World'
buf.readLong(); // 123456789
```
```

0 comments on commit 38814da

Please sign in to comment.