diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..8d8d9cb --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,32 @@ +{ + "parserOptions": { + "ecmaVersion": 5 + }, + "extends": "eslint:recommended", + "env": { + "commonjs": true, + "browser": true + }, + "globals": { + "QueuingStrategy": "readonly" + }, + "rules": { + "strict": [2, "global"], + "block-scoped-var": 2, + "consistent-return": 2, + "eqeqeq": [2, "smart"], + "guard-for-in": 2, + "no-caller": 2, + "no-extend-native": 2, + "no-loop-func": 2, + "no-new": 2, + "no-param-reassign": 2, + "no-return-assign": 2, + "no-unused-expressions": 2, + "no-use-before-define": 2, + "radix": [2, "always"], + "indent": [2, 2], + "quotes": [2, "double"], + "semi": [2, "always"] + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..063845e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: purescript-contrib/setup-purescript@main + + - uses: actions/setup-node@v1 + with: + node-version: "10" + + - name: Install dependencies + run: | + npm install -g bower + npm install + bower install --production + + - name: Build source + run: npm run-script build + + - name: Run tests + run: | + bower install + npm run-script test --if-present diff --git a/.gitignore b/.gitignore index 20e090a..a56845c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ +/.* +!/.gitignore +!/.eslintrc.json +!/.github/ +package-lock.json /bower_components/ /node_modules/ -/.pulp-cache/ /output/ /generated-docs/ -/.psc-package/ -/.psc* -/.purs* -/.psa* diff --git a/README.md b/README.md index 5bde205..2320451 100644 --- a/README.md +++ b/README.md @@ -1 +1,17 @@ # purescript-web-streams + +[![Latest release](http://img.shields.io/github/release/purescript-web/purescript-web-streams.svg)](https://github.com/purescript-web/purescript-web-streams/releases) +[![Build status](https://github.com/purescript/purescript-web-streams/workflows/CI/badge.svg?branch=master)](https://github.com/purescript/purescript-web-streams/actions?query=workflow%3ACI+branch%3Amaster) +[![Pursuit](https://pursuit.purescript.org/packages/purescript-web-streams/badge)](https://pursuit.purescript.org/packages/purescript-web-streams) + +Type definitions and low level interface implementations for ReadableStream and related types from the [WHATWG Streams Living Standard](https://streams.spec.whatwg.org/). + +## Installation + +``` +spago install web-streams +``` + +## Documentation + +Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-web-streams). diff --git a/package.json b/package.json new file mode 100644 index 0000000..1c67b54 --- /dev/null +++ b/package.json @@ -0,0 +1,13 @@ +{ + "private": true, + "scripts": { + "clean": "rimraf output && rimraf .pulp-cache", + "build": "eslint src && pulp build -- --censor-lib --strict" + }, + "devDependencies": { + "eslint": "^7.15.0", + "pulp": "^15.0.0", + "purescript-psa": "^0.8.0", + "rimraf": "^3.0.2" + } +} diff --git a/src/Web/Streams/QueuingStrategy.js b/src/Web/Streams/QueuingStrategy.js index 0004c5b..e22c02f 100644 --- a/src/Web/Streams/QueuingStrategy.js +++ b/src/Web/Streams/QueuingStrategy.js @@ -1,3 +1,5 @@ +"use strict"; + exports.new = function(options) { return function() { return new QueuingStrategy(options); @@ -14,4 +16,4 @@ exports.countQueuingStrategy = function(options) { return function() { return new CountQueuingStrategy(options); }; -}; \ No newline at end of file +}; diff --git a/src/Web/Streams/ReadableStream.js b/src/Web/Streams/ReadableStream.js index 2528799..060ec06 100644 --- a/src/Web/Streams/ReadableStream.js +++ b/src/Web/Streams/ReadableStream.js @@ -1,3 +1,5 @@ +"use strict"; + exports._new = function(source, strategy) { return new ReadableStream(source, strategy); }; @@ -23,4 +25,4 @@ exports.getReader = function(stream) { exports._tee = function(tuple, stream) { var r = stream.tee(); return tuple(r[0])(r[1]); -}; \ No newline at end of file +}; diff --git a/src/Web/Streams/ReadableStreamController.js b/src/Web/Streams/ReadableStreamController.js index 25824d2..3f66e4c 100644 --- a/src/Web/Streams/ReadableStreamController.js +++ b/src/Web/Streams/ReadableStreamController.js @@ -1,3 +1,5 @@ +"use strict"; + exports.enqueue = function(chunk) { return function(controller) { return function() { @@ -24,4 +26,4 @@ exports.desiredSize = function(controller) { return function() { return controller.desiredSize; }; -}; \ No newline at end of file +}; diff --git a/src/Web/Streams/Reader.js b/src/Web/Streams/Reader.js index 93e25fe..f4360fa 100644 --- a/src/Web/Streams/Reader.js +++ b/src/Web/Streams/Reader.js @@ -1,3 +1,5 @@ +"use strict"; + exports._read = function(nothing, just, reader) { return reader.read().then(function(res) { if (res.done) { @@ -5,4 +7,4 @@ exports._read = function(nothing, just, reader) { } return just(res.value); }); -}; \ No newline at end of file +}; diff --git a/src/Web/Streams/Source.js b/src/Web/Streams/Source.js index 32644e9..6c1a4cb 100644 --- a/src/Web/Streams/Source.js +++ b/src/Web/Streams/Source.js @@ -1,3 +1,5 @@ +"use strict"; + exports._make = function(options) { var newOptions = { start: function(controller) { @@ -15,4 +17,4 @@ exports._make = function(options) { }; } return newOptions; -}; \ No newline at end of file +};