@@ -1,14 +1,17 @@
1-- | A collection of utility functions for dealing with 'Enumerator's.
1-- | A collection of utility functions for dealing with 'Enumerator's.
2module Network.Wai.Enumerator
2module Network.Wai.Enumerator
3− ( -- * Lazy byte strings
6+ , -- ** Lazy byte strings
7− -- * Source
10+ -- ** Source
8 , toSource
11 , toSource
9− -- * Handle
12+ -- ** Handle
10 , fromHandle
13 , fromHandle
11− -- * FilePath
14+ -- ** FilePath
12 , fromFile
15 , fromFile
13 , fromEitherFile
16 , fromEitherFile
@@ -19,6 +22,12 @@ import qualified Data.ByteString as B
19import System.IO.Unsafe (unsafeInterleaveIO)
22import System.IO.Unsafe (unsafeInterleaveIO)
20import System.IO (withBinaryFile, IOMode (ReadMode), Handle, hIsEOF)
23import System.IO (withBinaryFile, IOMode (ReadMode), Handle, hIsEOF)
25+-- | Performs a specified conversion on each 'B.ByteString' output by an
27+mapE :: (B.ByteString -> B.ByteString) -> Enumerator a -> Enumerator a
28+mapE f e iter = e iter' where
22-- | This uses 'unsafeInterleaveIO' to lazily read from an enumerator. All
31-- | This uses 'unsafeInterleaveIO' to lazily read from an enumerator. All
23-- normal lazy I/O warnings apply.
32-- normal lazy I/O warnings apply.
24toLBS :: Enumerator (Maybe B.ByteString) -> IO L.ByteString
33toLBS :: Enumerator (Maybe B.ByteString) -> IO L.ByteString