Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sail-sail/buffer_list
A Deno Buffer list collector, reader and streamer thingy.
https://github.com/sail-sail/buffer_list
Last synced: 6 days ago
JSON representation
A Deno Buffer list collector, reader and streamer thingy.
- Host: GitHub
- URL: https://github.com/sail-sail/buffer_list
- Owner: sail-sail
- Created: 2022-05-23T07:18:24.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-23T07:30:17.000Z (over 2 years ago)
- Last Synced: 2024-12-10T21:26:15.966Z (2 months ago)
- Language: JavaScript
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# buffer_list (BufferList)
A Deno Buffer list collector, reader and streamer thingy.
buffer_list is a storage object for collections of Node Buffers, exposing them with the main Buffer readable API. Also works as a duplex stream so you can collect buffers from a stream that emits them and emit buffers to a stream that consumes them!
The original buffers are kept intact and copies are only done as necessary. Any reads that require the use of a single original buffer will return a slice of that buffer only (which references the same memory as the original buffer). Reads that span buffers perform concatenation as required and return the results transparently.
fork by https://github.com/rvagg/bl
## usage
```ts
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { Buffer } from "https://deno.land/[email protected]/node/buffer.ts";
import { BufferList } from "https://deno.land/x/[email protected]/mod.ts";Deno.test("bufferList", function() {
const bufferList = new BufferList();
bufferList.append(Buffer.from('abcd'));
assertEquals(bufferList.length, 4);
assertEquals(bufferList.get(0), 97);
assertEquals(bufferList.get(1), 98);
assertEquals(bufferList.get(2), 99)
assertEquals(bufferList.get(3), 100)
assertEquals(bufferList.get(4), undefined)
});
```