Skip to content

Commit d8a32f8

Browse files
committed
Rename info.promiseValue to info.value
1 parent 13bd10d commit d8a32f8

File tree

8 files changed

+41
-48
lines changed

8 files changed

+41
-48
lines changed

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,21 @@ Can be
163163
or
164164
[`"warning"`](https://nodejs.org/api/process.html#process_event_warning).
165165

166-
## `info.error`
166+
## `info.value`
167167

168-
Either the value thrown by
169-
[`uncaughtException`](https://nodejs.org/api/process.html#process_event_uncaughtexception)
170-
or the error emitted by
171-
[`warning`](https://nodejs.org/api/process.html#process_event_warning).
172-
Not defined with other events. It is usually an `Error` instance but could be
173-
anything.
168+
Can be:
169+
170+
- the value thrown by
171+
[`uncaughtException`](https://nodejs.org/api/process.html#process_event_uncaughtexception).
172+
- the value resolved/rejected by the promise with
173+
[`unhandledRejection`](https://nodejs.org/api/process.html#process_event_unhandledrejection),
174+
[`rejectionHandled`](https://nodejs.org/api/process.html#process_event_rejectionhandled)
175+
and
176+
[`multipleResolves`](https://nodejs.org/api/process.html#process_event_multipleresolves).
177+
- the error emitted by
178+
[`warning`](https://nodejs.org/api/process.html#process_event_warning).
179+
180+
It is usually an `Error` instance but could be anything.
174181

175182
## `info.rejected`
176183

@@ -181,14 +188,6 @@ with
181188
and
182189
[`multipleResolves`](https://nodejs.org/api/process.html#process_event_multipleresolves).
183190

184-
## `info.promiseValue`
185-
186-
Value resolved/rejected by the promise. Only defined with
187-
[`unhandledRejection`](https://nodejs.org/api/process.html#process_event_unhandledrejection),
188-
[`rejectionHandled`](https://nodejs.org/api/process.html#process_event_rejectionhandled)
189-
and
190-
[`multipleResolves`](https://nodejs.org/api/process.html#process_event_multipleresolves).
191-
192191
## `info.nextRejected`, `info.nextValue`
193192

194193
Like [`rejected`](#inforejected) and [`value`](#infovalue) but for

src/events.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const warning = function(context, error) {
1313
handleEvent({ ...context, error })
1414
}
1515

16-
const unhandledRejection = function(context, promiseValue, promise) {
17-
handleEvent({ ...context, promise, promiseValue })
16+
const unhandledRejection = function(context, value, promise) {
17+
handleEvent({ ...context, promise, value })
1818
}
1919

2020
const rejectionHandled = function(context, promise) {

src/handle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const handleEvent = async function({
1616
mEmitLimitedWarning,
1717
error,
1818
promise,
19-
promiseValue,
19+
value,
2020
nextRejected,
2121
nextValue,
2222
}) {
@@ -28,7 +28,7 @@ const handleEvent = async function({
2828
eventName,
2929
error,
3030
promise,
31-
promiseValue,
31+
value,
3232
nextRejected,
3333
nextValue,
3434
})

src/info.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ const getInfo = async function({
77
eventName,
88
error,
99
promise,
10-
promiseValue,
10+
value,
1111
nextRejected,
1212
nextValue,
1313
}) {
14-
const { rejected, promiseValue: promiseValueA } = await parsePromise({
14+
const { rejected, value: valueA } = await parsePromise({
1515
eventName,
1616
promise,
17-
promiseValue,
17+
value,
1818
})
1919

2020
const info = {
2121
eventName,
2222
error,
2323
rejected,
24-
promiseValue: promiseValueA,
24+
value: valueA,
2525
nextRejected,
2626
nextValue,
2727
}
@@ -31,24 +31,24 @@ const getInfo = async function({
3131
}
3232

3333
// Retrieve promise's resolved/rejected state and value.
34-
const parsePromise = async function({ eventName, promise, promiseValue }) {
34+
const parsePromise = async function({ eventName, promise, value }) {
3535
// `uncaughtException` and `warning` events do not have `promise`.
3636
if (promise === undefined) {
3737
return {}
3838
}
3939

4040
// `unhandledRejection` should not use the following code because:
41-
// - we already know `rejected` and `promiseValue`
41+
// - we already know `rejected` and `value`
4242
// - using `try/catch` will fire `rejectionHandled`
4343
if (eventName === 'unhandledRejection') {
44-
return { rejected: true, promiseValue }
44+
return { rejected: true, value }
4545
}
4646

4747
// `rejectionHandled` and `multipleResolves` use `await promise`
4848
try {
49-
return { rejected: false, promiseValue: await promise }
49+
return { rejected: false, value: await promise }
5050
} catch (error) {
51-
return { rejected: true, promiseValue: error }
51+
return { rejected: true, value: error }
5252
}
5353
}
5454

src/limit.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const { MAX_EVENTS } = require('./constants')
1313
// - it prevents infinite recursions if `opts.log|level|message()` triggers
1414
// itself an event.
1515
// The `repeated` logic should prevent it most of the times, but it can still
16-
// happen when `error` or `[second]promiseValue` is not an `Error` instance
17-
// and contain dynamic content.
16+
// happen when `[next]Value` is not an `Error` instance and contain dynamic
17+
// content.
1818
const isLimited = function({
1919
previousEvents,
2020
mEmitLimitedWarning,

src/message.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const getMessage = function({ opts, info, level, colors }) {
1616
const defaultMessage = function({
1717
eventName,
1818
rejected,
19-
promiseValue,
19+
value,
2020
nextRejected,
2121
nextValue,
2222
error,
@@ -25,7 +25,7 @@ const defaultMessage = function({
2525
}) {
2626
const message = MESSAGES[eventName]({
2727
rejected,
28-
promiseValue,
28+
value,
2929
nextRejected,
3030
nextValue,
3131
error,
@@ -47,21 +47,21 @@ const warning = function({ error, error: { code, detail } }) {
4747
${codeMessage}${detailMessage}${serialize(error)}`
4848
}
4949

50-
const unhandledRejection = function({ promiseValue }) {
50+
const unhandledRejection = function({ value }) {
5151
return ` (a promise was rejected but not handled)
52-
${serialize(promiseValue)}`
52+
${serialize(value)}`
5353
}
5454

55-
const rejectionHandled = function({ promiseValue }) {
55+
const rejectionHandled = function({ value }) {
5656
return ` (a promise was rejected and handled too late)
57-
${serialize(promiseValue)}`
57+
${serialize(value)}`
5858
}
5959

6060
// The default level is `info` because it does not always indicate an
6161
// error: https://github.com/nodejs/node/issues/24321
6262
const multipleResolves = function({
6363
rejected,
64-
promiseValue,
64+
value,
6565
nextRejected,
6666
nextValue,
6767
}) {
@@ -73,7 +73,7 @@ const multipleResolves = function({
7373
const state = again ? rejectedStr : 'resolved/rejected'
7474

7575
return ` (a promise was ${state} multiple times)
76-
Initially ${rejectedStr} with: ${serialize(promiseValue)}
76+
Initially ${rejectedStr} with: ${serialize(value)}
7777
Then ${nextRejectedStr}${again} with: ${serialize(nextValue)}`
7878
}
7979

src/repeat.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ const getFingerprint = function({ info }) {
3939
// We do not serialize `info.eventName` since this is already `eventName-wise`
4040
// Key order matters since fingerprint might be truncated: we serialize short
4141
// and non-dynamic values first.
42-
const INFO_PROPS = [
43-
'nextRejected',
44-
'rejected',
45-
'error',
46-
'nextValue',
47-
'promiseValue',
48-
]
42+
const INFO_PROPS = ['nextRejected', 'rejected', 'error', 'nextValue', 'value']
4943

5044
const FINGERPRINT_MAX_LENGTH = 1e4
5145

test/info.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ const INFOS = [
3434
{
3535
name: 'unhandledRejection',
3636
arg: () => true,
37-
expected: { rejected: true, promiseValue: true },
37+
expected: { rejected: true, value: true },
3838
},
3939
{
4040
name: 'rejectionHandled',
4141
arg: () => true,
42-
expected: { rejected: true, promiseValue: true },
42+
expected: { rejected: true, value: true },
4343
},
4444
{
4545
name: 'multipleResolves',
4646
arg: [['resolve', () => true], ['reject', () => false]],
4747
expected: {
4848
rejected: false,
49-
promiseValue: true,
49+
value: true,
5050
nextRejected: true,
5151
nextValue: false,
5252
},

0 commit comments

Comments
 (0)