Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Aug 27, 2019
1 parent 98d245d commit 3641933
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 25 deletions.
6 changes: 3 additions & 3 deletions jsdoc/fixLinks.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Automatic links:
var links = {
const links = {
'promise.all': 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all',
'Readable': 'https://nodejs.org/api/stream.html#stream_class_stream_readable',
'stream': 'https://github.com/vitaly-t/spex/blob/master/docs/concept/stream.md',
Expand All @@ -14,8 +14,8 @@ var links = {
};

function fixLinks(source) {
return source.replace(/\$\[[a-z0-9\s/+-.]+\]/gi, function (name) {
var sln = name.replace(/\$\[|]/g, ''); // stripped link name;
return source.replace(/\$\[[a-z0-9\s/+-.]+\]/gi, name => {
const sln = name.replace(/\$\[|]/g, ''); // stripped link name;
if (sln in links) {
return '<a href="' + links[sln] + '">' + sln + '</a>';
}
Expand Down
4 changes: 2 additions & 2 deletions jsdoc/shortLinks.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var fixLinks = require('./fixLinks');
const fixLinks = require('./fixLinks');

exports.handlers = {
beforeParse: function (e) {
beforeParse: e => {
e.source = fixLinks(e.source);
}
};
8 changes: 4 additions & 4 deletions jsdoc/tutorials/batch.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ And this is where method [batch] helps:
Let's start with a positive example, and throw in a few combinations of [mixed values].

```js
var spex = require('spex')(Promise);
const spex = require('spex')(Promise);
// function that returns a promise;
function getWord() {
Expand All @@ -46,18 +46,18 @@ function nested() {
return getExcl;
}
var values = [
const values = [
123,
'Hello',
getWord,
Promise.resolve(nested)
];
spex.batch(values)
.then(function (data) {
.then(data => {
console.log('DATA:', data);
})
.catch(function (error) {
.catch(error => {
console.log('ERROR:', error);
});
```
Expand Down
2 changes: 1 addition & 1 deletion jsdoc/tutorials/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The library exposes global variable `spexLib`, to be initialized as shown in the
```html
<script src="spex.js"></script>
<script>
var spex = spexLib(Promise); // Initializing with ES6 Promise;
const spex = spexLib(Promise); // Initializing with ES6 Promise;
</script>
```

Expand Down
9 changes: 5 additions & 4 deletions jsdoc/tutorials/sequencing.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Let's implement a linked sequence that calculates primes from the previous resul
```js
function nextPrime(value) {
if (value > 2) {
var i, q;
let i, q;
do {
i = 3;
value += 2;
Expand All @@ -36,8 +36,9 @@ function nextPrime(value) {
Building a sequence of the first 10 primes directly:

```js
var value, result = [];
for (var i = 0; i < 10; i++) {
const result = [];
let value;
for (let i = 0; i < 10; i++) {
value = nextPrime(value);
result.push(value);
}
Expand All @@ -58,7 +59,7 @@ function source(index, data) {
}
spex.sequence(source, {limit: 10, track: true})
.then(function (data) {
.then(data => {
console.log('Result:', data);
});
```
Expand Down
6 changes: 3 additions & 3 deletions jsdoc/tutorials/streaming.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Below is a simple track-enabled sequence that creates and returns promises one b
It also includes a destination function for logging purposes.

```js
var spex = require('spex')(Promise);
const spex = require('spex')(Promise);
function source(index, data, delay) {
// create and return a promise objects dynamically,
Expand All @@ -39,7 +39,7 @@ function dest(index, data, delay) {
}
spex.sequence(source, {dest: dest, track: true})
.then(function (data) {
.then(data => {
console.log('DATA:', data); // print result;
});
```
Expand All @@ -57,7 +57,7 @@ And if we run the same sequence without tracking (default):

```js
spex.sequence(source, {dest: dest})
.then(function (data) {
.then(data => {
console.log('DATA:', data); // print result;
});
```
Expand Down
16 changes: 8 additions & 8 deletions jsdoc/tutorials/throttling.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ The example below uses method [page] to initiate a sequence of 5 pages, and then
The `source` function serves each page with a half-second delay.

```js
var spex = require('spex')(Promise);
const spex = require('spex')(Promise);
function source(index, data, delay) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve([
'page-' + index, // simple value;
Promise.resolve(Date.now()) // promise value;
Expand All @@ -42,7 +42,7 @@ function logger(index, data, delay) {
}
spex.page(source, {dest: logger, limit: 5})
.then(function (data) {
.then(data => {
console.log('FINISHED:', data);
});
```
Expand All @@ -64,7 +64,7 @@ In the following example we have a [sequence] that returns data while the index
destination function that enforces a 1 second delay on processing each data resolved from the source.

```js
var spex = require('spex')(Promise);
const spex = require('spex')(Promise);
function source(index, data, delay) {
console.log('SOURCE:', index, data, delay);
Expand All @@ -75,15 +75,15 @@ function source(index, data, delay) {
function dest(index, data, delay) {
console.log('DEST:', index, data, delay);
return new Promise(function (resolve, reject) {
setTimeout(function () {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, 1000);
});
}
spex.sequence(source, {dest: dest})
.then(function (data) {
.then(data => {
console.log('DATA:', data);
});
```
Expand Down

0 comments on commit 3641933

Please sign in to comment.