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 06bc1ef commit a513233
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 28 deletions.
18 changes: 7 additions & 11 deletions lib/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@
* Below is an example of setting up a [client-side]{@tutorial client} adapter for AngularJS $q.
*
* ```js
* var spexLib = require('spex'); // or include client-side spex.js
* const spexLib = require('spex'); // or include client-side spex.js
*
* var adapter = new spexLib.PromiseAdapter(
* function (cb) {
* return $q(cb); // creating a new promise;
* }, function (data) {
* return $q.when(data); // resolving a promise;
* }, function (reason) {
* return $q.reject(reason); // rejecting a promise;
* });
* const adapter = new spexLib.PromiseAdapter(
* cb => $q(cb), // creating a new promise;
* data => $q.when(data), // resolving a promise;
* reason => $q.reject(reason) // rejecting a promise;
* );
*
* var spex = spexLib(adapter);
* const spex = spexLib(adapter);
* ```
* Please note that AngularJS 1.4.1 or later no longer requires a promise adapter.
*
* @param {Function} create
* A function that takes a callback parameter and returns a new promise object.
Expand Down
22 changes: 11 additions & 11 deletions lib/ext/stream/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,44 @@ const npm = {
* **Synchronous Stream Processing**
*
* ```js
* var stream = require('spex')(Promise).stream;
* var fs = require('fs');
* const stream = require('spex')(Promise).stream;
* const fs = require('fs');
*
* var rs = fs.createReadStream('values.txt');
* const rs = fs.createReadStream('values.txt');
*
* function receiver(index, data, delay) {
* console.log('RECEIVED:', index, data, delay);
* }
*
* stream.read(rs, receiver)
* .then(function (data) {
* .then(data => {
* console.log('DATA:', data);
* })
* .catch(function (error) {
* .catch(error => {
* console.log('ERROR:', error);
* });
* ```
*
* **Asynchronous Stream Processing**
*
* ```js
* var stream = require('spex')(Promise).stream;
* var fs = require('fs');
* const stream = require('spex')(Promise).stream;
* const fs = require('fs');
*
* var rs = fs.createReadStream('values.txt');
* const rs = fs.createReadStream('values.txt');
*
* function receiver(index, data, delay) {
* return new Promise(function (resolve) {
* return new Promise(resolve => {
* console.log('RECEIVED:', index, data, delay);
* resolve();
* });
* }
*
* stream.read(rs, receiver)
* .then(function (data) {
* .then(data => {
* console.log('DATA:', data);
* })
* .catch(function (error) {
* .catch(error => {
* console.log('ERROR:', error);
* });
* ```
Expand Down
5 changes: 2 additions & 3 deletions lib/ext/stream/read.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,9 @@ function read(stream, receiver, options, config) {
} else {
cache = [];
waiting = true;
let page;
do {
// TODO: var page is defined wrong way here
// eslint-disable-next-line
var page = stream.read(readSize);
page = stream.read(readSize);
if (page) {
cache.push(page);
// istanbul ignore next: requires a unique stream that
Expand Down
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ const npm = {
* ### usage
* For any third-party promise library:
* ```js
* var promise = require('bluebird');
* var spex = require('spex')(promise);
* const promise = require('bluebird');
* const spex = require('spex')(promise);
* ```
* For ES6 promises:
* ```js
* var spex = require('spex')(Promise);
* const spex = require('spex')(Promise);
* ```
*
* @param {Object|Function} promiseLib
Expand Down

0 comments on commit a513233

Please sign in to comment.