Module
DynamicBuffer
- Package
- purescript-dynamic-buffers
- Repository
- kritzcreek/purescript-dynamic-buffer
#addBuffer Source
addBuffer :: DBuffer -> DBuffer -> Effect Unit
Adds the contents of the second buffer to the first. The contents are copied, so subsequent modifications to the second buffer don't affect the first.
import Prelude
import DynamicBuffer as DBuffer
import Debug.Trace as Debug
main = do
b1 <- DBuffer.create 8
b2 <- DBuffer.create 8
DBuffer.addByte b1 10
DBuffer.addByte b2 20
DBuffer.addByte b2 30
DBuffer.addBuffer b1 b2
Debug.traceM =<< DBuffer.size b1 -- 3
Debug.traceM =<< DBuffer.contents b1 -- Uint8Array(3) [ 10, 20, 30 ]
#unsafeContents Source
unsafeContents :: DBuffer -> Effect Uint8Array
Extracts the contents of this DBuffer without copying.
Careful! Modifying the contents of the DBuffer afterwards will modify the returned Uint8Array in place
#debugToString Source
debugToString :: DBuffer -> String
Displays the contents of the DBuffer for debugging purposes. Don't use this in "production", it's not referentially transparent.
import Prelude
import DynamicBuffer as DBuffer
import Effect.Console as Console
main = do
b <- DBuffer.create 8
DBuffer.addByte b 10
DBuffer.addByte b 20
DBuffer.addByte b 30
Console.log (DBuffer.debugToString b) -- [0xA, 0x14, 0x1E]
- Modules
- DynamicBuffer