Add some type declarations to get compatibility with node-buffer 6.x. (#149)

Since node-buffer 6.x is not yet in the package set, compatibility with
node-buffer 5.x is maintained.
This commit is contained in:
Gareth Smith 2019-09-25 01:09:29 +01:00 committed by Connor Prussin
parent ff89d67979
commit d37096dcce
3 changed files with 6 additions and 4 deletions

View File

@ -31,7 +31,7 @@
"purescript-lists": "^5.4.0",
"purescript-maybe": "^4.0.1",
"purescript-newtype": "^3.0.0",
"purescript-node-buffer": "^5.0.0",
"purescript-node-buffer": "^5.0.0 || ^6.0.0",
"purescript-node-child-process": "^6.0.0",
"purescript-node-fs": "^5.0.0",
"purescript-node-fs-aff": "^6.0.0",

View File

@ -39,7 +39,9 @@ class Body b where
-- | response stream and closing the response stream.
instance bodyString :: Body String where
defaultHeaders body = Buffer.fromString body Encoding.UTF8 >>= defaultHeaders
defaultHeaders body = do
buf :: Buffer.Buffer <- Buffer.fromString body Encoding.UTF8
defaultHeaders buf
write body response = Aff.makeAff \done -> do
let stream = HTTP.responseAsStream response

View File

@ -33,7 +33,7 @@ defaultHeadersSpec = Spec.describe "defaultHeaders" do
headers ?= Headers.header "Content-Length" "3"
Spec.describe "Buffer" do
Spec.it "has the correct Content-Length header" do
buf <- EffectClass.liftEffect $ Buffer.fromString "foobar" Encoding.UTF8
buf :: Buffer.Buffer <- EffectClass.liftEffect $ Buffer.fromString "foobar" Encoding.UTF8
headers <- EffectClass.liftEffect $ Body.defaultHeaders buf
headers ?= Headers.header "Content-Length" "6"
Spec.describe "Readable" do
@ -55,7 +55,7 @@ writeSpec = Spec.describe "write" do
Spec.it "writes the Buffer to the Response body" do
body <- do
resp <- EffectClass.liftEffect TestHelpers.mockResponse
buf <- EffectClass.liftEffect $ Buffer.fromString "test" Encoding.UTF8
buf :: Buffer.Buffer <- EffectClass.liftEffect $ Buffer.fromString "test" Encoding.UTF8
Body.write buf resp
pure $ TestHelpers.getResponseBody resp
body ?= "test"