This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
promisify: function (web3) { | |
// Pipes values from a Web3 callback. | |
var callbackToResolve = function (resolve, reject) { | |
return function (error, value) { | |
if (error) { | |
reject(error); | |
} else { | |
resolve(value); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Promise = require("bluebird"); | |
/** | |
* @param {!Array.<function.Promise.<Any>>} promiseArray. | |
* @returns {!Promise.<Array.<Any>>} The results of the promises passed to the function. | |
*/ | |
module.exports = function sequentialPromise(promiseArray) { | |
const result = promiseArray.reduce( | |
(reduced, promise, index) => { | |
reduced.results.push(undefined); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Promise = require("bluebird"); | |
/** | |
* @param {!Object.<function.<Promise.<Any>>>} promiseObject. Each key maps to a function | |
* that returns a promise. | |
* @returns {!Promise.<Object.<Any>>} The results of the promises passed to the function. | |
*/ | |
module.exports = function sequentialPromiseNamed(promiseObject) { | |
const result = Object.keys(promiseObject).reduce( | |
(reduced, key) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const Rx = require('rx'); | |
module.exports = function addFilterObservableToWeb3(web3) { | |
web3.eth.filterObservable = function(_options) { | |
const filter = web3.eth.filter(_options); | |
return Rx.Observable.create(function(observer) { |
OlderNewer