# as-buffers

> Some Buffer classes for AssemblyScript

Latest version **0.3.0** (published 2023-03-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install as-buffers
pnpm add as-buffers
yarn add as-buffers
bun add as-buffers
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2023-03-01 |
| First published | 2021-06-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 51 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | yjhmelody |
| Maintainers | yjhmelody |
| Keywords | assemblyscript, stringBuffer, bytesBuffer, bytes, string |

## Links

- npm: https://www.npmjs.com/package/as-buffers
- Repository: https://github.com/ask-lang/serde-as
- Homepage: https://github.com/ask-lang/serde-as#readme
- Issues: https://github.com/ask-lang/serde-as/issues
- npm.io page: https://npm.io/package/as-buffers

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2023-03-01
- 0.1.3 — 2022-08-12
- 0.1.2 — 2021-07-26
- 0.1.1 — 2021-07-20
- 0.1.0 — 2021-07-20
- 0.0.9 — 2021-07-19
- 0.0.7 — 2021-07-06
- 0.0.6 — 2021-07-01
- 0.0.5 — 2021-06-29
- 0.0.4 — 2021-06-28
- 0.0.3 — 2021-06-23

## README

# as-buffers

`as-buffers` provides some Buffer types for reading/writing string/bytes efficiently and simply.

<!-- TODO: more docs -->

## Usage

There are 2 useful buffer classes here: `BytesBuffer` and `StringBuffer`.

-   `BytesBuffer` provides bytes related/endian related methods.
-   `StringBuffer`(is forked from [MaxGraey](https://github.com/MaxGraey/as-string-sink)) provides string (UTF16) related methods.

### Write/Read bytes

```ts
let buf = BytesBuffer.wrap(new ArrayBuffer(0));
let val = 0x11 as i8;
buf.writeNumberBE<i8>(val);
let res = buf.readNumberBE<i8>(0);
expect(res).toBe(val);
```

### Write/Read string

```ts
let buf = new StringBuffer();
buf.write("hello");
expect(buf.toString()).toBe("hello");
```

### More usages

In addition to some safe methods, they also have some unsafe methods to improve performance. You need to pay attention to the buffer capacity and read/write offset.

See unit tests and source comments.

---
_Source: https://npm.io/package/as-buffers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
