Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kritzcreek/purescript-dynamic-buffer
Growing Buffers
https://github.com/kritzcreek/purescript-dynamic-buffer
Last synced: about 1 hour ago
JSON representation
Growing Buffers
- Host: GitHub
- URL: https://github.com/kritzcreek/purescript-dynamic-buffer
- Owner: kritzcreek
- License: mpl-2.0
- Created: 2020-11-06T20:48:13.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-06T08:23:41.000Z (over 2 years ago)
- Last Synced: 2024-10-11T23:55:02.673Z (26 days ago)
- Language: PureScript
- Size: 17.6 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# purescript-dynamic-buffer
Growable buffers
Can be used to build up binary data. Inspired by OCaml's buffer type.
This is a small, minimal library, with very few dependencies, which
should be reasonably fast.If you're looking for a general purpose library and don't mind a few
extra dependencies you should first take a look at
[`arraybuffer-builder`](https://github.com/jamesdbrock/purescript-arraybuffer-builder).## Examples
```purescript
module Main whereimport Prelude
import Data.Array as Array
import Data.Traversable (for_)
import DynamicBuffer as DBuffer
import Effect (Effect)
import Effect.Console as Consolemain :: Effect Unit
main = do
buf <- DBuffer.create 8
for_ (Array.range 1 10) do
DBuffer.addByte buf
Console.log (DBuffer.debugToString buf)
-- [0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA]
```For a more comprehensive usage check out my [encoder for the WebAssembly binary format](https://github.com/kritzcreek/purescript-wasm/blob/main/src/Wasm/Encode.purs).
More examples can also be found in the [testsuite](./test/Main.purs)
## License
Copyright 2020 Christoph HegemannThis software is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.