Skip to content

Commit

Permalink
docs: update jsdoc comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdalisue committed Aug 8, 2024
1 parent 27bca81 commit 8483ad3
Show file tree
Hide file tree
Showing 26 changed files with 43 additions and 36 deletions.
7 changes: 4 additions & 3 deletions async/chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
* console.log(await toArray(iter)); // [1, 2, 3, 4]
* ```
*
* It supports chaining malformed iterables.
*
* @example
* @example With malformed iterables
* ```ts
* import { toArray } from "@core/iterutil/async/to-array";
* import { chain } from "@core/iterutil/async/chain";
Expand All @@ -36,6 +34,9 @@ export async function* chain<
}
}

/**
* @inner
*/
export type Chain<T> = T extends readonly [] ? never
: T extends readonly [Iterable<infer U>] ? U
: T extends readonly [AsyncIterable<infer U>] ? U
Expand Down
2 changes: 1 addition & 1 deletion async/compact.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Removes all nullish values from an iterable.
* Removes all nullish (`null` or `undefined`) values from an iterable.
*
* @param iterable The iterable to compact.
* @returns The compacted iterable.
Expand Down
2 changes: 1 addition & 1 deletion async/compress.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Compress an iterable by selecting elements using a selector iterable.
* Compresses an iterable by selecting elements using a selector iterable.
*
* @param iterable The iterable to compress.
* @param selectors The selectors to use.
Expand Down
5 changes: 2 additions & 3 deletions async/drop.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* Drops the first `limit` items from the iterable.
*
* It throws an error if `limit` is less than 0.
*
* @param iterable The iterable to drop items from.
* @param limit The number of items to drop.
* @param limit The number of items to drop. It must be 0 or positive safe integer.
* @returns The iterable with the first `limit` items dropped.
* @throws {DropLimitError} If `limit` is less than 0 or non safe integer.
*
* @example
* ```ts
Expand Down
2 changes: 1 addition & 1 deletion async/enumerate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Enumerate an iterable.
* Enumerates an iterable.
*
* @param iterable The iterable to enumerate.
* @param start The starting index.
Expand Down
3 changes: 1 addition & 2 deletions async/first.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* Returns the first element of an iterable.
* If the iterable is empty, returns `undefined`.
* Returns the first element of an iterable. If the iterable is empty, returns `undefined`.
*
* @param iterable The iterable to get the first element from.
* @returns The first element of the iterable, or `undefined` if the iterable is empty.
Expand Down
1 change: 1 addition & 0 deletions async/for_each.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @example
* ```ts
* import { forEach } from "@core/iterutil/async/for-each";
*
* await forEach([1, 2, 3], console.log);
* // 1
* // 2
Expand Down
2 changes: 1 addition & 1 deletion async/iter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Convert an iterable to an iterator.
* Converts an iterable to an iterator.
*
* @param iterable The iterable to convert.
* @returns The iterator.
Expand Down
7 changes: 3 additions & 4 deletions async/take.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* Take the first `limit` items from the iterable.
*
* It throws an error if `limit` is less than 0.
* Takes the first `limit` items from the iterable.
*
* @param iterable The iterable to take items from.
* @param limit The number of items to take.
* @param limit The number of items to take. It must be 0 or positive safe integer.
* @returns The iterable with the first `limit` items taken.
* @throws {TakeLimitError} If `limit` is less than 0 or non safe integer.
*
* @example
* ```ts
Expand Down
2 changes: 1 addition & 1 deletion async/take_while.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Take elements from the iterable while the predicate is true.
* Takes elements from the iterable while the predicate is true.
*
* @param iterable The iterable to take elements from.
* @param fn The predicate to take elements with.
Expand Down
2 changes: 1 addition & 1 deletion async/uniq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* console.log(await toArray(iter)); // [1, 2, 3]
* ```
*
* @example
* @example With identify function
* ```ts
* import { toArray } from "@core/iterutil/async/to-array";
* import { uniq } from "@core/iterutil/async/uniq";
Expand Down
3 changes: 3 additions & 0 deletions async/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export async function* zip<
}
}

/**
* @inner
*/
export type Zip<T extends (Iterable<unknown> | AsyncIterable<unknown>)[]> = {
[P in keyof T]: T[P] extends Iterable<infer U> ? U
: T[P] extends AsyncIterable<infer U> ? U
Expand Down
7 changes: 4 additions & 3 deletions chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
* console.log([...iter]); // [1, 2, 3, 4]
* ```
*
* It supports chaining malformed iterables.
*
* @example
* @example With malformed iterables
* ```ts
* import { chain } from "@core/iterutil/chain";
*
Expand All @@ -30,6 +28,9 @@ export function* chain<T extends Iterable<unknown>[]>(
}
}

/**
* @inner
*/
export type Chain<T> = T extends readonly [] ? never
: T extends readonly [Iterable<infer U>] ? U
: T extends readonly [Iterable<infer U>, ...infer R] ? U | Chain<R>
Expand Down
2 changes: 1 addition & 1 deletion compact.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Removes all nullish values from an iterable.
* Removes all nullish (`null` or `undefined`) values from an iterable.
*
* @param iterable The iterable to compact.
* @returns The compacted iterable.
Expand Down
2 changes: 1 addition & 1 deletion compress.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Compress an iterable by selecting elements using a selector iterable.
* Compresses an iterable by selecting elements using a selector iterable.
*
* @param iterable The iterable to compress.
* @param selectors The selectors to use.
Expand Down
5 changes: 2 additions & 3 deletions drop.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* Drops the first `limit` items from the iterable.
*
* It throws an error if `limit` is less than 0.
*
* @param iterable The iterable to drop items from.
* @param limit The number of items to drop.
* @param limit The number of items to drop. It must be 0 or positive safe integer.
* @returns The iterable with the first `limit` items dropped.
* @throws {DropLimitError} If `limit` is less than 0 or non safe integer.
*
* @example
* ```ts
Expand Down
2 changes: 1 addition & 1 deletion enumerate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Enumerate an iterable.
* Enumerates an iterable.
*
* @param iterable The iterable to enumerate.
* @param start The starting index.
Expand Down
3 changes: 1 addition & 2 deletions first.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* Returns the first element of an iterable.
* If the iterable is empty, returns `undefined`.
* Returns the first element of an iterable. If the iterable is empty, returns `undefined`.
*
* @param iterable The iterable to get the first element from.
* @returns The first element of the iterable, or `undefined` if the iterable is empty.
Expand Down
1 change: 1 addition & 0 deletions for_each.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @example
* ```ts
* import { forEach } from "@core/iterutil/for-each";
*
* forEach([1, 2, 3], console.log);
* // 1
* // 2
Expand Down
2 changes: 1 addition & 1 deletion iter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Convert an iterable to an iterator.
* Converts an iterable to an iterator.
*
* @param iterable The iterable to convert.
* @returns The iterator.
Expand Down
1 change: 1 addition & 0 deletions range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* @param stop The end of the range.
* @returns The range of numbers.
*
* @example
* ```ts
* import { range } from "@core/iterutil/range";
Expand Down
7 changes: 3 additions & 4 deletions take.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* Take the first `limit` items from the iterable.
*
* It throws an error if `limit` is less than 0.
* Takes the first `limit` items from the iterable.
*
* @param iterable The iterable to take items from.
* @param limit The number of items to take.
* @param limit The number of items to take. It must be 0 or positive safe integer.
* @returns The iterable with the first `limit` items taken.
* @throws {TakeLimitError} If `limit` is less than 0 or non safe integer.
*
* @example
* ```ts
Expand Down
2 changes: 1 addition & 1 deletion take_while.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Take elements from the iterable while the predicate is true.
* Takes elements from the iterable while the predicate is true.
*
* @param iterable The iterable to take elements from.
* @param fn The predicate to take elements with.
Expand Down
2 changes: 2 additions & 0 deletions to_array.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Converts an iterable to an array.
*
* Note that users should use `Array.from` directly. This function exists for consistency with `async/to-array.toArray`.
*
* @param iterable The iterable to convert.
* @returns The array.
*
Expand Down
2 changes: 1 addition & 1 deletion uniq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* console.log([...iter]); // [1, 2, 3]
* ```
*
* @example
* @example With identify function
* ```ts
* import { uniq } from "@core/iterutil/uniq";
*
Expand Down
3 changes: 3 additions & 0 deletions zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export function* zip<U extends Iterable<unknown>[]>(
}
}

/**
* @inner
*/
export type Zip<T extends Iterable<unknown>[]> = {
[P in keyof T]: T[P] extends Iterable<infer U> ? U : never;
};

0 comments on commit 8483ad3

Please sign in to comment.