Stable Buffers in Motoko.
This is a breaking change , as it now follows the [var ?X]
array convention adapted by the Buffer class in the motoko-base library in late October '22 (previously the internal elements were [var X]
).
Inspiration taken from this back and forth in the Dfinity developer forums.
API documentation for this library can be found at https://canscale.github.io/StableBuffer
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.
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<Nat>();
B.add(b, 5);
// initialize from an existing Array
stable let b = B.fromArray<Nat>([1,2,3,4,5]);
// for more, check out the API Documentation -> https://canscale.github.io/StableBuffer
StableBuffer is distributed under the terms of the Apache License (Version 2.0).
See LICENSE for details.