Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/canscale/StableBuffer
Stable Buffers in Motoko
https://github.com/canscale/StableBuffer
Last synced: 3 months ago
JSON representation
Stable Buffers in Motoko
- Host: GitHub
- URL: https://github.com/canscale/StableBuffer
- Owner: canscale
- License: apache-2.0
- Created: 2022-03-27T21:49:18.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-10T06:52:10.000Z (over 1 year ago)
- Last Synced: 2024-08-04T00:14:20.116Z (6 months ago)
- Language: Motoko
- Size: 65.4 KB
- Stars: 12
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-motoko - Stable Buffers - Stable (Heap-based) Buffers in Motoko. (Libraries / Data structures)
- awesome-motoko - Stable Buffers - Stable (Heap-based) Buffers in Motoko. (Libraries / Data structures)
README
# StableBuffer
Stable Buffers in Motoko.
## Note - Stable Buffer v1.0.0 has just been released.
This is a breaking change , as it now follows the `[var ?X]` array convention adapted by the [Buffer class in the motoko-base library](https://github.com/dfinity/motoko-base/blob/98c5717b283a8ec233907c3a3e92c79e3bbab1b3/src/Buffer.mo#L69) in late October '22 (previously the internal elements were `[var X]`).## Motivation
Inspiration taken from [this back and forth in the Dfinity developer forums](https://forum.dfinity.org/t/clarification-on-stable-types-with-examples/11075).## API Documentation
API documentation for this library can be found at https://canscale.github.io/StableBuffer
## About
This module is a direct deconstruction of the object oriented [Buffer.mo class in motoko-base]
(https://github.com/dfinity/motoko-base/blob/master/src/Buffer.mo)
into a series of functions and is meant to be persistent across updates, with the tradeoff
being larger function signatures.## Usage
Install vessel and ensure this is included in your package-set.dhall and vessel.dhall
```
import B "mo:stablebuffer/StableBuffer";
...// initialize and add to a Buffer
stable let b = B.init();
B.add(b, 5);// initialize from an existing Array
stable let b = B.fromArray([1,2,3,4,5]);// for more, check out the API Documentation -> https://canscale.github.io/StableBuffer
```## License
StableBuffer is distributed under the terms of the Apache License (Version 2.0).See LICENSE for details.