Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
- uses: purescript-contrib/setup-purescript@main
with:
purescript: "unstable"
purs-tidy: "latest"

- uses: actions/setup-node@v2
with:
Expand All @@ -33,3 +34,7 @@ jobs:
run: |
bower install
npm run-script test --if-present

- name: Check formatting
run: |
purs-tidy check src test
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ New features:
Bugfixes:

Other improvements:
- Format code with `purs-tidy`; enforce in CI (#52 by @JordanMartinez)

## [v8.0.0](https://github.com/purescript-node/purescript-node-buffer/releases/tag/v8.0.0) - 2022-04-27

Expand Down
8 changes: 4 additions & 4 deletions src/Node/Buffer/Immutable.purs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ foreign import readImpl :: String -> Offset -> ImmutableBuffer -> Number
readString :: Encoding -> Offset -> Offset -> ImmutableBuffer -> String
readString = readStringImpl <<< encodingToNode

foreign import readStringImpl ::
String -> Offset -> Offset -> ImmutableBuffer -> String
foreign import readStringImpl
:: String -> Offset -> Offset -> ImmutableBuffer -> String

-- | Reads the buffer as a string with the specified encoding.
toString :: Encoding -> ImmutableBuffer -> String
Expand All @@ -92,8 +92,8 @@ foreign import toArrayBuffer :: ImmutableBuffer -> ArrayBuffer
getAtOffset :: Offset -> ImmutableBuffer -> Maybe Octet
getAtOffset = getAtOffsetImpl Just Nothing

foreign import getAtOffsetImpl ::
(Octet -> Maybe Octet) -> Maybe Octet -> Offset -> ImmutableBuffer -> Maybe Octet
foreign import getAtOffsetImpl
:: (Octet -> Maybe Octet) -> Maybe Octet -> Offset -> ImmutableBuffer -> Maybe Octet

-- | Concatenates a list of buffers.
foreign import concat :: Array ImmutableBuffer -> ImmutableBuffer
Expand Down
4 changes: 2 additions & 2 deletions src/Node/Buffer/Internal.purs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ foreign import writeInternal :: forall buf m. String -> Number -> Offset -> buf
writeString :: forall buf m. Monad m => Encoding -> Offset -> Int -> String -> buf -> m Int
writeString = writeStringInternal <<< encodingToNode

foreign import writeStringInternal ::
forall buf m. String -> Offset -> Int -> String -> buf -> m Int
foreign import writeStringInternal
:: forall buf m. String -> Offset -> Int -> String -> buf -> m Int

toArray :: forall buf m. Monad m => buf -> m (Array Octet)
toArray = usingFromImmutable Immutable.toArray
Expand Down
16 changes: 8 additions & 8 deletions src/Node/Buffer/Types.purs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ data BufferValueType
| DoubleBE

instance showBufferValueType :: Show BufferValueType where
show UInt8 = "UInt8"
show UInt8 = "UInt8"
show UInt16LE = "UInt16LE"
show UInt16BE = "UInt16BE"
show UInt32LE = "UInt32LE"
show UInt32BE = "UInt32BE"
show Int8 = "Int8"
show Int16LE = "Int16LE"
show Int16BE = "Int16BE"
show Int32LE = "Int32LE"
show Int32BE = "Int32BE"
show FloatLE = "FloatLE"
show FloatBE = "FloatBE"
show Int8 = "Int8"
show Int16LE = "Int16LE"
show Int16BE = "Int16BE"
show Int32LE = "Int32LE"
show Int32BE = "Int32BE"
show FloatLE = "FloatLE"
show FloatBE = "FloatBE"
show DoubleLE = "DoubleLE"
show DoubleBE = "DoubleBE"
30 changes: 15 additions & 15 deletions src/Node/Encoding.purs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Node.Encoding
( Encoding (..)
( Encoding(..)
, encodingToNode
, byteLength
) where
Expand All @@ -17,26 +17,26 @@ data Encoding
| Hex

instance showEncoding :: Show Encoding where
show ASCII = "ASCII"
show UTF8 = "UTF8"
show ASCII = "ASCII"
show UTF8 = "UTF8"
show UTF16LE = "UTF16LE"
show UCS2 = "UCS2"
show Base64 = "Base64"
show Latin1 = "Latin1"
show Binary = "Binary"
show Hex = "Hex"
show UCS2 = "UCS2"
show Base64 = "Base64"
show Latin1 = "Latin1"
show Binary = "Binary"
show Hex = "Hex"

-- | Convert an `Encoding` to a `String` in the format expected by Node.js
-- | APIs.
encodingToNode :: Encoding -> String
encodingToNode ASCII = "ascii"
encodingToNode UTF8 = "utf8"
encodingToNode ASCII = "ascii"
encodingToNode UTF8 = "utf8"
encodingToNode UTF16LE = "utf16le"
encodingToNode UCS2 = "ucs2"
encodingToNode Base64 = "base64"
encodingToNode Latin1 = "latin1"
encodingToNode Binary = "binary"
encodingToNode Hex = "hex"
encodingToNode UCS2 = "ucs2"
encodingToNode Base64 = "base64"
encodingToNode Latin1 = "latin1"
encodingToNode Binary = "binary"
encodingToNode Hex = "hex"

foreign import byteLengthImpl :: String -> String -> Int

Expand Down
Loading