Module

Data.ByteString

Package
purescript-bytestrings
Repository
rightfold/purescript-bytestrings

#Octet Source

type Octet = Int / Mod256

An 8-bit non-negative integer.

#unsafeFreeze Source

unsafeFreeze :: Buffer -> ByteString

O(1) The result points directly into the buffer. Mutating the buffer afterwards results in undefined behavior.

#unsafeThaw Source

unsafeThaw :: ByteString -> Buffer

O(1) The result points directly into the byte string. Mutating the buffer results in undefined behavior.

#empty Source

empty :: ByteString

O(1) The empty byte string.

#singleton Source

singleton :: Octet -> ByteString

O(1) A byte string with a single byte.

#pack Source

pack :: Array Octet -> ByteString

Θ(n) A byte string with many bytes.

#unpack Source

unpack :: ByteString -> Array Octet

Θ(n) Get the bytes from a byte string.

#index Source

index :: ByteString -> Int -> Maybe Octet

O(1) Get the nth byte.

#(!!) Source

Operator alias for Data.ByteString.index (left-associative / precedence 8)

#unsafeIndex Source

unsafeIndex :: ByteString -> Int -> Octet

O(1) Get the nth byte. If the index is out of bounds, the behavior is undefined.

#cons Source

cons :: Octet -> ByteString -> ByteString

Θ(n) Prepend a byte.

#snoc Source

snoc :: ByteString -> Octet -> ByteString

Θ(n) Append a byte.

#uncons Source

uncons :: ByteString -> Maybe { head :: Octet, tail :: ByteString }

Θ(n) Unprepend a byte.

#unsnoc Source

unsnoc :: ByteString -> Maybe { init :: ByteString, last :: Octet }

Θ(n) Unappend a byte.

#head Source

head :: ByteString -> Maybe Octet

O(1) Get the first byte.

#tail Source

tail :: ByteString -> Maybe ByteString

Θ(n) Get all but the first byte.

#last Source

last :: ByteString -> Maybe Octet

O(1) Get the last byte.

#init Source

init :: ByteString -> Maybe ByteString

Θ(n) Get all but the last byte.

#length Source

length :: ByteString -> Int

O(1) How many bytes are in this byte string?

#isEmpty Source

isEmpty :: ByteString -> Boolean

O(1) Check if a byte string is empty.

#map Source

map :: (Octet -> Octet) -> ByteString -> ByteString

Θ(n) Transform the bytes in the byte string.

#reverse Source

reverse :: ByteString -> ByteString

Θ(n) Reverse the byte string.

#Foldable Source

newtype Foldable a

A foldable byte string.

Instances

#foldableOfOctet Source

foldableOfOctet :: forall a. Foldable a -> a ~ Octet

O(1) Witness that foldable byte strings can only contain octets.

#foldl Source

foldl :: forall a. (a -> Octet -> a) -> a -> ByteString -> a

Θ(n) Fold a byte string.

#foldr Source

foldr :: forall a. (Octet -> a -> a) -> a -> ByteString -> a

Θ(n) Fold a byte string.

#fromString Source

fromString :: String -> Encoding -> Maybe ByteString

Θ(n) Encode a string.

#toString Source

toString :: ByteString -> Encoding -> String

Θ(n) Decode a string.

#toUTF8 Source

toUTF8 :: String -> ByteString

Θ(n) unsafePartial fromJust <<< flip fromString UTF8.

#fromUTF8 Source

fromUTF8 :: ByteString -> String

Θ(n) flip toString UTF8

Re-exports from Node.Encoding

#Encoding

data Encoding

Constructors

  • ASCII
  • UTF8
  • UTF16LE
  • UCS2
  • Base64
  • Latin1
  • Binary
  • Hex

Instances

  • Show Encoding