Module

Node.Buffer

Package
purescript-node-buffer
Repository
purescript-node/purescript-node-buffer

#Octet Source

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 Source

type Offset = Int

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

#Buffer Source

data Buffer :: Type

An instance of Node's Buffer class.

Instances

#BufferValueType Source

data BufferValueType

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

Constructors

Instances

#create Source

create :: Int -> Effect Buffer

Creates a new buffer of the specified size.

#fromArray Source

fromArray :: Array Octet -> Effect Buffer

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

#fromString Source

fromString :: String -> Encoding -> Effect Buffer

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

#fromArrayBuffer Source

fromArrayBuffer :: ArrayBuffer -> Effect Buffer

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

#read Source

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

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

#readString Source

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

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

#toString Source

toString :: Encoding -> Buffer -> Effect String

Reads the buffer as a string with the specified encoding.

#write Source

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

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

#writeString Source

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 Source

toArray :: Buffer -> Effect (Array Octet)

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

#getAtOffset Source

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

Reads an octet from a buffer at the specified offset.

#setAtOffset Source

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

Writes an octet in the buffer at the specified offset.

#size Source

size :: Buffer -> Effect Int

Returns the size of a buffer.

#concat Source

concat :: Array Buffer -> Effect Buffer

Concatenates a list of buffers.

#concat' Source

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

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

#copy Source

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 Source

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

Fills a range in a buffer with the specified octet.