Skip to content

Commit

Permalink
Merge pull request feross#630 from LinusU/object-shorthand
Browse files Browse the repository at this point in the history
Use object shorthand for properties
  • Loading branch information
t-mullen committed May 3, 2020
2 parents 6cdac1f + 7ccf829 commit b7e4037
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 79 deletions.
26 changes: 13 additions & 13 deletions test/basic.js
Expand Up @@ -43,7 +43,7 @@ test('can detect error when RTCPeerConstructor throws', function (t) {
test('signal event gets emitted', function (t) {
t.plan(2)

var peer = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer = new Peer({ config, initiator: true, wrtc: common.wrtc })
peer.once('signal', function () {
t.pass('got signal event')
peer.on('close', function () { t.pass('peer destroyed') })
Expand All @@ -52,7 +52,7 @@ test('signal event gets emitted', function (t) {
})

test('signal event does not get emitted by non-initiator', function (t) {
var peer = new Peer({ config: config, initiator: false, wrtc: common.wrtc })
var peer = new Peer({ config, initiator: false, wrtc: common.wrtc })
peer.once('signal', function () {
t.fail('got signal event')
peer.on('close', function () { t.pass('peer destroyed') })
Expand All @@ -67,7 +67,7 @@ test('signal event does not get emitted by non-initiator', function (t) {

test('signal event does not get emitted by non-initiator with stream', function (t) {
var peer = new Peer({
config: config,
config,
stream: common.getMediaStream(),
initiator: false,
wrtc: common.wrtc
Expand All @@ -87,8 +87,8 @@ test('signal event does not get emitted by non-initiator with stream', function
test('data send/receive text', function (t) {
t.plan(10)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config: config, wrtc: common.wrtc })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config, wrtc: common.wrtc })

var numSignal1 = 0
peer1.on('signal', function (data) {
Expand Down Expand Up @@ -135,8 +135,8 @@ test('data send/receive text', function (t) {
test('sdpTransform function is called', function (t) {
t.plan(3)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config: config, sdpTransform: sdpTransform, wrtc: common.wrtc })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config, sdpTransform, wrtc: common.wrtc })

function sdpTransform (sdp) {
t.equal(typeof sdp, 'string', 'got a string as SDP')
Expand Down Expand Up @@ -168,8 +168,8 @@ test('old constraint formats are used', function (t) {
}
}

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc, constraints: constraints })
var peer2 = new Peer({ config: config, wrtc: common.wrtc, constraints: constraints })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc, constraints })
var peer2 = new Peer({ config, wrtc: common.wrtc, constraints })

peer1.on('signal', function (data) {
peer2.signal(data)
Expand All @@ -196,8 +196,8 @@ test('new constraint formats are used', function (t) {
offerToReceiveVideo: true
}

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc, constraints: constraints })
var peer2 = new Peer({ config: config, wrtc: common.wrtc, constraints: constraints })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc, constraints })
var peer2 = new Peer({ config, wrtc: common.wrtc, constraints })

peer1.on('signal', function (data) {
peer2.signal(data)
Expand Down Expand Up @@ -230,8 +230,8 @@ test('ensure remote address and port are available right after connection', func

t.plan(7)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config: config, wrtc: common.wrtc })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config, wrtc: common.wrtc })

peer1.on('signal', function (data) {
peer2.signal(data)
Expand Down
12 changes: 6 additions & 6 deletions test/binary.js
Expand Up @@ -14,8 +14,8 @@ test('get config', function (t) {
test('data send/receive Buffer', function (t) {
t.plan(6)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config: config, wrtc: common.wrtc })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config, wrtc: common.wrtc })
peer1.on('signal', function (data) {
peer2.signal(data)
})
Expand Down Expand Up @@ -50,8 +50,8 @@ test('data send/receive Buffer', function (t) {
test('data send/receive Uint8Array', function (t) {
t.plan(6)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config: config, wrtc: common.wrtc })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config, wrtc: common.wrtc })
peer1.on('signal', function (data) {
peer2.signal(data)
})
Expand Down Expand Up @@ -88,8 +88,8 @@ test('data send/receive Uint8Array', function (t) {
test('data send/receive ArrayBuffer', function (t) {
t.plan(6)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config: config, wrtc: common.wrtc })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config, wrtc: common.wrtc })
peer1.on('signal', function (data) {
peer2.signal(data)
})
Expand Down
44 changes: 22 additions & 22 deletions test/multistream.js
Expand Up @@ -20,13 +20,13 @@ test('multistream', function (t) {
t.plan(20)

var peer1 = new Peer({
config: config,
config,
initiator: true,
wrtc: common.wrtc,
streams: (new Array(10)).fill(null).map(function () { return common.getMediaStream() })
})
var peer2 = new Peer({
config: config,
config,
wrtc: common.wrtc,
streams: (new Array(10)).fill(null).map(function () { return common.getMediaStream() })
})
Expand Down Expand Up @@ -63,13 +63,13 @@ test('multistream (track event)', function (t) {
t.plan(20)

var peer1 = new Peer({
config: config,
config,
initiator: true,
wrtc: common.wrtc,
streams: (new Array(5)).fill(null).map(function () { return common.getMediaStream() })
})
var peer2 = new Peer({
config: config,
config,
wrtc: common.wrtc,
streams: (new Array(5)).fill(null).map(function () { return common.getMediaStream() })
})
Expand Down Expand Up @@ -106,13 +106,13 @@ test('multistream on non-initiator only', function (t) {
t.plan(30)

var peer1 = new Peer({
config: config,
config,
initiator: true,
wrtc: common.wrtc,
streams: []
})
var peer2 = new Peer({
config: config,
config,
wrtc: common.wrtc,
streams: (new Array(10)).fill(null).map(function () { return common.getMediaStream() })
})
Expand Down Expand Up @@ -153,14 +153,14 @@ test('delayed stream on non-initiator', function (t) {
t.plan(1)

var peer1 = new Peer({
config: config,
config,
trickle: true,
initiator: true,
wrtc: common.wrtc,
streams: [common.getMediaStream()]
})
var peer2 = new Peer({
config: config,
config,
trickle: true,
wrtc: common.wrtc,
streams: []
Expand Down Expand Up @@ -191,13 +191,13 @@ test('incremental multistream', function (t) {
t.plan(12)

var peer1 = new Peer({
config: config,
config,
initiator: true,
wrtc: common.wrtc,
streams: []
})
var peer2 = new Peer({
config: config,
config,
wrtc: common.wrtc,
streams: []
})
Expand Down Expand Up @@ -254,13 +254,13 @@ test('incremental multistream (track event)', function (t) {
t.plan(22)

var peer1 = new Peer({
config: config,
config,
initiator: true,
wrtc: common.wrtc,
streams: []
})
var peer2 = new Peer({
config: config,
config,
wrtc: common.wrtc,
streams: []
})
Expand Down Expand Up @@ -322,13 +322,13 @@ test('incremental multistream on non-initiator only', function (t) {
t.plan(7)

var peer1 = new Peer({
config: config,
config,
initiator: true,
wrtc: common.wrtc,
streams: []
})
var peer2 = new Peer({
config: config,
config,
wrtc: common.wrtc,
streams: []
})
Expand Down Expand Up @@ -370,13 +370,13 @@ test('incremental multistream on non-initiator only (track event)', function (t)
t.plan(12)

var peer1 = new Peer({
config: config,
config,
initiator: true,
wrtc: common.wrtc,
streams: []
})
var peer2 = new Peer({
config: config,
config,
wrtc: common.wrtc,
streams: []
})
Expand Down Expand Up @@ -425,8 +425,8 @@ test('addStream after removeStream', function (t) {
var stream1 = common.getMediaStream()
var stream2 = common.getMediaStream()

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config: config, wrtc: common.wrtc, streams: [stream1] })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config, wrtc: common.wrtc, streams: [stream1] })

peer1.on('signal', function (data) { if (!peer2.destroyed) peer2.signal(data) })
peer2.on('signal', function (data) { if (!peer1.destroyed) peer1.signal(data) })
Expand All @@ -451,8 +451,8 @@ test('addStream after removeStream', function (t) {
test('removeTrack immediately', function (t) {
t.plan(2)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config: config, wrtc: common.wrtc })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config, wrtc: common.wrtc })

peer1.on('signal', function (data) { if (!peer2.destroyed) peer2.signal(data) })
peer2.on('signal', function (data) { if (!peer1.destroyed) peer1.signal(data) })
Expand Down Expand Up @@ -489,8 +489,8 @@ test('removeTrack immediately', function (t) {
test('replaceTrack', function (t) {
t.plan(4)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config: config, wrtc: common.wrtc })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config, wrtc: common.wrtc })

peer1.on('signal', function (data) { if (!peer2.destroyed) peer2.signal(data) })
peer2.on('signal', function (data) { if (!peer1.destroyed) peer1.signal(data) })
Expand Down
24 changes: 12 additions & 12 deletions test/negotiation.js
Expand Up @@ -14,8 +14,8 @@ test('get config', function (t) {
test('single negotiation', function (t) {
t.plan(10)

var peer1 = new Peer({ config: config, initiator: true, stream: common.getMediaStream(), wrtc: common.wrtc })
var peer2 = new Peer({ config: config, stream: common.getMediaStream(), wrtc: common.wrtc })
var peer1 = new Peer({ config, initiator: true, stream: common.getMediaStream(), wrtc: common.wrtc })
var peer2 = new Peer({ config, stream: common.getMediaStream(), wrtc: common.wrtc })

peer1.on('signal', function (data) { if (!peer2.destroyed) peer2.signal(data) })
peer2.on('signal', function (data) { if (!peer1.destroyed) peer1.signal(data) })
Expand Down Expand Up @@ -55,8 +55,8 @@ test('single negotiation', function (t) {
test('manual renegotiation', function (t) {
t.plan(2)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config: config, wrtc: common.wrtc })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config, wrtc: common.wrtc })

peer1.on('signal', function (data) { if (!peer2.destroyed) peer2.signal(data) })
peer2.on('signal', function (data) { if (!peer1.destroyed) peer1.signal(data) })
Expand All @@ -76,8 +76,8 @@ test('manual renegotiation', function (t) {
test('repeated manual renegotiation', function (t) {
t.plan(6)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config: config, wrtc: common.wrtc })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config, wrtc: common.wrtc })

peer1.on('signal', function (data) { if (!peer2.destroyed) peer2.signal(data) })
peer2.on('signal', function (data) { if (!peer1.destroyed) peer1.signal(data) })
Expand Down Expand Up @@ -117,8 +117,8 @@ test('renegotiation after addStream', function (t) {
}
t.plan(4)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config: config, wrtc: common.wrtc })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc })
var peer2 = new Peer({ config, wrtc: common.wrtc })

peer1.on('signal', function (data) { if (!peer2.destroyed) peer2.signal(data) })
peer2.on('signal', function (data) { if (!peer1.destroyed) peer1.signal(data) })
Expand All @@ -143,12 +143,12 @@ test('add stream on non-initiator only', function (t) {
t.plan(3)

var peer1 = new Peer({
config: config,
config,
initiator: true,
wrtc: common.wrtc
})
var peer2 = new Peer({
config: config,
config,
wrtc: common.wrtc,
stream: common.getMediaStream()
})
Expand All @@ -171,7 +171,7 @@ test('negotiated channels', function (t) {
t.plan(2)

var peer1 = new Peer({
config: config,
config,
initiator: true,
wrtc: common.wrtc,
channelConfig: {
Expand All @@ -180,7 +180,7 @@ test('negotiated channels', function (t) {
}
})
var peer2 = new Peer({
config: config,
config,
wrtc: common.wrtc,
channelConfig: {
id: 1,
Expand Down
16 changes: 8 additions & 8 deletions test/object-mode.js
Expand Up @@ -14,8 +14,8 @@ test('get config', function (t) {
test('data send/receive string {objectMode: true}', function (t) {
t.plan(6)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc, objectMode: true })
var peer2 = new Peer({ config: config, wrtc: common.wrtc, objectMode: true })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc, objectMode: true })
var peer2 = new Peer({ config, wrtc: common.wrtc, objectMode: true })
peer1.on('signal', function (data) {
peer2.signal(data)
})
Expand Down Expand Up @@ -50,8 +50,8 @@ test('data send/receive string {objectMode: true}', function (t) {
test('data send/receive Buffer {objectMode: true}', function (t) {
t.plan(6)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc, objectMode: true })
var peer2 = new Peer({ config: config, wrtc: common.wrtc, objectMode: true })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc, objectMode: true })
var peer2 = new Peer({ config, wrtc: common.wrtc, objectMode: true })
peer1.on('signal', function (data) {
peer2.signal(data)
})
Expand Down Expand Up @@ -86,8 +86,8 @@ test('data send/receive Buffer {objectMode: true}', function (t) {
test('data send/receive Uint8Array {objectMode: true}', function (t) {
t.plan(6)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc, objectMode: true })
var peer2 = new Peer({ config: config, wrtc: common.wrtc, objectMode: true })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc, objectMode: true })
var peer2 = new Peer({ config, wrtc: common.wrtc, objectMode: true })
peer1.on('signal', function (data) {
peer2.signal(data)
})
Expand Down Expand Up @@ -124,8 +124,8 @@ test('data send/receive Uint8Array {objectMode: true}', function (t) {
test('data send/receive ArrayBuffer {objectMode: true}', function (t) {
t.plan(6)

var peer1 = new Peer({ config: config, initiator: true, wrtc: common.wrtc, objectMode: true })
var peer2 = new Peer({ config: config, wrtc: common.wrtc, objectMode: true })
var peer1 = new Peer({ config, initiator: true, wrtc: common.wrtc, objectMode: true })
var peer2 = new Peer({ config, wrtc: common.wrtc, objectMode: true })
peer1.on('signal', function (data) {
peer2.signal(data)
})
Expand Down

0 comments on commit b7e4037

Please sign in to comment.