Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 987b95c

Browse files
authored
fix: export helper functions to match documentation (#9)
1 parent 41a52e5 commit 987b95c

3 files changed

Lines changed: 21 additions & 0 deletions

File tree

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export * from './flatMap';
1616
export * from './flatten';
1717
export * from './includes';
1818
export * from './interleave';
19+
export * from './isIterable';
20+
export * from './iteratorFromIterable';
1921
export * from './map';
2022
export * from './merge';
2123
export * from './range';

src/isIterable.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1+
/**
2+
* Determines if the provided value adheres to the AsyncIterable protocol.
3+
*
4+
* @param arg Any value
5+
*/
16
export function isAsyncIterable<T>(arg: any): arg is AsyncIterable<T> {
27
return Boolean(arg) && typeof arg[Symbol.asyncIterator] === 'function';
38
}
49

10+
/**
11+
* Determines if the provided value adheres to Iterable protocol.
12+
*
13+
* @param arg Any value
14+
*/
515
export function isSyncIterable<T>(arg: any): arg is Iterable<T> {
616
return Boolean(arg) && typeof arg[Symbol.iterator] === 'function';
717
}

src/iteratorFromIterable.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import { isAsyncIterable } from './isIterable';
22

3+
/**
4+
* Extracts the underlying synchronous or asynchronous iterator from a
5+
* synchronous or asynchronous iterable, respectively.
6+
*
7+
* If the provided value adheres to both the Iterable and AsyncIterable
8+
* protocols, its asynchronous interface will be used.
9+
*
10+
* @param iterable A synchronous or asynchronous iterable.
11+
*/
312
export function iteratorFromIterable<T>(
413
iterable: Iterable<T>|AsyncIterable<T>
514
): Iterator<T>|AsyncIterator<T> {

0 commit comments

Comments
 (0)