| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,15 +1,14 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | - // Flags: --expose-internals --no-warnings | ||
| 2 | + // Flags: --no-warnings | ||
| 3 | 3 | ||
| 4 | 4 | const common = require('../common'); | |
| 5 | - const { once, EventEmitter } = require('events'); | ||
| 5 | + const { once, EventEmitter, getEventListeners } = require('events'); | ||
| 6 | 6 | const { | |
| 7 | 7 | deepStrictEqual, | |
| 8 | 8 | fail, | |
| 9 | 9 | rejects, | |
| 10 | 10 | strictEqual, | |
| 11 | 11 | } = require('assert'); | |
| 12 | - const { kEvents } = require('internal/event_target'); | ||
| 13 | 12 | ||
| 14 | 13 | async function onceAnEvent() { | |
| 15 | 14 | const ee = new EventEmitter(); | |
@@ -78,7 +77,7 @@ async function catchesErrorsWithAbortSignal() { | |||
| 78 | 77 | try { | |
| 79 | 78 | const promise = once(ee, 'myevent', { signal }); | |
| 80 | 79 | strictEqual(ee.listenerCount('error'), 1); | |
| 81 | - strictEqual(signal[kEvents].size, 1); | ||
| 80 | + strictEqual(getEventListeners(signal, 'abort').length, 1); | ||
| 82 | 81 | ||
| 83 | 82 | await promise; | |
| 84 | 83 | } catch (e) { | |
@@ -87,7 +86,7 @@ async function catchesErrorsWithAbortSignal() { | |||
| 87 | 86 | strictEqual(err, expected); | |
| 88 | 87 | strictEqual(ee.listenerCount('error'), 0); | |
| 89 | 88 | strictEqual(ee.listenerCount('myevent'), 0); | |
| 90 | - strictEqual(signal[kEvents].size, 0); | ||
| 89 | + strictEqual(getEventListeners(signal, 'abort').length, 0); | ||
| 91 | 90 | } | |
| 92 | 91 | ||
| 93 | 92 | async function stopListeningAfterCatchingError() { | |
@@ -198,9 +197,9 @@ async function abortSignalAfterEvent() { | |||
| 198 | 197 | ac.abort(); | |
| 199 | 198 | }); | |
| 200 | 199 | const promise = once(ee, 'foo', { signal: ac.signal }); | |
| 201 | - strictEqual(ac.signal[kEvents].size, 1); | ||
| 200 | + strictEqual(getEventListeners(ac.signal, 'abort').length, 1); | ||
| 202 | 201 | await promise; | |
| 203 | - strictEqual(ac.signal[kEvents].size, 0); | ||
| 202 | + strictEqual(getEventListeners(ac.signal, 'abort').length, 0); | ||
| 204 | 203 | } | |
| 205 | 204 | ||
| 206 | 205 | async function abortSignalRemoveListener() { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments