Skip to content

Commit eca73aa

Browse files
JacobPlasterJacobPlaster
JacobPlaster
authored andcommitted
standard --fix
1 parent 0e03396 commit eca73aa

File tree

6 files changed

+88
-70
lines changed

6 files changed

+88
-70
lines changed

examples/rest2/positions.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const debug = require('debug')('bfx:examples:rest2_positions')
77
const bfx = require('../bfx')
88
const rest = bfx.rest(2, { transform: true })
99

10-
1110
const PL_ENABLED = process.argv[2] === 'pl'
1211
const tableColWidths = [20, 10, 20, 20, 20]
1312
const tableHeaders = [
@@ -82,5 +81,4 @@ const example = async () => {
8281
// })
8382
}
8483

85-
8684
example().catch(debug)

examples/rest2/submit_funding_offer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const rest = bfx.rest(2, { transform: true })
99

1010
debug('Submitting new order...')
1111

12-
// Build new order
13-
const fo = new FundingOffer({
12+
// Build new order
13+
const fo = new FundingOffer({
1414
type: 'LIMIT',
1515
symbol: 'fUSD',
1616
rate: 0.0120000,
@@ -19,9 +19,9 @@ debug('Submitting new order...')
1919
}, rest)
2020

2121
fo.submit().then((fo) => {
22-
debug("Submitted funding offer", fo.id)
22+
debug('Submitted funding offer', fo.id)
2323
})
24-
.catch((err) => console.log(err))
24+
.catch((err) => console.log(err))
2525

2626
// cancel offer
2727

examples/rest2/submit_order.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ const rest = bfx.rest(2)
99

1010
debug('Submitting new order...')
1111

12-
// Build new order
13-
const o = new Order({
12+
// Build new order
13+
const o = new Order({
1414
cid: Date.now(),
1515
symbol: 'tBTCUSD',
1616
price: 18000,
@@ -25,7 +25,7 @@ o.submit().then(() => {
2525
o.cid, o.id, o.mtsTIF
2626
)
2727
})
28-
.catch((err) => console.log(err))
28+
.catch((err) => console.log(err))
2929

3030
// update order
3131

@@ -37,4 +37,4 @@ setTimeout(() => {
3737

3838
setTimeout(() => {
3939
o.cancel()
40-
},10000)
40+
}, 10000)

examples/rest2/wallet.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ const rest = bfx.rest(2, { transform: true })
88

99
debug('Submitting new order...')
1010

11-
// get new deposit address
12-
rest.getDepositAddress ({
11+
// get new deposit address
12+
rest.getDepositAddress({
1313
wallet: 'exchange',
1414
method: 'bitcoin',
1515
opRenew: 0
16-
})
17-
.then((address) => {
18-
debug(`New wallet address ${address}`)
1916
})
17+
.then((address) => {
18+
debug(`New wallet address ${address}`)
19+
})
2020

2121
// transfer between accounts
2222
rest.transfer({
@@ -26,9 +26,9 @@ rest.transfer({
2626
currency: 'BTC',
2727
currencyTo: 'BTC'
2828
})
29-
.then((res) => {
30-
debug(`transfer confirmed: ${res}`)
31-
})
29+
.then((res) => {
30+
debug(`transfer confirmed: ${res}`)
31+
})
3232

3333
// withdraw
3434
rest.withdraw({
@@ -37,6 +37,6 @@ rest.withdraw({
3737
amount: 2,
3838
address: '1MUz4VMYui5qY1mxUiG8BQ1Luv6tqkvaiL'
3939
})
40-
.then((res) => {
41-
debug(`withdraw confirmed: ${res}`)
42-
})
40+
.then((res) => {
41+
debug(`withdraw confirmed: ${res}`)
42+
})

examples/ws2/candles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ ws.onCandle({ key: CANDLE_KEY }, (candles) => {
2424
if (prevTS === null || candles[0].mts > prevTS) {
2525
const c = candles[1] // report previous candle
2626

27-
debug(`%s %s open: %f, high: %f, low: %f, close: %f, volume: %f`,
27+
debug('%s %s open: %f, high: %f, low: %f, close: %f, volume: %f',
2828
CANDLE_KEY, new Date(c.mts).toLocaleTimeString(),
2929
c.open, c.high, c.low, c.close, c.volume
3030
)

test/lib/transports/ws2-unit.js

Lines changed: 68 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe('WSv2 utilities', () => {
3838
const listener = listenerSet.trade[0]
3939

4040
assert.strictEqual(listener.modelClass, Map)
41-
assert.deepStrictEqual(listener.filter, { '2': 'tBTCUSD' })
41+
assert.deepStrictEqual(listener.filter, { 2: 'tBTCUSD' })
4242
assert.strictEqual(typeof listener.cb, 'function')
4343
})
4444

@@ -349,7 +349,7 @@ describe('WSv2 auto reconnect', () => {
349349

350350
ws.on('open', ws.auth.bind(ws))
351351
ws.once('auth', () => {
352-
let now = Date.now()
352+
const now = Date.now()
353353

354354
ws.reconnectAfterClose = () => {
355355
assert((Date.now() - now) >= 70)
@@ -674,16 +674,16 @@ describe('WSv2 channel msg handling', () => {
674674

675675
const lg = {
676676
'': [{ cb: func }],
677-
'test': [{ cb: func }],
678-
'nope': [{ cb: func }]
677+
test: [{ cb: func }],
678+
nope: [{ cb: func }]
679679
}
680680

681681
WSv2._notifyListenerGroup(lg, [0, 'test', [0, 'tu']], false)
682682
})
683683

684684
it('_notifyListenerGroup: doesn\'t fail on missing data if filtering', (done) => {
685685
const lg = {
686-
'test': [{
686+
test: [{
687687
filter: { 1: 'on' },
688688
cb: () => {
689689
done(new Error('filter should not have matched'))
@@ -726,14 +726,18 @@ describe('WSv2 channel msg handling', () => {
726726
transform: true
727727
})
728728

729-
ws._channelMapA = { 42: {
730-
channel: 'orderbook',
731-
symbol: 'tBTCUSD'
732-
} }
733-
ws._channelMapB = { 43: {
734-
channel: 'orderbook',
735-
symbol: 'fUSD'
736-
} }
729+
ws._channelMapA = {
730+
42: {
731+
channel: 'orderbook',
732+
symbol: 'tBTCUSD'
733+
}
734+
}
735+
ws._channelMapB = {
736+
43: {
737+
channel: 'orderbook',
738+
symbol: 'fUSD'
739+
}
740+
}
737741

738742
ws._handleOBMessage([42, [
739743
[100, 2, -4],
@@ -778,10 +782,12 @@ describe('WSv2 channel msg handling', () => {
778782
transform: true
779783
})
780784

781-
wsNoTransform._channelMap = { 42: {
782-
channel: 'orderbook',
783-
symbol: 'tBTCUSD'
784-
} }
785+
wsNoTransform._channelMap = {
786+
42: {
787+
channel: 'orderbook',
788+
symbol: 'tBTCUSD'
789+
}
790+
}
785791

786792
wsTransform._channelMap = wsNoTransform._channelMap
787793

@@ -801,10 +807,12 @@ describe('WSv2 channel msg handling', () => {
801807

802808
it('_handleOBMessage: forwards managed ob to listeners', (done) => {
803809
const ws = new WSv2({ manageOrderBooks: true })
804-
ws._channelMap = { 42: {
805-
channel: 'orderbook',
806-
symbol: 'tBTCUSD'
807-
} }
810+
ws._channelMap = {
811+
42: {
812+
channel: 'orderbook',
813+
symbol: 'tBTCUSD'
814+
}
815+
}
808816

809817
let seen = 0
810818
ws.onOrderBook({ symbol: 'tBTCUSD' }, (ob) => {
@@ -861,10 +869,12 @@ describe('WSv2 channel msg handling', () => {
861869

862870
it('_handleOBMessage: emits managed ob', (done) => {
863871
const ws = new WSv2({ manageOrderBooks: true })
864-
ws._channelMap = { 42: {
865-
channel: 'orderbook',
866-
symbol: 'tBTCUSD'
867-
} }
872+
ws._channelMap = {
873+
42: {
874+
channel: 'orderbook',
875+
symbol: 'tBTCUSD'
876+
}
877+
}
868878

869879
ws.on('orderbook', (symbol, data) => {
870880
assert.strictEqual(symbol, 'tBTCUSD')
@@ -877,11 +887,13 @@ describe('WSv2 channel msg handling', () => {
877887

878888
it('_handleOBMessage: forwards transformed data if transform enabled', (done) => {
879889
const ws = new WSv2({ transform: true })
880-
ws._channelMap = { 42: {
881-
chanId: 42,
882-
channel: 'orderbook',
883-
symbol: 'tBTCUSD'
884-
} }
890+
ws._channelMap = {
891+
42: {
892+
chanId: 42,
893+
channel: 'orderbook',
894+
symbol: 'tBTCUSD'
895+
}
896+
}
885897

886898
ws.onOrderBook({ symbol: 'tBTCUSD' }, (ob) => {
887899
assert(ob.asks)
@@ -940,10 +952,12 @@ describe('WSv2 channel msg handling', () => {
940952

941953
it('_handleCandleMessage: maintains internal candles if management is enabled', () => {
942954
const ws = new WSv2({ manageCandles: true })
943-
ws._channelMap = { 64: {
944-
channel: 'candles',
945-
key: 'trade:1m:tBTCUSD'
946-
} }
955+
ws._channelMap = {
956+
64: {
957+
channel: 'candles',
958+
key: 'trade:1m:tBTCUSD'
959+
}
960+
}
947961

948962
ws._handleCandleMessage([64, [
949963
[5, 100, 70, 150, 30, 1000],
@@ -1014,11 +1028,13 @@ describe('WSv2 channel msg handling', () => {
10141028

10151029
it('_handleCandleMessage: forwards managed candles to listeners', (done) => {
10161030
const ws = new WSv2({ manageCandles: true })
1017-
ws._channelMap = { 42: {
1018-
chanId: 42,
1019-
channel: 'candles',
1020-
key: 'trade:1m:tBTCUSD'
1021-
} }
1031+
ws._channelMap = {
1032+
42: {
1033+
chanId: 42,
1034+
channel: 'candles',
1035+
key: 'trade:1m:tBTCUSD'
1036+
}
1037+
}
10221038

10231039
let seen = 0
10241040
ws.onCandle({ key: 'trade:1m:tBTCUSD' }, (data) => {
@@ -1039,10 +1055,12 @@ describe('WSv2 channel msg handling', () => {
10391055

10401056
it('_handleCandleMessage: emits managed candles', (done) => {
10411057
const ws = new WSv2({ manageCandles: true })
1042-
ws._channelMap = { 42: {
1043-
channel: 'candles',
1044-
key: 'trade:1m:tBTCUSD'
1045-
} }
1058+
ws._channelMap = {
1059+
42: {
1060+
channel: 'candles',
1061+
key: 'trade:1m:tBTCUSD'
1062+
}
1063+
}
10461064

10471065
ws.on('candle', (data, key) => {
10481066
assert.strictEqual(key, 'trade:1m:tBTCUSD')
@@ -1058,11 +1076,13 @@ describe('WSv2 channel msg handling', () => {
10581076

10591077
it('_handleCandleMessage: forwards transformed data if transform enabled', (done) => {
10601078
const ws = new WSv2({ transform: true })
1061-
ws._channelMap = { 42: {
1062-
chanId: 42,
1063-
channel: 'candles',
1064-
key: 'trade:1m:tBTCUSD'
1065-
} }
1079+
ws._channelMap = {
1080+
42: {
1081+
chanId: 42,
1082+
channel: 'candles',
1083+
key: 'trade:1m:tBTCUSD'
1084+
}
1085+
}
10661086

10671087
ws.onCandle({ key: 'trade:1m:tBTCUSD' }, (candles) => {
10681088
assert.strictEqual(candles.length, 1)

0 commit comments

Comments
 (0)