Skip to content

Commit 543af9f

Browse files
committed
Changed name of new reflectStatus function
1 parent f879754 commit 543af9f

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## next version
44

5-
* Added `reflectStatus()` function.
5+
* Added `reflectAsyncStatus()` function.
66

77
## 1.1.4
88

modern-async.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ declare module "timeoutPrecise" {
220220
export default timeoutPrecise;
221221
function timeoutPrecise<T>(fct: () => Promise<T> | T, amount: number): Promise<T>;
222222
}
223-
declare module "reflectStatus" {
224-
export default reflectStatus;
225-
function reflectStatus<T>(fct: () => Promise<T> | T): Promise<PromiseSettledResult<T>>;
223+
declare module "reflectAsyncStatus" {
224+
export default reflectAsyncStatus;
225+
function reflectAsyncStatus<T>(fct: () => Promise<T> | T): Promise<PromiseSettledResult<T>>;
226226
}
227227
declare module "modern-async" {
228228
export { default as asyncIterableWrap } from "asyncIterableWrap";
@@ -269,5 +269,5 @@ declare module "modern-async" {
269269
export { default as TimeoutError } from "TimeoutError";
270270
export { default as timeoutPrecise } from "timeoutPrecise";
271271
export { default as toArray } from "toArray";
272-
export { default as reflectStatus } from "reflectStatus";
272+
export { default as reflectAsyncStatus } from "reflectAsyncStatus";
273273
}

src/findInternal.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import assert from 'nanoassert'
33
import asyncWrap from './asyncWrap.mjs'
44
import asyncIterableWrap from './asyncIterableWrap.mjs'
55
import getQueue from './getQueue.mjs'
6-
import reflectStatus from './reflectStatus.mjs'
6+
import reflectAsyncStatus from './reflectAsyncStatus.mjs'
77

88
/**
99
* @ignore
@@ -40,7 +40,7 @@ async function findInternal (iterable, iteratee, queueOrConcurrency, ordered) {
4040
const identifier = waitListIndex
4141
waitListIndex += 1
4242
const p = (async () => {
43-
return [identifier, await reflectStatus(fct)]
43+
return [identifier, await reflectAsyncStatus(fct)]
4444
})()
4545
assert(!waitList.has(identifier), 'waitList already contains identifier')
4646
waitList.set(identifier, p)
@@ -72,7 +72,7 @@ async function findInternal (iterable, iteratee, queueOrConcurrency, ordered) {
7272
const removed = scheduledList.delete(index)
7373
assert(removed, 'Couldn\'t find index in scheduledList for removal')
7474

75-
const snapshot = await reflectStatus(() => iteratee(value, index, iterable))
75+
const snapshot = await reflectAsyncStatus(() => iteratee(value, index, iterable))
7676

7777
scheduledCount -= 1
7878
insertInResults(index, value, snapshot)
@@ -103,7 +103,7 @@ async function findInternal (iterable, iteratee, queueOrConcurrency, ordered) {
103103
const fetch = () => {
104104
fetching = true
105105
addToWaitList(async () => {
106-
const snapshot = await reflectStatus(() => it.next())
106+
const snapshot = await reflectAsyncStatus(() => it.next())
107107
fetching = false
108108
if (snapshot.status === 'fulfilled') {
109109
const { value, done } = snapshot.value

src/mapGenerator.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import asyncWrap from './asyncWrap.mjs'
44
import asyncIterableWrap from './asyncIterableWrap.mjs'
55
import getQueue from './getQueue.mjs'
66
import Queue from './Queue.mjs'
7-
import reflectStatus from './reflectStatus.mjs'
7+
import reflectAsyncStatus from './reflectAsyncStatus.mjs'
88

99
/**
1010
* Produces a an async iterator that will return each value or `iterable` after having processed them through
@@ -78,7 +78,7 @@ async function * mapGenerator (iterable, iteratee, queueOrConcurrency = 1, order
7878
const identifier = waitListIndex
7979
waitListIndex += 1
8080
const p = (async () => {
81-
return [identifier, await reflectStatus(fct)]
81+
return [identifier, await reflectAsyncStatus(fct)]
8282
})()
8383
assert(!waitList.has(identifier), 'waitList contains identifier')
8484
waitList.set(identifier, p)
@@ -110,7 +110,7 @@ async function * mapGenerator (iterable, iteratee, queueOrConcurrency = 1, order
110110
const removed = scheduledList.delete(index)
111111
assert(removed, 'Couldn\'t find index in scheduledList for removal')
112112

113-
const snapshot = await reflectStatus(() => iteratee(value, index, iterable))
113+
const snapshot = await reflectAsyncStatus(() => iteratee(value, index, iterable))
114114

115115
scheduledCount -= 1
116116
insertInResults(index, value, snapshot)
@@ -141,7 +141,7 @@ async function * mapGenerator (iterable, iteratee, queueOrConcurrency = 1, order
141141
const fetch = () => {
142142
fetching = true
143143
addToWaitList(async () => {
144-
const snapshot = await reflectStatus(() => it.next())
144+
const snapshot = await reflectAsyncStatus(() => it.next())
145145
fetching = false
146146
if (snapshot.status === 'fulfilled') {
147147
const { value, done } = snapshot.value

src/modern-async.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ export { default as timeout } from './timeout.mjs'
4343
export { default as TimeoutError } from './TimeoutError.mjs'
4444
export { default as timeoutPrecise } from './timeoutPrecise.mjs'
4545
export { default as toArray } from './toArray.mjs'
46-
export { default as reflectStatus } from './reflectStatus.mjs'
46+
export { default as reflectAsyncStatus } from './reflectAsyncStatus.mjs'

src/reflectStatus.mjs renamed to src/reflectAsyncStatus.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
* @returns {Promise<any>} A promise that will always be resolved with an object containing
2323
* a snapshot of the original promise state.
2424
* @example
25-
* import { reflectStatus, map, sleep } from 'modern-async'
25+
* import { reflectAsyncStatus, map, sleep } from 'modern-async'
2626
*
2727
* const array = [1, 2, 3]
2828
*
29-
* const result = await map(array, (v) => reflectStatus(async () => {
29+
* const result = await map(array, (v) => reflectAsyncStatus(async () => {
3030
* await sleep(10) // waits 10ms
3131
* if (v % 2 === 0) { // throws error on some values
3232
* throw Error("error")
@@ -42,7 +42,7 @@
4242
* // { status: 'fulfilled', value: 3 }
4343
* // ]
4444
*/
45-
async function reflectStatus (fct) {
45+
async function reflectAsyncStatus (fct) {
4646
try {
4747
const res = await fct()
4848
return {
@@ -57,4 +57,4 @@ async function reflectStatus (fct) {
5757
}
5858
}
5959

60-
export default reflectStatus
60+
export default reflectAsyncStatus

src/reflectStatus.test.mjs renamed to src/reflectAsyncStatus.test.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
import { expect, test } from '@jest/globals'
3-
import reflectStatus from './reflectStatus.mjs'
3+
import reflectAsyncStatus from './reflectAsyncStatus.mjs'
44
import delay from './delay.mjs'
55

6-
test('reflectStatus base test', async () => {
7-
const res1 = await reflectStatus(async () => {
6+
test('reflectAsyncStatus base test', async () => {
7+
const res1 = await reflectAsyncStatus(async () => {
88
await delay()
99
return 3
1010
})
@@ -15,8 +15,8 @@ test('reflectStatus base test', async () => {
1515
expect(res1.reason).toBeUndefined()
1616
})
1717

18-
test('reflectStatus falure', async () => {
19-
const res1 = await reflectStatus(async () => {
18+
test('reflectAsyncStatus falure', async () => {
19+
const res1 = await reflectAsyncStatus(async () => {
2020
await delay()
2121
throw new Error('error')
2222
})

0 commit comments

Comments
 (0)