time-to-botec/squiggle/node_modules/@stdlib/utils/circular-buffer/docs/repl.txt
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00

58 lines
1.3 KiB
Plaintext

{{alias}}( buffer )
Circular buffer constructor.
Parameters
----------
buffer: integer|ArrayLike
Buffer size or an array-like object to use as the underlying buffer.
Returns
-------
buf: Object
Circular buffer data structure.
buf.clear: Function
Clears the buffer.
buf.count: integer
Number of elements currently in the buffer.
buf.full: boolean
Boolean indicating whether the buffer is full.
buf.iterator: Function
Returns an iterator for iterating over a buffer. If an environment
supports Symbol.iterator, the returned iterator is iterable. Note that a
returned iterator does **not** iterate over partially full buffers.
buf.length: integer
Buffer length (capacity).
buf.push: Function
Adds a value to the buffer. If the buffer is full, the method returns
the removed value; otherwise, the method returns `undefined`.
buf.toArray: Function
Returns an array of buffer values.
buf.toJSON: Function
Serializes a circular buffer as JSON.
Examples
--------
> var b = {{alias}}( 3 );
> b.push( 'foo' );
> b.push( 'bar' );
> b.push( 'beep' );
> b.length
3
> b.count
3
> b.push( 'boop' )
'foo'
See Also
--------