File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 'use strict'
2+
13const Packet = require ( 'aedes-packet' )
2- const { PromisifiedPersistence, waitForEvent, getArrayFromStream } = require ( './promisified.js' )
4+ const { once } = require ( 'node:events' )
5+ const { PromisifiedPersistence, getArrayFromStream } = require ( './promisified.js' )
36
47// helper functions
58
@@ -73,7 +76,7 @@ function abstractPersistence (opts) {
7376 // destroyed while it's still being set up.
7477 // https://github.com/mcollina/aedes-persistence-redis/issues/41
7578 if ( waitForReady && ! instance . ready ) {
76- await waitForEvent ( instance , 'ready' )
79+ await once ( instance , 'ready' )
7780 }
7881 t . diagnostic ( 'instance created' )
7982 const prInstance = new PromisifiedPersistence ( instance )
Original file line number Diff line number Diff line change 11// promisified versions of the persistence interface
22// to avoid deep callbacks while testing
33
4+ 'use strict'
5+
46class PromisifiedPersistence {
57 constructor ( instance ) {
68 this . instance = instance
@@ -272,14 +274,6 @@ class PromisifiedPersistence {
272274// end of promisified versions ofthis.instance methods
273275
274276// helper functions
275- function waitForEvent ( obj , resolveEvt ) {
276- return new Promise ( ( resolve , reject ) => {
277- obj . once ( resolveEvt , ( ) => {
278- resolve ( )
279- } )
280- obj . once ( 'error' , reject )
281- } )
282- }
283277
284278// stream.toArray() sometimes returns undefined or [undefined] instead of []
285279async function getArrayFromStream ( stream ) {
@@ -294,6 +288,5 @@ async function getArrayFromStream (stream) {
294288
295289module . exports = {
296290 PromisifiedPersistence,
297- waitForEvent,
298291 getArrayFromStream
299292}
You can’t perform that action at this time.
0 commit comments