Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
style: eslint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed May 3, 2016
1 parent 11a17d9 commit 67034d5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ const loadCommands = require('./load-commands')
const getConfig = require('./config')
const getRequestAPI = require('./request-api')

function IpfsAPI (host_or_multiaddr, port, opts) {
function IpfsAPI (hostOrMultiaddr, port, opts) {
const config = getConfig()

try {
const maddr = multiaddr(host_or_multiaddr).nodeAddress()
const maddr = multiaddr(hostOrMultiaddr).nodeAddress()
config.host = maddr.address
config.port = maddr.port
} catch (e) {
if (typeof host_or_multiaddr === 'string') {
config.host = host_or_multiaddr
if (typeof hostOrMultiaddr === 'string') {
config.host = hostOrMultiaddr
config.port = port && typeof port !== 'object' ? port : config.port
}
}
Expand Down
24 changes: 12 additions & 12 deletions test/api/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ describe('.config', () => {
const confKey = 'arbitraryKey'
const confVal = 'arbitraryVal'

apiClients['a'].config.set(confKey, confVal, (err, res) => {
apiClients.a.config.set(confKey, confVal, (err, res) => {
expect(err).to.not.exist
apiClients['a'].config.get(confKey, (err, res) => {
apiClients.a.config.get(confKey, (err, res) => {
expect(err).to.not.exist
expect(res).to.have.a.property('Value', confVal)
done()
Expand All @@ -26,9 +26,9 @@ describe('.config', () => {
const confKey = 'otherKey'
const confVal = true

apiClients['a'].config.set(confKey, confVal, (err, res) => {
apiClients.a.config.set(confKey, confVal, (err, res) => {
expect(err).to.not.exist
apiClients['a'].config.get(confKey, (err, res) => {
apiClients.a.config.get(confKey, (err, res) => {
expect(err).to.not.exist
expect(res.Value).to.deep.equal(confVal)
done()
Expand All @@ -40,9 +40,9 @@ describe('.config', () => {
const confKey = 'API.HTTPHeaders.Access-Control-Allow-Origin'
const confVal = ['http://example.io']

apiClients['a'].config.set(confKey, confVal, (err, res) => {
apiClients.a.config.set(confKey, confVal, (err, res) => {
expect(err).to.not.exist
apiClients['a'].config.get(confKey, (err, res) => {
apiClients.a.config.get(confKey, (err, res) => {
expect(err).to.not.exist
expect(res.Value).to.deep.equal(confVal)
done()
Expand Down Expand Up @@ -77,9 +77,9 @@ describe('.config', () => {
const confKey = 'arbitraryKey'
const confVal = 'arbitraryVal'

return apiClients['a'].config.set(confKey, confVal)
return apiClients.a.config.set(confKey, confVal)
.then((res) => {
return apiClients['a'].config.get(confKey)
return apiClients.a.config.get(confKey)
})
.then((res) => {
expect(res).to.have.a.property('Value', confVal)
Expand All @@ -90,9 +90,9 @@ describe('.config', () => {
const confKey = 'otherKey'
const confVal = true

return apiClients['a'].config.set(confKey, confVal)
return apiClients.a.config.set(confKey, confVal)
.then((res) => {
return apiClients['a'].config.get(confKey)
return apiClients.a.config.get(confKey)
})
.then((res) => {
expect(res.Value).to.deep.equal(confVal)
Expand All @@ -103,9 +103,9 @@ describe('.config', () => {
const confKey = 'API.HTTPHeaders.Access-Control-Allow-Origin'
const confVal = ['http://example.com']

return apiClients['a'].config.set(confKey, confVal)
return apiClients.a.config.set(confKey, confVal)
.then((res) => {
return apiClients['a'].config.get(confKey)
return apiClients.a.config.get(confKey)
})
.then((res) => {
expect(res.Value).to.deep.equal(confVal)
Expand Down
8 changes: 4 additions & 4 deletions test/api/swarm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('.swarm', () => {
})

it('.swarm.addrs', (done) => {
apiClients['a'].swarm.addrs((err, res) => {
apiClients.a.swarm.addrs((err, res) => {
expect(err).to.not.exist

expect(Object.keys(res.Addrs)).to.have.length.above(1)
Expand All @@ -34,7 +34,7 @@ describe('.swarm', () => {
})

it('.swarm.localAddrs', (done) => {
apiClients['a'].swarm.localAddrs((err, res) => {
apiClients.a.swarm.localAddrs((err, res) => {
expect(err).to.not.exist

expect(res.Strings).to.have.length.above(1)
Expand All @@ -51,14 +51,14 @@ describe('.swarm', () => {
})

it('.swarm.addrs', () => {
return apiClients['a'].swarm.addrs()
return apiClients.a.swarm.addrs()
.then((res) => {
expect(Object.keys(res.Addrs)).to.have.length.above(1)
})
})

it('.swarm.localAddrs', () => {
return apiClients['a'].swarm.localAddrs()
return apiClients.a.swarm.localAddrs()
.then((res) => {
expect(res.Strings).to.have.length.above(1)
})
Expand Down

0 comments on commit 67034d5

Please sign in to comment.