Skip to content

Commit facc272

Browse files
Finish PR 17 - Fix Gzip example (#36)
* fix example Update node dependencies and fix example. * Update changelog * Drop eslint 'global Buffer' usage * Remove extra whitespace * Drop package-lock.json Co-authored-by: Matthew Leon <[email protected]>
1 parent 886bb20 commit facc272

File tree

8 files changed

+17
-13
lines changed

8 files changed

+17
-13
lines changed

.eslintrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
},
55
"extends": "eslint:recommended",
66
"env": {
7+
"node": true,
78
"commonjs": true
89
},
910
"rules": {

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ New features:
1111
Bugfixes:
1212

1313
Other improvements:
14+
- Fix `Gzip` example (#17, #36 by @matthewleon and @JordanMartinez)
1415

1516
## [v5.0.0](https://github.com/purescript-node/purescript-posix-types/releases/tag/v5.0.0) - 2021-02-26
1617

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

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

9+
See the `example` directory for a usage example.
10+
911
## Installation
1012

1113
```

example/Gzip.js

+2-6
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

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ module Gzip where
33
import Prelude
44

55
import Effect (Effect)
6-
import Node.Stream (Duplex, Readable, Writable, pipe)
7-
6+
import Effect.Console (log)
7+
import Node.Stream (Duplex, Readable, Writable, onEnd, pipe)
88

99
foreign import gzip :: Effect Duplex
10-
foreign import stdin :: Readable ()
10+
foreign import fileStream :: Readable ()
1111
foreign import stdout :: Writable ()
1212

13-
main :: Effect (Writable ())
13+
main :: Effect Unit
1414
main = do
1515
z <- gzip
16-
_ <- stdin `pipe` z
17-
z `pipe` stdout
16+
_ <- fileStream `pipe` z
17+
_ <- z `pipe` stdout
18+
void $ onEnd fileStream do
19+
log "Done reading file, gzip output below"

example/Gzip.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Compress me pretty please!

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"scripts": {
44
"clean": "rimraf output && rimraf .pulp-cache",
55
"build": "eslint src && pulp build -- --censor-lib --strict",
6+
"example:build": "eslint example && pulp build -I example -- --censor-lib --strict",
7+
"example": "eslint example && pulp run -I example -m Gzip",
68
"test": "pulp test -- --censor-lib --strict"
79
},
810
"devDependencies": {

src/Node/Stream.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* global Buffer */
21
"use strict";
32

43
exports.undefined = undefined;

0 commit comments

Comments
 (0)