Skip to content

Commit

Permalink
Update to PureScript v0.15.0 (#39)
Browse files Browse the repository at this point in the history
* ESM conversion

* ES6 transformations

* Removed '"use strict";' in FFI files

* Update to CI to use 'unstable' purescript

* Update Bower dependencies to master or main

* Update pulp to 16.0.0-0

* Update psa to 0.8.2

* Update Bower dependencies to master or main

* Update ci.yml to v2

* Add changelog entry

Co-authored-by: Nicholas Wolverson <[email protected]>
  • Loading branch information
sigma-andex and nwolverson authored Mar 22, 2022
1 parent facc272 commit b40025a
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 214 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ jobs:
- uses: actions/checkout@v2

- uses: purescript-contrib/setup-purescript@main
with:
purescript: "unstable"

- uses: actions/setup-node@v1
- uses: actions/setup-node@v2
with:
node-version: "10"
node-version: "14"

- name: Install dependencies
run: |
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Notable changes to this project are documented in this file. The format is based
## [Unreleased]

Breaking changes:
- Update project and deps to PureScript v0.15.0 (#39 by @nwolverson, @JordanMartinez, @sigma-andex)

New features:

Expand Down
16 changes: 8 additions & 8 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"url": "https://github.com/purescript-node/purescript-node-streams.git"
},
"devDependencies": {
"purescript-assert": "^5.0.0",
"purescript-console": "^5.0.0",
"purescript-partial": "^3.0.0"
"purescript-assert": "master",
"purescript-console": "master",
"purescript-partial": "master"
},
"dependencies": {
"purescript-effect": "^3.0.0",
"purescript-either": "^5.0.0",
"purescript-exceptions": "^5.0.0",
"purescript-node-buffer": "^7.0.0",
"purescript-prelude": "^5.0.0"
"purescript-effect": "master",
"purescript-either": "master",
"purescript-exceptions": "master",
"purescript-node-buffer": "master",
"purescript-prelude": "master"
}
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
},
"devDependencies": {
"eslint": "^7.15.0",
"pulp": "^15.0.0",
"purescript-psa": "^0.8.0",
"pulp": "16.0.0-0",
"purescript-psa": "^0.8.2",
"rimraf": "^3.0.2",
"stream-buffers": "^3.0.2"
}
Expand Down
285 changes: 111 additions & 174 deletions src/Node/Stream.js
Original file line number Diff line number Diff line change
@@ -1,208 +1,145 @@
"use strict";
const _undefined = undefined;
export { _undefined as undefined };

exports.undefined = undefined;

exports.setEncodingImpl = function (s) {
return function (enc) {
return function () {
s.setEncoding(enc);
};
export function setEncodingImpl(s) {
return enc => () => {
s.setEncoding(enc);
};
};

exports.readChunkImpl = function (Left) {
return function (Right) {
return function (chunk) {
if (chunk instanceof Buffer) {
return Right(chunk);
} else if (typeof chunk === "string") {
return Left(chunk);
} else {
throw new Error(
"Node.Stream.readChunkImpl: Unrecognised " +
"chunk type; expected String or Buffer, got: " +
chunk
);
}
};
}

export function readChunkImpl(Left) {
return Right => chunk => {
if (chunk instanceof Buffer) {
return Right(chunk);
} else if (typeof chunk === "string") {
return Left(chunk);
} else {
throw new Error(
"Node.Stream.readChunkImpl: Unrecognised " +
"chunk type; expected String or Buffer, got: " +
chunk
);
}
};
};

exports.onDataEitherImpl = function (readChunk) {
return function (r) {
return function (f) {
return function () {
r.on("data", function (data) {
f(readChunk(data))();
});
};
};
}

export function onDataEitherImpl(readChunk) {
return r => f => () => {
r.on("data", data => {
f(readChunk(data))();
});
};
};
}

exports.onEnd = function (s) {
return function (f) {
return function () {
s.on("end", f);
};
export function onEnd(s) {
return f => () => {
s.on("end", f);
};
};
}

exports.onFinish = function (s) {
return function (f) {
return function () {
s.on("finish", f);
};
export function onFinish(s) {
return f => () => {
s.on("finish", f);
};
};
}

exports.onReadable = function (s) {
return function (f) {
return function () {
s.on("readable", f);
};
export function onReadable(s) {
return f => () => {
s.on("readable", f);
};
};

exports.onError = function (s) {
return function (f) {
return function () {
s.on("error", function (e) {
f(e)();
});
};
}

export function onError(s) {
return f => () => {
s.on("error", e => {
f(e)();
});
};
};
}

exports.onClose = function (s) {
return function (f) {
return function () {
s.on("close", f);
};
export function onClose(s) {
return f => () => {
s.on("close", f);
};
};
}

exports.resume = function (s) {
return function () {
export function resume(s) {
return () => {
s.resume();
};
};
}

exports.pause = function (s) {
return function () {
export function pause(s) {
return () => {
s.pause();
};
};
}

exports.isPaused = function (s) {
return function () {
return s.isPaused();
};
};
export function isPaused(s) {
return () => s.isPaused();
}

exports.pipe = function (r) {
return function (w) {
return function () {
return r.pipe(w);
};
};
};
export function pipe(r) {
return w => () => r.pipe(w);
}

exports.unpipe = function (r) {
return function (w) {
return function () {
return r.unpipe(w);
};
};
};
export function unpipe(r) {
return w => () => r.unpipe(w);
}

exports.unpipeAll = function (r) {
return function () {
return r.unpipe();
};
};

exports.readImpl = function (readChunk) {
return function (Nothing) {
return function (Just) {
return function (r) {
return function (s) {
return function () {
var v = r.read(s);
if (v === null) {
return Nothing;
} else {
return Just(readChunk(v));
}
};
};
};
};
};
};

exports.write = function (w) {
return function (chunk) {
return function (done) {
return function () {
return w.write(chunk, null, done);
};
};
};
};

exports.writeStringImpl = function (w) {
return function (enc) {
return function (s) {
return function (done) {
return function () {
return w.write(s, enc, done);
};
};
};
};
};
export function unpipeAll(r) {
return () => r.unpipe();
}

exports.cork = function (w) {
return function () {
return w.cork();
export function readImpl(readChunk) {
return Nothing => Just => r => s => () => {
const v = r.read(s);
if (v === null) {
return Nothing;
} else {
return Just(readChunk(v));
}
};
};
}

exports.uncork = function (w) {
return function () {
return w.uncork();
};
};
export function write(w) {
return chunk => done => () => w.write(chunk, null, done);
}

exports.setDefaultEncodingImpl = function (w) {
return function (enc) {
return function () {
w.setDefaultEncoding(enc);
};
export function writeStringImpl(w) {
return enc => s => done => () => w.write(s, enc, done);
}

export function cork(w) {
return () => w.cork();
}

export function uncork(w) {
return () => w.uncork();
}

export function setDefaultEncodingImpl(w) {
return enc => () => {
w.setDefaultEncoding(enc);
};
};

exports.end = function (w) {
return function (done) {
return function () {
w.end(null, null, function () {
done();
});
};
}

export function end(w) {
return done => () => {
w.end(null, null, () => {
done();
});
};
};
}

exports.destroy = function (strm) {
return function () {
export function destroy(strm) {
return () => {
strm.destroy(null);
};
};
}

exports.destroyWithError = function (strm) {
return function (e) {
return function () {
strm.destroy(e);
};
export function destroyWithError(strm) {
return e => () => {
strm.destroy(e);
};
};
}
Loading

0 comments on commit b40025a

Please sign in to comment.