Skip to content

Commit ae6dda7

Browse files
authored
Legacy (#17)
* parking * typescript fixed * linting fixed * tests fixed * update tests * docs * docs
1 parent f1d377f commit ae6dda7

38 files changed

Lines changed: 556 additions & 961 deletions

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,12 @@ $ npm i spex
2020

2121
## Usage
2222

23-
* For any [Promises/A+] library: [Promise], [Bluebird], [When], [Q], [RSVP], etc.
23+
```ts
24+
import {batch, errors} from 'spex';
2425

25-
```js
26-
const promise = require('bluebird');
27-
const spex = require('spex')(promise);
28-
```
29-
30-
* For ES6 Promise:
31-
32-
```js
33-
const spex = require('spex')(Promise);
26+
await batch([1, 2, 3])
27+
.catch((err: errors.BatchError) => {
28+
});
3429
```
3530

3631
See also: [client-side usage](http://vitaly-t.github.io/spex/tutorial-client.html).

eslint.config.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const js = require("@eslint/js");
2-
const globals = require("globals");
1+
const js = require('@eslint/js');
2+
const globals = require('globals');
33

44
module.exports = [
55
js.configs.recommended,
@@ -12,33 +12,33 @@ module.exports = [
1212
...globals.BigInt,
1313
},
1414
parserOptions: {
15-
ecmaFeatures: { globalReturn: true },
15+
ecmaFeatures: {globalReturn: true}
1616
},
17-
sourceType: "commonjs",
18-
ecmaVersion: 2022,
17+
sourceType: 'commonjs',
18+
ecmaVersion: 2020
1919
},
2020
rules: {
21-
"no-var": "error",
22-
"prefer-const": "error",
23-
"prefer-arrow-callback": "error",
24-
"no-else-return": "error",
25-
"no-multi-spaces": "error",
26-
"no-whitespace-before-property": "error",
27-
camelcase: "error",
28-
"new-cap": "error",
29-
"no-console": "error",
30-
"comma-dangle": "error",
31-
"no-shadow": "error",
32-
"object-shorthand": ["error", "properties"],
21+
'no-var': 'error',
22+
'prefer-const': 'error',
23+
'prefer-arrow-callback': 'error',
24+
'no-else-return': 'error',
25+
'no-multi-spaces': 'error',
26+
'no-whitespace-before-property': 'error',
27+
camelcase: 'error',
28+
'new-cap': 'error',
29+
'no-console': 'error',
30+
'comma-dangle': 'error',
31+
'no-shadow': 'error',
32+
'object-shorthand': ['error', 'properties'],
3333
indent: [
34-
"error",
34+
'error',
3535
4,
3636
{
37-
SwitchCase: 1,
38-
},
37+
SwitchCase: 1
38+
}
3939
],
40-
quotes: ["error", "single"],
41-
semi: ["error", "always"],
42-
},
43-
},
40+
quotes: ['error', 'single'],
41+
semi: ['error', 'always']
42+
}
43+
}
4444
];

jsdoc/fixLinks.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ const links = {
55
'stream': 'https://github.com/vitaly-t/spex/blob/master/docs/concept/stream.md',
66
'client-side': 'https://github.com/vitaly-t/spex/blob/master/docs/client.md',
77
'Promise': 'https://github.com/then/promise',
8-
'Bluebird': 'https://github.com/petkaantonov/bluebird',
98
'When': 'https://github.com/cujojs/when',
10-
'Q': 'https://github.com/kriskowal/q',
11-
'RSVP': 'https://github.com/tildeio/rsvp.js',
12-
'Lie': 'https://github.com/calvinmetcalf/lie',
139
'Promises/A+': 'https://promisesaplus.com'
1410
};
1511

jsdoc/jsdoc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
22
source: {
33
include: [
4-
'lib'
4+
'src'
55
]
66
},
77
opts: {

jsdoc/tutorials/batch.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ And this is where method [batch] helps:
2929
Let's start with a positive example, and throw in a few combinations of [mixed values].
3030

3131
```js
32-
const spex = require('spex')(Promise);
32+
const {batch} = require('spex');
3333
3434
// function that returns a promise;
3535
function getWord() {
@@ -53,7 +53,7 @@ const values = [
5353
Promise.resolve(nested)
5454
];
5555
56-
spex.batch(values)
56+
batch(values)
5757
.then(data => {
5858
console.log('DATA:', data);
5959
})
@@ -103,4 +103,3 @@ This is just to simplify quick access to the list of errors that occurred.
103103

104104
[batch]:http://vitaly-t.github.io/spex/global.html#batch
105105
[mixed values]:http://vitaly-t.github.io/spex/tutorial-mixed.html
106-

jsdoc/tutorials/client.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@ $ npm install
1616
$ npm run browserify
1717
```
1818

19-
This generates file `spex.js` within the module's root folder, to be copied into your web project.
20-
21-
The library exposes global variable `spexLib`, to be initialized as shown in the following example:
19+
This generates file `spex.js` within the module's root folder, to be copied into your web project,
20+
which exposes global variable `spexLib`:
2221

2322
```html
2423
<script src="spex.js"></script>
2524
<script>
26-
const spex = spexLib(Promise); // Initializing with ES6 Promise;
25+
const {batch, page, sequence, errors} = spexLib;
2726
</script>
2827
```
2928

jsdoc/tutorials/streaming.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Below is a simple track-enabled sequence that creates and returns promises one b
1515
It also includes a destination function for logging purposes.
1616

1717
```js
18-
const spex = require('spex')(Promise);
18+
const {sequence} = require('spex');
1919
2020
function source(index, data, delay) {
2121
// create and return a promise objects dynamically,
@@ -38,7 +38,7 @@ function dest(index, data, delay) {
3838
console.log('LOG:', index, data, delay);
3939
}
4040
41-
spex.sequence(source, {dest: dest, track: true})
41+
sequence(source, {dest: dest, track: true})
4242
.then(data => {
4343
console.log('DATA:', data); // print result;
4444
});
@@ -56,7 +56,7 @@ DATA: [ 'zero', 'one', 'two', 'three' ]
5656
And if we run the same sequence without tracking (default):
5757

5858
```js
59-
spex.sequence(source, {dest: dest})
59+
sequence(source, {dest: dest})
6060
.then(data => {
6161
console.log('DATA:', data); // print result;
6262
});

jsdoc/tutorials/throttling.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The example below uses method [page] to initiate a sequence of 5 pages, and then
2424
The `source` function serves each page with a half-second delay.
2525

2626
```js
27-
const spex = require('spex')(Promise);
27+
const {page} = require('spex');
2828
2929
function source(index, data, delay) {
3030
return new Promise((resolve, reject) => {
@@ -41,7 +41,7 @@ function logger(index, data, delay) {
4141
console.log('LOG:', data);
4242
}
4343
44-
spex.page(source, {dest: logger, limit: 5})
44+
page(source, {dest: logger, limit: 5})
4545
.then(data => {
4646
console.log('FINISHED:', data);
4747
});
@@ -64,7 +64,7 @@ In the following example we have a [sequence] that returns data while the index
6464
destination function that enforces a 1 second delay on processing each data resolved from the source.
6565

6666
```js
67-
const spex = require('spex')(Promise);
67+
const {sequence} = require('spex');
6868
6969
function source(index, data, delay) {
7070
console.log('SOURCE:', index, data, delay);
@@ -82,7 +82,7 @@ function dest(index, data, delay) {
8282
});
8383
}
8484
85-
spex.sequence(source, {dest: dest})
85+
sequence(source, {dest: dest})
8686
.then(data => {
8787
console.log('DATA:', data);
8888
});

lib/adapter.js

Lines changed: 0 additions & 68 deletions
This file was deleted.

0 commit comments

Comments
 (0)