Skip to content

Commit

Permalink
Finish PR 17 - Fix Gzip example (#36)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
JordanMartinez and matthewleon authored Sep 27, 2021
1 parent 886bb20 commit facc272
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
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!
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "eslint src && pulp build -- --censor-lib --strict",
"example:build": "eslint example && pulp build -I example -- --censor-lib --strict",
"example": "eslint example && pulp run -I example -m Gzip",
"test": "pulp test -- --censor-lib --strict"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion src/Node/Stream.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global Buffer */
"use strict";

exports.undefined = undefined;
Expand Down

0 comments on commit facc272

Please sign in to comment.