Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish PR 17 - Fix Gzip example #36

Merged
merged 6 commits into from
Sep 27, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
},
"extends": "eslint:recommended",
"env": {
"node": true,
"commonjs": true
},
"rules": {
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ New features:
Bugfixes:

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

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

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

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

See the `example` directory for a usage example.

## Installation

```
Expand Down
8 changes: 2 additions & 6 deletions example/Gzip.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/* global exports */
/* global require */
"use strict";

// module Gzip

exports.gzip = require('zlib').createGzip;
exports.gzip = require("zlib").createGzip;
exports.fileStream = require("fs").createReadStream("example/Gzip.txt");
exports.stdout = process.stdout;
exports.stdin = process.stdin;
14 changes: 8 additions & 6 deletions example/Gzip.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ module Gzip where
import Prelude

import Effect (Effect)
import Node.Stream (Duplex, Readable, Writable, pipe)

import Effect.Console (log)
import Node.Stream (Duplex, Readable, Writable, onEnd, pipe)

foreign import gzip :: Effect Duplex
foreign import stdin :: Readable ()
foreign import fileStream :: Readable ()
foreign import stdout :: Writable ()

main :: Effect (Writable ())
main :: Effect Unit
main = do
z <- gzip
_ <- stdin `pipe` z
z `pipe` stdout
_ <- fileStream `pipe` z
_ <- z `pipe` stdout
void $ onEnd fileStream do
log "Done reading file, gzip output below"
1 change: 1 addition & 0 deletions example/Gzip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Compress me pretty please!
Loading