-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #741 from wilsonianb/fix-lint-errors
Fix eslint errors
- Loading branch information
Showing
70 changed files
with
1,358 additions
and
1,358 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,70 @@ | ||
'use strict'; | ||
const _ = require('lodash'); | ||
const RippleAPI = require('./api').RippleAPI; | ||
'use strict' // eslint-disable-line strict | ||
const _ = require('lodash') | ||
const RippleAPI = require('./api').RippleAPI | ||
|
||
class RippleAPIBroadcast extends RippleAPI { | ||
constructor(servers, options) { | ||
super(options); | ||
this.ledgerVersion = 0; | ||
super(options) | ||
this.ledgerVersion = 0 | ||
|
||
const apis = servers.map(server => new RippleAPI( | ||
_.assign({}, options, {server}) | ||
)); | ||
)) | ||
|
||
// exposed for testing | ||
this._apis = apis; | ||
this._apis = apis | ||
|
||
this.getMethodNames().forEach(name => { | ||
this[name] = function() { // eslint-disable-line no-loop-func | ||
return Promise.race(apis.map(api => api[name].apply(api, arguments))); | ||
}; | ||
}); | ||
return Promise.race(apis.map(api => api[name](...arguments))) | ||
} | ||
}) | ||
|
||
// connection methods must be overridden to apply to all api instances | ||
this.connect = function() { | ||
return Promise.all(apis.map(api => api.connect())); | ||
}; | ||
return Promise.all(apis.map(api => api.connect())) | ||
} | ||
this.disconnect = function() { | ||
return Promise.all(apis.map(api => api.disconnect())); | ||
}; | ||
return Promise.all(apis.map(api => api.disconnect())) | ||
} | ||
this.isConnected = function() { | ||
return _.every(apis.map(api => api.isConnected())); | ||
}; | ||
return _.every(apis.map(api => api.isConnected())) | ||
} | ||
|
||
// synchronous methods are all passed directly to the first api instance | ||
const defaultAPI = apis[0]; | ||
const syncMethods = ['sign', 'generateAddress', 'computeLedgerHash']; | ||
const defaultAPI = apis[0] | ||
const syncMethods = ['sign', 'generateAddress', 'computeLedgerHash'] | ||
syncMethods.forEach(name => { | ||
this[name] = defaultAPI[name].bind(defaultAPI); | ||
}); | ||
this[name] = defaultAPI[name].bind(defaultAPI) | ||
}) | ||
|
||
apis.forEach(api => { | ||
api.on('ledger', this.onLedgerEvent.bind(this)); | ||
api.on('ledger', this.onLedgerEvent.bind(this)) | ||
api.on('error', (errorCode, errorMessage, data) => | ||
this.emit('error', errorCode, errorMessage, data)); | ||
}); | ||
this.emit('error', errorCode, errorMessage, data)) | ||
}) | ||
} | ||
|
||
onLedgerEvent(ledger) { | ||
if (ledger.ledgerVersion > this.ledgerVersion) { | ||
this.ledgerVersion = ledger.ledgerVersion; | ||
this.emit('ledger', ledger); | ||
this.ledgerVersion = ledger.ledgerVersion | ||
this.emit('ledger', ledger) | ||
} | ||
} | ||
|
||
getMethodNames() { | ||
const methodNames = []; | ||
const methodNames = [] | ||
for (const name in RippleAPI.prototype) { | ||
if (RippleAPI.prototype.hasOwnProperty(name)) { | ||
if (typeof RippleAPI.prototype[name] === 'function') { | ||
methodNames.push(name); | ||
methodNames.push(name) | ||
} | ||
} | ||
} | ||
return methodNames; | ||
return methodNames | ||
} | ||
} | ||
|
||
module.exports = { | ||
RippleAPIBroadcast | ||
}; | ||
} |
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
Oops, something went wrong.