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
28 changes: 28 additions & 0 deletions src/Node/Stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ exports.pipe = function (r) {
};
};

exports.unpipe = function (r) {
return function (w) {
return function () {
return r.unpipe(w);
};
};
};

exports.unpipeAll = function (r) {
return function () {
return r.unpipe();
};
};

exports.readImpl = function (readChunk) {
return function (Nothing) {
return function (Just) {
Expand Down Expand Up @@ -177,3 +191,17 @@ exports.end = function (w) {
};
};
};

exports.destroy = function (strm) {
return function () {
strm.destroy(null);
};
};

exports.destroyWithError = function (strm) {
return function (e) {
return function () {
strm.destroy(e);
};
};
};
33 changes: 33 additions & 0 deletions src/Node/Stream.purs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ module Node.Stream
, pause
, isPaused
, pipe
, unpipe
, unpipeAll
, read
, readString
, readEither
Expand All @@ -29,6 +31,7 @@ module Node.Stream
, uncork
, setDefaultEncoding
, end
, destroy
) where

import Prelude
Expand Down Expand Up @@ -234,6 +237,19 @@ foreign import pipe
-> Writable r eff
-> Eff eff (Writable r eff)

-- | Detach a Writable stream previously attached using `pipe`.
foreign import unpipe
:: forall r w eff
. Readable w eff
-> Writable r eff
-> Eff eff Unit

-- | Detach all Writable streams previously attached using `pipe`.
foreign import unpipeAll
:: forall w eff
. Readable w eff
-> Eff eff Unit

-- | Write a Buffer to a writable stream.
foreign import write
:: forall r eff
Expand Down Expand Up @@ -290,3 +306,20 @@ foreign import end
. Writable r eff
-> Eff eff Unit
-> Eff eff Unit

-- | Destroy the stream. It will release any internal resources.
--
-- Added in node 8.0.
foreign import destroy
:: forall r eff
. Stream r eff
-> Eff eff Unit

-- | Destroy the stream and emit 'error'.
--
-- Added in node 8.0.
foreign import destroyWithError
:: forall r eff
. Stream r eff
-> Error
-> Eff eff Unit