Module

Node.Buffer

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

Mutable buffers and associated operations.

#Buffer Source

data Buffer :: Type

A reference to a mutable buffer for use with Effect

Instances

Re-exports from Node.Buffer.Class

#MutableBuffer Source

class (Monad m) <= MutableBuffer buf m | buf -> m where

A type class for mutable buffers buf where operations on those buffers are represented by a particular monadic effect type m.

Members

  • create :: Int -> m buf

    Creates a new buffer of the specified size.

  • freeze :: buf -> m ImmutableBuffer

    Creates an immutable copy of a mutable buffer.

  • unsafeFreeze :: buf -> m ImmutableBuffer

    O(1). Convert a mutable buffer to an immutable buffer, without copying. The mutable buffer must not be mutated afterwards.

  • thaw :: ImmutableBuffer -> m buf

    Creates a mutable copy of an immutable buffer.

  • unsafeThaw :: ImmutableBuffer -> m buf

    O(1) Convert an immutable buffer to a mutable buffer, without copying. The input buffer must not be used afterward.

  • fromArray :: Array Octet -> m buf

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

  • fromString :: String -> Encoding -> m buf

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

  • fromArrayBuffer :: ArrayBuffer -> m buf

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

  • toArrayBuffer :: buf -> m ArrayBuffer

    Copies the data in the buffer to a new JS ArrayBuffer

  • read :: BufferValueType -> Offset -> buf -> m Number

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

  • readString :: Encoding -> Offset -> Offset -> buf -> m String

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

  • toString :: Encoding -> buf -> m String

    Reads the buffer as a string with the specified encoding.

  • write :: BufferValueType -> Number -> Offset -> buf -> m Unit

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

  • writeString :: Encoding -> Offset -> Int -> String -> buf -> m 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 :: buf -> m (Array Octet)

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

  • getAtOffset :: Offset -> buf -> m (Maybe Octet)

    Reads an octet from a buffer at the specified offset.

  • setAtOffset :: Octet -> Offset -> buf -> m Unit

    Writes an octet in the buffer at the specified offset.

  • slice :: Offset -> Offset -> buf -> buf

    Creates a new buffer slice that acts like a window on the original buffer. Writing to the slice buffer updates the original buffer and vice-versa.

  • size :: buf -> m Int

    Returns the size of a buffer.

  • concat :: Array buf -> m buf

    Concatenates a list of buffers.

  • concat' :: Array buf -> Int -> m buf

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

  • copy :: Offset -> Offset -> buf -> Offset -> buf -> m Int

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

  • fill :: Octet -> Offset -> Offset -> buf -> m Unit

    Fills a range in a buffer with the specified octet.

Re-exports from Node.Buffer.Types

#Offset Source

type Offset = Int

Type synonym indicating the value refers to an offset in a 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.

#BufferValueType Source

data BufferValueType

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

Constructors

Instances