Skip to content

Commit e2bf93f

Browse files
♻️ refactor: Improve docstrings.
1 parent 2c25816 commit e2bf93f

21 files changed

+33
-32
lines changed

src/Tape.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ export default class Tape {
99
/**
1010
* The constructor. Stores the callable that yields values to put on the tape.
1111
*
12-
* @param {Callable} callable - The callable to use.
12+
* @param {Function} callable - The callable to use.
1313
*/
1414
constructor(callable) {
1515
/**
1616
* The callable yielding values to put on the tape.
17-
* @type {Callable}
17+
* @type {Function}
1818
*/
1919
this.callable = callable;
2020

@@ -26,7 +26,7 @@ export default class Tape {
2626

2727
/**
2828
* The eof symbol.
29-
* @type {String}
29+
* @type {any}
3030
*/
3131
this.eof = eof;
3232
}
@@ -35,7 +35,7 @@ export default class Tape {
3535
* Returns the next token on the tape or {@link Tape#eof}
3636
* if the tape has been exhausted.
3737
*
38-
* @returns {Object} The next token on the tape or {@link Tape#eof}.
38+
* @returns {Promise} The next token on the tape or {@link Tape#eof}.
3939
*/
4040
async read() {
4141
if (this.buffer.length > 0) return this.buffer.pop();
@@ -51,7 +51,7 @@ export default class Tape {
5151
* Puts a token back on the tape. If {@link Tape#read} is
5252
* used just after, this token will be returned.
5353
*
54-
* @param {Object} token - The token to put back on the tape.
54+
* @param {any} token - The token to put back on the tape.
5555
*/
5656
unread(token) {
5757
// Should this be async too ?
@@ -69,7 +69,7 @@ export default class Tape {
6969
/**
7070
* Skip the next `n` tokens on the tape.
7171
*
72-
* @param {Number} n - The number of tokens to skip.
72+
* @param {number} n - The number of tokens to skip.
7373
*/
7474
async skipMany(n) {
7575
while (n-- > 0) await this.skip(); // eslint-disable-line no-await-in-loop

src/asyncIterableChain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Utility function to chain an async iterable of async iterables.
33
*
44
* @private
5-
* @param {AsyncIterable} iterables - the input iterable of iterables.
5+
* @param {AsyncIterable<AsyncIterable>} iterables - the input iterable of iterables.
66
* @returns {AsyncIterable} The chain of the input iterables.
77
*/
88
export default async function* asyncIterableChain(iterables) {

src/asyncIterableMap.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Utility function to apply a sync callable to each item of an async iterable.
33
*
44
* @private
5-
* @param {Callable} callable - The callable to apply.
5+
* @param {Function} callable - The callable to apply.
66
* @param {AsyncIterable} iterable - The iterable to process.
77
* @returns {AsyncIterable} The iterable of mapped values.
88
*/

src/asyncIterableToArray.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* @private
55
* @param {AsyncIterable} asyncIterable - the input iterable.
6-
* @returns {Array} A new array filled with the elements of the input iterable.
6+
* @returns {Promise<any[]>} A new array filled with the elements of the input iterable.
77
*/
88
export default async function asyncIterableToArray(asyncIterable) {
99
const array = [];

src/chain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import asyncIterableMap from './asyncIterableMap.js';
66
/**
77
* Converts a tape of tapes of tokens to a tape of tokens.
88
* @param {Tape} tape - The tape of tapes of tokens to read from.
9-
* @return {Tape} The converted tape of tokens.
9+
* @returns {Tape} The converted tape of tokens.
1010
*/
1111
export default function chain(tape) {
1212
return fromAsyncIterable(

src/eof.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/**
22
* Shared object used as end of file.
3+
*
4+
* @type {object}
35
*/
4-
export default {};
6+
const eof = {};
7+
export default eof;

src/fromArray.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import fromIterable from './fromIterable.js';
44
* Converts an array to a tape.
55
*
66
* @function
7-
* @param {Array} _array - the array to convert
7+
* @param {Array} array - the array to convert
88
* @returns {Tape}
99
*/
10-
export default fromIterable;
10+
const fromArray = fromIterable;
11+
export default fromArray;

src/fromCallable.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Tape from './Tape.js';
44
* Converts a callable to a tape.
55
*
66
* @function
7-
* @param {Callable} callable - The callable to convert.
7+
* @param {Function} callable - The callable to convert.
88
* @returns {Tape} The converted tape.
99
*/
1010
export default (callable) => new Tape(callable);

src/fromIterator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import fromCallable from './fromCallable.js';
44
* Converts an iterator to a tape.
55
*
66
* @function
7-
* @param {Iterator} iterator - The iterator to convert.
7+
* @param {Iterator|AsyncIterator} iterator - The iterator to convert.
88
* @returns {Tape} The converted tape.
99
*/
1010
export default (iterator) => fromCallable(iterator.next.bind(iterator));

src/fromString.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import fromIterable from './fromIterable.js';
77
* fromString( '1,3,2' ) ;
88
*
99
* @function
10-
* @param {String} _string - the string to convert
10+
* @param {string} string - the string to convert
1111
* @returns {Tape}
1212
*/
13-
export default fromIterable;
13+
const fromString = fromIterable;
14+
export default fromString;

0 commit comments

Comments
 (0)