Skip to content

Commit

Permalink
update deps, add CI
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Oct 13, 2024
1 parent b89900e commit d041571
Show file tree
Hide file tree
Showing 17 changed files with 140 additions and 87 deletions.
36 changes: 0 additions & 36 deletions .eslintrc.json

This file was deleted.

23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Bug Report
about: New issues are for bug reports only. For everything else, use Discussions.
title: ''
labels: ''
assignees: ''

---

### Expected behavior


### Actual behavior


### Steps to reproduce


### Environment

* Version of spex:
* OS type (Linux/Windows/Mac):
* Version of Node.js:
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: ci

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
node-version: [14.x, 20.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- run: npm install
- run: npm run lint
- run: npm run coverage
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Specialized Promise Extensions
SPEX
----

[![Build Status](https://travis-ci.org/vitaly-t/spex.svg?branch=master)](https://travis-ci.org/vitaly-t/spex)
[![Coverage Status](https://coveralls.io/repos/vitaly-t/spex/badge.svg?branch=master)](https://coveralls.io/r/vitaly-t/spex?branch=master)
[![Join the chat at https://gitter.im/vitaly-t/spex](https://badges.gitter.im/vitaly-t/spex.svg)](https://gitter.im/vitaly-t/spex?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
Specialized Promise Extensions.

[![Build Status](https://github.com/vitaly-t/spex/actions/workflows/ci.yml/badge.svg)](https://github.com/vitaly-t/spex/actions/workflows/ci.yml)
[![Node Version](https://img.shields.io/badge/nodejs-14%20--%2020-green.svg?logo=node.js&style=flat)](https://nodejs.org)

[batch], [page], [sequence] - promise methods for the following patterns:
* [Data Throttling & Load Balancing](http://vitaly-t.github.io/spex/tutorial-throttling.html)
Expand Down
44 changes: 44 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const js = require("@eslint/js");
const globals = require("globals");

module.exports = [
js.configs.recommended,
{
languageOptions: {
globals: {
...globals.es6,
...globals.node,
...globals.jasmine,
...globals.BigInt,
},
parserOptions: {
ecmaFeatures: { globalReturn: true },
},
sourceType: "commonjs",
ecmaVersion: 2022,
},
rules: {
"no-var": "error",
"prefer-const": "error",
"prefer-arrow-callback": "error",
"no-else-return": "error",
"no-multi-spaces": "error",
"no-whitespace-before-property": "error",
camelcase: "error",
"new-cap": "error",
"no-console": "error",
"comma-dangle": "error",
"no-shadow": "error",
"object-shorthand": ["error", "properties"],
indent: [
"error",
4,
{
SwitchCase: 1,
},
],
quotes: ["error", "single"],
semi: ["error", "always"],
},
},
];
3 changes: 1 addition & 2 deletions lib/errors/batch.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class BatchError extends Error {
total: result.length,
succeeded: result.length - e.length,
failed: e.length,
duration: duration
duration
};

this.getErrors = getErrors;
Expand Down Expand Up @@ -170,4 +170,3 @@ npm.utils.addInspection(BatchError, function () {
});

module.exports = {BatchError};

8 changes: 3 additions & 5 deletions lib/ext/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function page(source, options, config) {
.then(next)
.catch(error => {
fail({
error: error,
error,
dest: data
}, 3, dest.name);
});
Expand All @@ -130,9 +130,7 @@ function page(source, options, config) {
return null; // this dummy return is just to prevent Bluebird warnings;
})
.catch(error => {
fail({
error: error
}, 0);
fail({error}, 0);
});
} else {
fail({
Expand Down Expand Up @@ -160,7 +158,7 @@ function page(source, options, config) {
function success() {
resolve({
pages: idx,
total: total,
total,
duration: Date.now() - start
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/ext/sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function sequence(source, options, config) {
})
.catch(error => {
fail({
error: error,
error,
dest: data
}, 2, dest.name);
});
Expand Down
4 changes: 2 additions & 2 deletions lib/ext/stream/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ function read(stream, receiver, options, config) {
cleanup();
resolve({
calls: index,
reads: reads,
length: length,
reads,
length,
duration: Date.now() - start
});
}
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ function main(promiseLib) {
promise = parsePromiseLib(promiseLib); // promise library parsing;

const config = {
spex: spex,
promise: promise,
spex,
promise,
utils: npm.utils(promise)
};

Expand Down
4 changes: 2 additions & 2 deletions lib/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module.exports = function ($p) {
isReadableStream: npm.stat.isReadableStream,
messageGap: npm.stat.messageGap,
extend: npm.stat.extend,
resolve: resolve,
wrap: wrap
resolve,
wrap
};

return exp;
Expand Down
14 changes: 7 additions & 7 deletions lib/utils/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function isReadableStream(obj) {
// Sets an object property as read-only and non-enumerable.
function extend(obj, name, value) {
Object.defineProperty(obj, name, {
value: value,
value,
configurable: false,
enumerable: false,
writable: false
Expand Down Expand Up @@ -65,10 +65,10 @@ function addInspection(type, cb) {
}

module.exports = {
addInspection: addInspection,
formatError: formatError,
isPromise: isPromise,
isReadableStream: isReadableStream,
messageGap: messageGap,
extend: extend
addInspection,
formatError,
isPromise,
isReadableStream,
messageGap,
extend
};
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"name": "spex",
"version": "3.3.0",
"version": "3.3.1",
"description": "Specialized Promise Extensions",
"main": "lib/index.js",
"typings": "typescript/spex.d.ts",
"scripts": {
"test": "jasmine-node test",
"doc": "jsdoc -c ./jsdoc/jsDoc.js ./jsdoc/README.md -u ./jsdoc/tutorials",
"coverage": "istanbul cover ./node_modules/jasmine-node/bin/jasmine-node test",
"travis": "npm run lint && istanbul cover ./node_modules/jasmine-node/bin/jasmine-node test --captureExceptions && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage",
"browserify": "browserify lib/index.js -s spexLib -o spex.js",
"lint": "eslint ./lib ./test/**/*.spec.js"
},
Expand Down Expand Up @@ -37,16 +36,17 @@
},
"license": "MIT",
"engines": {
"node": ">=10.0.0"
"node": ">=14.0.0"
},
"devDependencies": {
"@eslint/js": "9.12.0",
"bluebird": "3.7.2",
"browserify": "17.0.0",
"browserify": "17.0.1",
"coveralls": "3.1.1",
"eslint": "8.36.0",
"eslint": "9.12.0",
"istanbul": "0.4.5",
"jasmine-node": "3.0.0",
"jsdoc": "4.0.2",
"typescript": "5.0.2"
"jsdoc": "4.0.3",
"typescript": "5.6.3"
}
}
8 changes: 4 additions & 4 deletions test/ext/batch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('Batch - negative', () => {
throw err;
}

spex.batch([1], {cb: cb})
spex.batch([1], {cb})
.catch(reason => {
r = reason;
done();
Expand All @@ -62,7 +62,7 @@ describe('Batch - negative', () => {
throw err;
}

spex.batch([promise.reject(rejectError)], {cb: cb})
spex.batch([promise.reject(rejectError)], {cb})
.catch(reason => {
r = reason;
done();
Expand Down Expand Up @@ -93,7 +93,7 @@ describe('Batch - negative', () => {
return promise.reject(err);
}

spex.batch([1, 2], {cb: cb})
spex.batch([1, 2], {cb})
.catch(reason => {
r = reason;
done();
Expand Down Expand Up @@ -312,7 +312,7 @@ describe('Batch callback as generator', () => {
}

beforeEach(done => {
spex.batch.call(context, [1], {cb: cb})
spex.batch.call(context, [1], {cb})
.then(data => {
result = data;
done();
Expand Down
10 changes: 5 additions & 5 deletions test/ext/page.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ describe('Page - negative', () => {
throw err;
}

spex.page(source, {dest: dest})
spex.page(source, {dest})
.catch(reason => {
r = reason;
done();
Expand Down Expand Up @@ -178,7 +178,7 @@ describe('Page - negative', () => {
return promise.reject(err);
}

spex.page(source, {dest: dest})
spex.page(source, {dest})
.catch(reason => {
r = reason;
done();
Expand Down Expand Up @@ -303,7 +303,7 @@ describe('Page - positive', () => {
}

beforeEach(done => {
spex.page(source, {dest: dest})
spex.page(source, {dest})
.then(data => {
result = data;
done();
Expand All @@ -330,7 +330,7 @@ describe('Page - positive', () => {
}

beforeEach(done => {
spex.page(source, {limit: limit})
spex.page(source, {limit})
.then(data => {
result = data;
done();
Expand Down Expand Up @@ -382,7 +382,7 @@ describe('Page callbacks generators', () => {
}

beforeEach(done => {
spex.page.call(context, source, {dest: dest, limit: 1})
spex.page.call(context, source, {dest, limit: 1})
.then(data => {
result = data;
done();
Expand Down
6 changes: 1 addition & 5 deletions test/ext/read.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,7 @@ describe('Stream/Read - positive', () => {
});

function receiver(index, data, delay) {
r = {
index: index,
data: data,
delay: delay
};
r = {index, data, delay};
}
});

Expand Down
Loading

0 comments on commit d041571

Please sign in to comment.