Skip to content

Commit

Permalink
some more less is more treatment
Browse files Browse the repository at this point in the history
  • Loading branch information
premiering committed Jul 10, 2024
1 parent 8525a5f commit c23b741
Showing 1 changed file with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
# byffer.ts
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/premiering/byffer.ts/node.js.yml)
![NPM Version](https://img.shields.io/npm/v/byffer.ts)
~250 line TS library for byte buffer manipulation

find it on npm [here](https://www.npmjs.com/package/byffer.ts).

An easy library to read and manipulate byte buffers in TypeScript.

It is also on `npm` [here](https://www.npmjs.com/package/byffer.ts).

## Installation
Installation is made easy with `npm`
## install it
use npm:
```shell
npm install byffer.ts
```
or just copy paste the [byffer.ts file](https://github.com/premiering/byffer.ts/blob/main/src/byffer.ts) since it's so small

## Using byffer.ts
You can create a `ByteBuf` instance to store and read manipulate your data.
## using byffer.ts
create a `ByteBuf` instance to store and read manipulate your data.

It can be created empty, or using pre-existing data.
it can be created empty, or using pre-existing data

Here's an example of using byffer.ts:
example:
```ts
import ByteBuf from 'byffer.ts';

// Create an empty buffer with 128 bytes
let buf: ByteBuf = ByteBuf.emptyBuffer(128);
// or, use an existing ArrayBuffer like class (ArrayBufferLike)
buf = ByteBuf.from(awesome_buffer);
buf = ByteBuf.from(some_buffer);

// You can then write some data
buf.writeInt(1337);
buf.writeByteUnsigned(255);
buf.writeByteString("I'm saying hi, from byffer!");
buf.writeByteString("i'm saying hi, from byffer!");
buf.writeFloat(-999999.3125);

// Then you can take back the data as an ArrayBuffer
Expand All @@ -39,9 +36,9 @@ let data: ArrayBuffer = buf.bytes();
// Or, read the data
let i = buf.readInt(); // Returns 1337
let b = buf.readByteUnsigned(); // Returns 255
let s = buf.readByteString(); // Returns "I'm saying hi, from byffer!"
let s = buf.readByteString(); // Returns "i'm saying hi, from byffer!"
let f = buf.readFloat(); // Returns -999999.3125
```

## License
byffer.ts is licensed under the MIT license. You can do pretty much whatever you want to with this code.
## license
using MIT license, do whatever

0 comments on commit c23b741

Please sign in to comment.