Q:

Can't process Firebase acquired values with async and Foreach

I want to process the value obtained by Firebase with Forach.
To processed in order, async, await was used.
const sleep = time => new Promise(resolve => setTimeout(resolve, time));
 async function () {
   var snapshot = await firebase.database().ref("/path/").once("value")
   snapshot.forEach(async function (childSnapshot) {
       await sleep(1000)
       console.log(snapshot.val)
   })
 }

However, as a result only the first item of the first is processed. 
That is, Foreach is not working.
Foreach will work if you remove async, await.
How can we make them compatible?

A:

You won't be able to use forEach, since it requires that you pass a function, and it won't use the promise returned by it (which is always what an async function returns).  Instead, convert the database child nodes into an array and iterate it with for/of:
async function () {
  const snapshot = await firebase.database().ref("/path/").once("value")
  const array = []
  snapshot.forEach(child => array.push(child))
  for (const child of array) {
     await sleep(1000)
     console.log(snapshot.val)
  }
}

Also note that the snapshot returned by Firebase isn't an array and can't be iterated with for/of directly.  Its forEach method is its own special child node iterator.

