diff options
author | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-04-21 05:10:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-21 05:10:05 +0800 |
commit | 74c419f9b65841c2966d1fe3b7414bf11e09e0d8 (patch) | |
tree | b685af5f2383a6d1159ed339e29b831f094aa079 /app/scripts/lib | |
parent | 00efcf9e8ba34d448b628c98d32ad12d5be2ffc9 (diff) | |
parent | 8636f3bae547ace7d099a3ed516bf013dfe3858e (diff) | |
download | tangerine-wallet-browser-74c419f9b65841c2966d1fe3b7414bf11e09e0d8.tar tangerine-wallet-browser-74c419f9b65841c2966d1fe3b7414bf11e09e0d8.tar.gz tangerine-wallet-browser-74c419f9b65841c2966d1fe3b7414bf11e09e0d8.tar.bz2 tangerine-wallet-browser-74c419f9b65841c2966d1fe3b7414bf11e09e0d8.tar.lz tangerine-wallet-browser-74c419f9b65841c2966d1fe3b7414bf11e09e0d8.tar.xz tangerine-wallet-browser-74c419f9b65841c2966d1fe3b7414bf11e09e0d8.tar.zst tangerine-wallet-browser-74c419f9b65841c2966d1fe3b7414bf11e09e0d8.zip |
Merge pull request #4020 from MetaMask/i3941-jsdoc-bitpshr
Documentation
Diffstat (limited to 'app/scripts/lib')
-rw-r--r-- | app/scripts/lib/createProviderMiddleware.js | 6 | ||||
-rw-r--r-- | app/scripts/lib/port-stream.js | 37 | ||||
-rw-r--r-- | app/scripts/lib/setupMetamaskMeshMetrics.js | 3 |
3 files changed, 41 insertions, 5 deletions
diff --git a/app/scripts/lib/createProviderMiddleware.js b/app/scripts/lib/createProviderMiddleware.js index 4e667bac2..8a939ba4e 100644 --- a/app/scripts/lib/createProviderMiddleware.js +++ b/app/scripts/lib/createProviderMiddleware.js @@ -1,6 +1,10 @@ module.exports = createProviderMiddleware -// forward requests to provider +/** + * Forwards an HTTP request to the current Web3 provider + * + * @param {{ provider: Object }} config Configuration containing current Web3 provider + */ function createProviderMiddleware ({ provider }) { return (req, res, next, end) => { provider.sendAsync(req, (err, _res) => { diff --git a/app/scripts/lib/port-stream.js b/app/scripts/lib/port-stream.js index a9716fb00..5c4224fd9 100644 --- a/app/scripts/lib/port-stream.js +++ b/app/scripts/lib/port-stream.js @@ -6,6 +6,13 @@ module.exports = PortDuplexStream inherits(PortDuplexStream, Duplex) +/** + * Creates a stream that's both readable and writable. + * The stream supports arbitrary objects. + * + * @class + * @param {Object} port Remote Port object + */ function PortDuplexStream (port) { Duplex.call(this, { objectMode: true, @@ -15,8 +22,13 @@ function PortDuplexStream (port) { port.onDisconnect.addListener(this._onDisconnect.bind(this)) } -// private - +/** + * Callback triggered when a message is received from + * the remote Port associated with this Stream. + * + * @private + * @param {Object} msg - Payload from the onMessage listener of Port + */ PortDuplexStream.prototype._onMessage = function (msg) { if (Buffer.isBuffer(msg)) { delete msg._isBuffer @@ -27,14 +39,31 @@ PortDuplexStream.prototype._onMessage = function (msg) { } } +/** + * Callback triggered when the remote Port + * associated with this Stream disconnects. + * + * @private + */ PortDuplexStream.prototype._onDisconnect = function () { this.destroy() } -// stream plumbing - +/** + * Explicitly sets read operations to a no-op + */ PortDuplexStream.prototype._read = noop + +/** + * Called internally when data should be written to + * this writable stream. + * + * @private + * @param {*} msg Arbitrary object to write + * @param {string} encoding Encoding to use when writing payload + * @param {Function} cb Called when writing is complete or an error occurs + */ PortDuplexStream.prototype._write = function (msg, encoding, cb) { try { if (Buffer.isBuffer(msg)) { diff --git a/app/scripts/lib/setupMetamaskMeshMetrics.js b/app/scripts/lib/setupMetamaskMeshMetrics.js index 40343f017..02690a948 100644 --- a/app/scripts/lib/setupMetamaskMeshMetrics.js +++ b/app/scripts/lib/setupMetamaskMeshMetrics.js @@ -1,6 +1,9 @@ module.exports = setupMetamaskMeshMetrics +/** + * Injects an iframe into the current document for testing + */ function setupMetamaskMeshMetrics() { const testingContainer = document.createElement('iframe') testingContainer.src = 'https://metamask.github.io/mesh-testing/' |