Skip to content

Commit

Permalink
Minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Smoren committed May 25, 2023
1 parent 2fe26df commit 638e07f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IterTools Typescript Change Log

## v1.22.0 - 2023-05-25
## v1.23.0 - 2023-05-25

### New features
* summary
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "itertools-ts",
"version": "1.22.0",
"version": "1.23.0",
"description": "Extended itertools port for TypeScript and JavaScript. Provides a huge set of functions for working with iterable collections (including async ones)",
"license": "MIT",
"repository": {
Expand Down
8 changes: 5 additions & 3 deletions src/async-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
zipLongestAsync,
} from "./multi";
import {
runningAverage,
runningAverageAsync,
runningDifferenceAsync,
runningMaxAsync,
Expand Down Expand Up @@ -905,8 +904,11 @@ export class AsyncStream {
*
* @see summary.exactlyNAsync
*/
async exactlyNAsync(n: number, predicate?: (item: unknown) => Promise<boolean> | boolean): Promise<boolean> {
return exactlyNAsync(this, n, predicate)
async exactlyNAsync(
n: number,
predicate?: (item: unknown) => Promise<boolean> | boolean
): Promise<boolean> {
return exactlyNAsync(this, n, predicate);
}

/**
Expand Down
12 changes: 6 additions & 6 deletions src/math.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ export function* runningAverage<T>(
numbers: Iterable<T> | Iterator<T>,
initialValue?: number
): Iterable<number> {

let n = 0;
for (const total of runningTotal(toIterable(numbers), initialValue)) {
n++;
yield total / n as number;
yield (total / n) as number;
}
}

Expand All @@ -28,11 +27,13 @@ export async function* runningAverageAsync<T>(
numbers: AsyncIterable<T> | AsyncIterator<T> | Iterable<T> | Iterator<T>,
initialValue?: number
): AsyncIterable<number> {

let n = 0;
for await (const total of runningTotalAsync(toAsyncIterable(numbers), initialValue)) {
for await (const total of runningTotalAsync(
toAsyncIterable(numbers),
initialValue
)) {
n++;
yield total / n as number;
yield (total / n) as number;
}
}

Expand Down Expand Up @@ -245,4 +246,3 @@ export async function* runningTotalAsync<T>(
yield total as number;
}
}

2 changes: 1 addition & 1 deletion src/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ export class Stream {
* @see summary.exactlyN
*/
exactlyN(n: number, predicate?: (item: unknown) => boolean): boolean {
return exactlyN(this, n, predicate)
return exactlyN(this, n, predicate);
}
/**
* Returns true if stream is sorted in ascending order; otherwise false.
Expand Down
8 changes: 4 additions & 4 deletions src/summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export async function anyMatchAsync<T>(
export function exactlyN<T>(
data: Iterable<T> | Iterator<T>,
n: number,
predicate?: (item: T) => boolean,
predicate?: (item: T) => boolean
): boolean {
if (n < 0) {
return false;
Expand All @@ -163,7 +163,7 @@ export function exactlyN<T>(
if (predicate(datum)) {
count++;
if (count > n) {
return false
return false;
}
}
}
Expand All @@ -182,7 +182,7 @@ export function exactlyN<T>(
export async function exactlyNAsync<T>(
data: AsyncIterable<T> | AsyncIterator<T> | Iterable<T> | Iterator<T>,
n: number,
predicate?: (item: T) => Promise<boolean> | boolean,
predicate?: (item: T) => Promise<boolean> | boolean
): Promise<boolean> {
if (n < 0) {
return false;
Expand All @@ -197,7 +197,7 @@ export async function exactlyNAsync<T>(
if (await predicate(datum)) {
count++;
if (count > n) {
return false
return false;
}
}
}
Expand Down

0 comments on commit 638e07f

Please sign in to comment.