es2015/Database.js
function runTransaction(transaction, objectStoreNames, transactionOperations) {
  let callbackArguments = objectStoreNames.map((objectStoreName) => {
    return transaction.getObjectStore(objectStoreName)
  })
  callbackArguments.push(() => transaction.abort())
  
  let resultPromise = transactionOperations(...callbackArguments)
  return Promise.resolve(resultPromise).then((result) => {
    return transaction.completionPromise.then(() => result)
  })
}
function runTransaction(transaction, objectStoreNames, transactionOperations) {
  let callbackArguments = objectStoreNames.map((objectStoreName) => {
    return transaction.getObjectStore(objectStoreName)
  })
  callbackArguments.push(() => transaction.abort())
  
  let resultPromise = transactionOperations(...callbackArguments)
  return Promise.resolve(resultPromise).then((result) => {
    return transaction.completionPromise.then(() => result)
  })
}
Runs the provided transaction operations on the specified object stores
obtained from the provided transaction.

The function returns a promise resolved when the transaction completes.

@param {ReadOnlyTransaction} transaction The transaction from which the
object stores will be retrieved. The returned promise will resolve
when this transaction is completed.
@param {string[]} objectStoreNames The names of the object stores to pass to the
{@linkcode transactionOperations} callback.
@param {function(...ReadOnlyObjectStore, function()): PromiseSync<*>} transactionOperations
The callback containing the operations on the object stores in the
transaction.
The callback will receive the requested object stores as arguments,
followed by a callback for aborting the transaction.
The callback should return a synchronous promise (a return value of
one of the data-related methods of object stores and their indexes),
the value to which the returned promise resolves will be the result
value of the promise returned by this function.
@return {Promise<*>} A promise that resolves when the transaction is
completed. The promise will resolve to the value to which resolved
the promise returned by the {@linkcode transactionOperations}
callback.