Module

Node.Buffer

#Octet

type Octet = Int

Type synonym indicating the value should be an octet (0-255). If the value provided is outside this range it will be used as modulo 256.

#Offset

type Offset = Int

Type synonym indicating the value refers to an offset in a buffer.

#Buffer

data Buffer :: Type

An instance of Node's Buffer class.

Instances

#BufferValueType

data BufferValueType

Enumeration of the numeric types that can be written to a buffer.

Constructors

Instances

#create

create :: Int -> Effect Buffer

Creates a new buffer of the specified size.

#fromArray

fromArray :: Array Octet -> Effect Buffer

Creates a new buffer from an array of octets, sized to match the array.

#fromString

fromString :: String -> Encoding -> Effect Buffer

Creates a new buffer from a string with the specified encoding, sized to match the string.

#fromArrayBuffer

fromArrayBuffer :: ArrayBuffer -> Effect Buffer

Creates a buffer view from a JS ArrayByffer without copying data.

#read

read :: BufferValueType -> Offset -> Buffer -> Effect Int

Reads a numeric value from a buffer at the specified offset.

#readString

readString :: Encoding -> Offset -> Offset -> Buffer -> Effect String

Reads a section of a buffer as a string with the specified encoding.

#toString

toString :: Encoding -> Buffer -> Effect String

Reads the buffer as a string with the specified encoding.

#write

write :: BufferValueType -> Int -> Offset -> Buffer -> Effect Unit

Writes a numeric value to a buffer at the specified offset.

#writeString

writeString :: Encoding -> Offset -> Int -> String -> Buffer -> Effect Int

Writes octets from a string to a buffer at the specified offset. Multi-byte characters will not be written to the buffer if there is not enough capacity to write them fully. The number of bytes written is returned.

#toArray

toArray :: Buffer -> Effect (Array Octet)

Creates an array of octets from a buffer's contents.

#getAtOffset

getAtOffset :: Offset -> Buffer -> Effect (Maybe Octet)

Reads an octet from a buffer at the specified offset.

#setAtOffset

setAtOffset :: Octet -> Offset -> Buffer -> Effect Unit

Writes an octet in the buffer at the specified offset.

#size

size :: Buffer -> Effect Int

Returns the size of a buffer.

#concat

concat :: Array Buffer -> Effect Buffer

Concatenates a list of buffers.

#concat'

concat' :: Array Buffer -> Int -> Effect Buffer

Concatenates a list of buffers, combining them into a new buffer of the specified length.

#copy

copy :: Offset -> Offset -> Buffer -> Offset -> Buffer -> Effect Int

Copies a section of a source buffer into a target buffer at the specified offset, and returns the number of octets copied.

#fill

fill :: Octet -> Offset -> Offset -> Buffer -> Effect Unit

Fills a range in a buffer with the specified octet.

Modules