Skip to content

Commit bea76bb

Browse files
committed
update readme
1 parent 5834f6f commit bea76bb

File tree

1 file changed

+9
-65
lines changed

1 file changed

+9
-65
lines changed

README.md

Lines changed: 9 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
- Supports both Node.js and browser environments.
1010
- Provides an easy-to-use API for handling binary data.
11-
- Utilizes `ArrayBuffer` and `DataView` for efficient binary data manipulation.
1211
- Methods for reading and writing various data types (integers, floats, strings, etc.).
12+
- Allows for dynamic buffer creation without worrying about resizing.
1313

1414
## Installation
1515

@@ -32,7 +32,7 @@ bun install @pocketnode/binarystream
3232
In a TypeScript or JavaScript file, import the `BinaryStream` module:
3333

3434
```typescript
35-
import { BinaryStream } from "binarystream";
35+
import { BinaryStream } from "@pocketnode/binarystream";
3636
```
3737

3838
### Creating a BinaryStream Instance
@@ -48,49 +48,27 @@ const buffer = new ArrayBuffer(1024);
4848
const streamFromBuffer = new BinaryStream(buffer);
4949
```
5050

51-
### Writing Data
52-
53-
The `BinaryStream` class provides methods to write various data types:
54-
55-
```typescript
56-
stream.writeUint8(255); // Write an unsigned 8-bit integer
57-
stream.writeInt16(-32768); // Write a signed 16-bit integer
58-
stream.writeFloat32(3.14); // Write a 32-bit float
59-
stream.writeString("Hello"); // Write a string
60-
```
61-
62-
### Reading Data
63-
64-
Similarly, you can read data using corresponding methods:
65-
66-
```typescript
67-
const uint8 = stream.readUint8(); // Read an unsigned 8-bit integer
68-
const int16 = stream.readInt16(); // Read a signed 16-bit integer
69-
const float32 = stream.readFloat32(); // Read a 32-bit float
70-
const str = stream.readString(); // Read a string
71-
```
72-
7351
### Example
7452

7553
Here is a complete example demonstrating how to write and read data using `BinaryStream`:
7654

7755
```typescript
78-
import { BinaryStream } from "binarystream";
56+
import { BinaryStream } from "@pocketnode/binarystream";
7957

8058
// Create a BinaryStream with a new ArrayBuffer of 1024 bytes
8159
const stream = new BinaryStream(1024);
8260

8361
// Write data to the stream
84-
stream.writeUint8(255);
62+
stream.writeUInt8(255);
8563
stream.writeInt16(-32768);
8664
stream.writeFloat32(3.14);
8765
stream.writeString("Hello, BinaryStream!");
8866

8967
// Reset the position to the beginning of the stream for reading
90-
stream.position = 0;
68+
stream.flip();
9169

9270
// Read data from the stream
93-
const uint8 = stream.readUint8();
71+
const uint8 = stream.readUInt8();
9472
const int16 = stream.readInt16();
9573
const float32 = stream.readFloat32();
9674
const str = stream.readString();
@@ -101,48 +79,14 @@ console.log(float32); // 3.14
10179
console.log(str); // Hello, BinaryStream!
10280
```
10381

104-
## API Documentation
105-
106-
### BinaryStream
107-
108-
#### Constructor
109-
110-
- `new BinaryStream(size: number): BinaryStream`
111-
- `new BinaryStream(buffer: ArrayBuffer): BinaryStream`
112-
113-
#### Methods
114-
115-
- `writeUint8(value: number): void`
116-
- `writeInt16(value: number): void`
117-
- `writeFloat32(value: number): void`
118-
- `writeString(value: string): void`
119-
120-
- `readUint8(): number`
121-
- `readInt16(): number`
122-
- `readFloat32(): number`
123-
- `readString(): string`
124-
125-
#### Properties
126-
127-
- `position: number` - The current read/write position in the buffer.
128-
- `buffer: ArrayBuffer` - The underlying `ArrayBuffer`.
129-
13082
## Compatibility
13183

132-
`BinaryStream` works in both Node.js and browser environments. It relies on `ArrayBuffer` and `DataView`, which are available in modern browsers and Node.js.
84+
`BinaryStream` works in both Node.js and browser environments. It relies on `ArrayBuffer` and `DataView`, which are available in [modern browsers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/transfer#browser_compatibility) and Node.js.
13385

13486
## License
13587

136-
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
137-
138-
## Contributing
139-
140-
Contributions are welcome! Please read the [CONTRIBUTING](CONTRIBUTING.md) guidelines for more information.
88+
This project is licensed under the GNU GPLv3 License. See the [LICENSE](LICENSE) file for details.
14189

14290
## Contact
14391

144-
For questions or feedback, please open an issue on the [GitHub repository](https://github.com/yourusername/binarystream).
145-
146-
---
147-
148-
Thank you for using `BinaryStream`! We hope it simplifies your binary data handling tasks.
92+
For questions or feedback, please open an issue on [GitHub](https://github.com/pocketnode/binarystream).

0 commit comments

Comments
 (0)