Skip to content

Commit 44f3fb9

Browse files
Update buffer dep; update CI; format (#48)
* update node-buffer; update CI * Format via purs-tidy; enforce in CI * Drop extra newline Co-authored-by: Thomas Honeyman <[email protected]> --------- Co-authored-by: Thomas Honeyman <[email protected]>
1 parent 8395652 commit 44f3fb9

File tree

5 files changed

+52
-46
lines changed

5 files changed

+52
-46
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,16 @@ jobs:
1010
build:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414

1515
- uses: purescript-contrib/setup-purescript@main
1616
with:
1717
purescript: "unstable"
18+
purs-tidy: "latest"
1819

19-
- uses: actions/setup-node@v2
20+
- uses: actions/setup-node@v3
2021
with:
21-
node-version: "14"
22+
node-version: "lts/*"
2223

2324
- name: Install dependencies
2425
run: |
@@ -33,3 +34,7 @@ jobs:
3334
run: |
3435
bower install
3536
npm run-script test --if-present
37+
38+
- name: Check formatting
39+
run: |
40+
purs-tidy check src test

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ Notable changes to this project are documented in this file. The format is based
55
## [Unreleased]
66

77
Breaking changes:
8+
- Update `node-buffer` to `v9.0.0` (#48 by @JordanMartinez)
89

910
New features:
1011

1112
Bugfixes:
1213

1314
Other improvements:
15+
- Bumped CI's node version to `lts/*` (#48 by @JordanMartinez)
16+
- Updated CI `actions/checkout` and `actions/setup-nodee` to `v3` (#48 by @JordanMartinez)
17+
- Format code via purs-tidy; enforce formatting via CI (#48 by @JordanMartinez)
1418

1519
## [v7.0.0](https://github.com/purescript-node/purescript-node-streams/releases/tag/v7.0.0) - 2022-04-29
1620

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"purescript-effect": "^4.0.0",
2121
"purescript-either": "^6.0.0",
2222
"purescript-exceptions": "^6.0.0",
23-
"purescript-node-buffer": "^8.0.0",
23+
"purescript-node-buffer": "^9.0.0",
2424
"purescript-nullable": "^6.0.0",
2525
"purescript-prelude": "^6.0.0"
2626
}

src/Node/Stream.purs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,21 +95,21 @@ onData r cb =
9595
where
9696
fromEither x =
9797
case x of
98-
Left _ ->
98+
Left _ ->
9999
throw "Stream encoding should not be set"
100100
Right buf ->
101101
pure buf
102102

103103
read
104104
:: forall w
105105
. Readable w
106-
-> Maybe Int
107-
-> Effect (Maybe Buffer)
106+
-> Maybe Int
107+
-> Effect (Maybe Buffer)
108108
read r size = do
109109
v <- readEither r size
110110
case v of
111-
Nothing -> pure Nothing
112-
Just (Left _) -> throw "Stream encoding should not be set"
111+
Nothing -> pure Nothing
112+
Just (Left _) -> throw "Stream encoding should not be set"
113113
Just (Right b) -> pure (Just b)
114114

115115
readString
@@ -121,9 +121,9 @@ readString
121121
readString r size enc = do
122122
v <- readEither r size
123123
case v of
124-
Nothing -> pure Nothing
125-
Just (Left _) -> throw "Stream encoding should not be set"
126-
Just (Right buf) -> Just <$> Buffer.toString enc buf
124+
Nothing -> pure Nothing
125+
Just (Left _) -> throw "Stream encoding should not be set"
126+
Just (Right buf) -> Just <$> Buffer.toString enc buf
127127

128128
readEither
129129
:: forall w

test/Main.purs

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ assertEqual :: forall a. Show a => Eq a => a -> a -> Effect Unit
1717
assertEqual x y =
1818
assert' (show x <> " did not equal " <> show y) (x == y)
1919

20-
2120
foreign import writableStreamBuffer :: Effect (Writable ())
2221

2322
foreign import getContentsAsString :: forall r. Writable r -> Effect String
@@ -58,34 +57,34 @@ testReads = do
5857
testReadBuf
5958

6059
where
61-
testReadString = do
62-
sIn <- passThrough
63-
v <- readString sIn Nothing UTF8
64-
assert (isNothing v)
65-
66-
onReadable sIn do
67-
str <- readString sIn Nothing UTF8
68-
assert (isJust str)
69-
assertEqual (unsafePartial (fromJust str)) testString
70-
pure unit
71-
72-
writeString sIn UTF8 testString \_ -> do
73-
pure unit
74-
75-
testReadBuf = do
76-
sIn <- passThrough
77-
v <- read sIn Nothing
78-
assert (isNothing v)
79-
80-
onReadable sIn do
81-
buf <- read sIn Nothing
82-
assert (isJust buf)
83-
_ <- assertEqual <$> (Buffer.toString UTF8 (unsafePartial (fromJust buf)))
84-
<*> pure testString
85-
pure unit
86-
87-
writeString sIn UTF8 testString \_ -> do
88-
pure unit
60+
testReadString = do
61+
sIn <- passThrough
62+
v <- readString sIn Nothing UTF8
63+
assert (isNothing v)
64+
65+
onReadable sIn do
66+
str <- readString sIn Nothing UTF8
67+
assert (isJust str)
68+
assertEqual (unsafePartial (fromJust str)) testString
69+
pure unit
70+
71+
writeString sIn UTF8 testString \_ -> do
72+
pure unit
73+
74+
testReadBuf = do
75+
sIn <- passThrough
76+
v <- read sIn Nothing
77+
assert (isNothing v)
78+
79+
onReadable sIn do
80+
buf <- read sIn Nothing
81+
assert (isJust buf)
82+
_ <- assertEqual <$> (Buffer.toString UTF8 (unsafePartial (fromJust buf)))
83+
<*> pure testString
84+
pure unit
85+
86+
writeString sIn UTF8 testString \_ -> do
87+
pure unit
8988

9089
testSetDefaultEncoding :: Effect Boolean
9190
testSetDefaultEncoding = do
@@ -123,9 +122,9 @@ testSetEncoding = do
123122

124123
testPipe :: Effect Boolean
125124
testPipe = do
126-
sIn <- passThrough
127-
sOut <- passThrough
128-
zip <- createGzip
125+
sIn <- passThrough
126+
sOut <- passThrough
127+
zip <- createGzip
129128
unzip <- createGunzip
130129

131130
log "pipe 1"
@@ -140,11 +139,9 @@ testPipe = do
140139
onDataString sOut UTF8 \str -> do
141140
assertEqual str testString
142141

143-
144142
foreign import createGzip :: Effect Duplex
145143
foreign import createGunzip :: Effect Duplex
146144

147-
148145
-- | Create a PassThrough stream, which simply writes its input to its output.
149146
foreign import passThrough :: Effect Duplex
150147

0 commit comments

Comments
 (0)