Skip to content

Commit 05ce511

Browse files
committed
fix example
Update node dependencies and fix example.
1 parent 5444a74 commit 05ce511

File tree

8 files changed

+3777
-56
lines changed

8 files changed

+3777
-56
lines changed

.jscsrc

Lines changed: 0 additions & 17 deletions
This file was deleted.

.jshintrc

Lines changed: 0 additions & 19 deletions
This file was deleted.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
A wrapper for Node's [Stream API](https://nodejs.org/api/stream.html).
77

8+
See the `example` directory for a usage example.
9+
810
## Installation
911

1012
```

example/Gzip.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
/* global exports */
2-
/* global require */
31
"use strict";
42

5-
// module Gzip
6-
7-
exports.gzip = require('zlib').createGzip;
3+
exports.gzip = require("zlib").createGzip;
4+
exports.fileStream = require("fs").createReadStream("example/Gzip.txt");
85
exports.stdout = process.stdout;
9-
exports.stdin = process.stdin;

example/Gzip.purs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ module Gzip where
22

33
import Prelude
44

5-
import Node.Stream
6-
7-
import Control.Monad.Eff
8-
import Control.Monad.Eff.Console
5+
import Control.Monad.Eff (Eff, kind Effect)
6+
import Control.Monad.Eff.Console (CONSOLE, log)
7+
import Node.Stream (Duplex, Readable, Writable, onEnd, pipe)
98

109
foreign import data GZIP :: Effect
1110

1211
foreign import gzip :: forall eff. Eff (gzip :: GZIP | eff) (Duplex (gzip :: GZIP | eff))
13-
foreign import stdin :: forall eff. Readable () (console :: CONSOLE | eff)
12+
foreign import fileStream :: forall eff. Readable () (console :: CONSOLE | eff)
1413
foreign import stdout :: forall eff. Writable () (console :: CONSOLE | eff)
1514

15+
main :: forall eff. Eff (gzip :: GZIP, console :: CONSOLE | eff) Unit
1616
main = do
1717
z <- gzip
18-
_ <- stdin `pipe` z
19-
z `pipe` stdout
18+
_ <- fileStream `pipe` z
19+
_ <- z `pipe` stdout
20+
void <<< onEnd fileStream $
21+
log "Done reading file, gzip output below"

example/Gzip.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Compress me pretty please!

0 commit comments

Comments
 (0)