Skip to content

Commit

Permalink
fix(constructor.name): bug when getting constructor name, appeared in…
Browse files Browse the repository at this point in the history
… Firefox 46
  • Loading branch information
kalitine committed May 24, 2016
1 parent c3d9460 commit 9b4a641
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 7 deletions.
22 changes: 21 additions & 1 deletion dist/netflux.js
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,10 @@
*/
class Interface extends Interface$1 {

constructor () {
super()
}

onMessage (wc, channel, msg) {
let cBuilder = provide(wc.settings.connector, wc.settings)
switch (msg.code) {
Expand Down Expand Up @@ -1389,6 +1393,11 @@
* @extends module:webChannelManager~Interface
*/
class FullyConnectedService extends Interface {

constructor () {
super()
}

add (channel) {
let wc = channel.webChannel
let peerIds = new Set([wc.myId])
Expand Down Expand Up @@ -1452,6 +1461,11 @@
* @extends module:service~Interface
*/
class Interface$2 extends Interface$1 {

constructor () {
super()
}

/**
* Enables other clients to establish a connection with you.
*
Expand Down Expand Up @@ -1922,6 +1936,11 @@
const buffers = new Map()

class MessageBuilderService extends Interface$1 {

constructor () {
super()
}

handleUserMessage (data, senderId, recipientId, action) {
let workingData = this.userDataToType(data)
let dataUint8Array = workingData.content
Expand Down Expand Up @@ -2172,7 +2191,7 @@
* @param {Object} [options] - Any options that the service accepts.
* @return {module:service~Interface} - Service instance.
*/
function provide (name, options = {}) {
let provide = function (name, options = {}) {
if (services.has(name)) {
return services.get(name)
}
Expand Down Expand Up @@ -2537,6 +2556,7 @@
join (key, options = {}) {
let settings = Object.assign({}, this.settings, options)

console.log('CONNECTOR webchannel: ' + this.settings.connector + ' --- ' + settings.connector)
let cBuilder = provide(settings.connector, settings)
return new Promise((resolve, reject) => {
this.onJoin = () => resolve(this)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
},
"devDependencies": {
"babel-core": "^6.3.17",
"babel-eslint": "^6.0.4",
"babel-loader": "^6.2.1",
"babel-polyfill": "^6.3.14",
"babel-preset-es2015": "^6.3.13",
Expand Down
1 change: 1 addition & 0 deletions src/WebChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ class WebChannel {
join (key, options = {}) {
let settings = Object.assign({}, this.settings, options)

console.log('CONNECTOR webchannel: ' + this.settings.connector + ' --- ' + settings.connector)
let cBuilder = provide(settings.connector, settings)
return new Promise((resolve, reject) => {
this.onJoin = () => resolve(this)
Expand Down
5 changes: 5 additions & 0 deletions src/service/MessageBuilderService.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ const DATA_VIEW_TYPE = 12
const buffers = new Map()

class MessageBuilderService extends service.Interface {

constructor () {
super()
}

handleUserMessage (data, senderId, recipientId, action) {
let workingData = this.userDataToType(data)
let dataUint8Array = workingData.content
Expand Down
5 changes: 5 additions & 0 deletions src/service/channelBuilder/channelBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ import * as service from '../service'
* @extends module:service~Interface
*/
class Interface extends service.Interface {

constructor () {
super()
}

/**
* Enables other clients to establish a connection with you.
*
Expand Down
5 changes: 5 additions & 0 deletions src/service/webChannelManager/FullyConnectedService.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import * as wcManager from './webChannelManager'
* @extends module:webChannelManager~Interface
*/
class FullyConnectedService extends wcManager.Interface {

constructor () {
super()
}

add (channel) {
let wc = channel.webChannel
let peerIds = new Set([wc.myId])
Expand Down
4 changes: 4 additions & 0 deletions src/service/webChannelManager/webChannelManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const CONNECT_WITH_TIMEOUT = 5000
*/
class Interface extends service.Interface {

constructor () {
super()
}

onMessage (wc, channel, msg) {
let cBuilder = provide(wc.settings.connector, wc.settings)
switch (msg.code) {
Expand Down
2 changes: 1 addition & 1 deletion src/serviceProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const services = new Map()
* @param {Object} [options] - Any options that the service accepts.
* @return {module:service~Interface} - Service instance.
*/
function provide (name, options = {}) {
let provide = function (name, options = {}) {
if (services.has(name)) {
return services.get(name)
}
Expand Down
8 changes: 4 additions & 4 deletions test/functional/fullyConnected/2peers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ describe('2 peers -> ', () => {
wc2.onLeaving = (id) => {
expect(id).toBe(wc1.myId)
wc1.send(message)
wc1.sendTo(message)
wc1.sendTo(wc2.myId, message)
done()
}

wc1.openForJoining().then((data) => {
wc2.join(data.key).catch(done.fail)
}).catch(done.fail)
wc2.send(message)
wc2.sendTo(message)
wc2.sendTo(wc1.myId, message)
})

it('guest is leaving', (done) => {
Expand All @@ -102,7 +102,7 @@ describe('2 peers -> ', () => {
wc1.onLeaving = (id) => {
expect(id).toBe(wc2.myId)
wc1.send(message)
wc1.sendTo(message)
wc1.sendTo(wc2.myId, message)
done()
}
let wc2 = new WebChannel({signaling})
Expand All @@ -114,7 +114,7 @@ describe('2 peers -> ', () => {
.catch(done.fail)
}).catch(done.fail)
wc2.send(message)
wc2.sendTo(message)
wc2.sendTo(wc1.myId, message)
})
})
})
3 changes: 2 additions & 1 deletion test/service/service.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as service from '../../src/service/service'

it('Service name should be its constructor name', () => {
class MyService extends service.Interface {}
class MyService extends service.Interface { constructor () { super() }}
let obj = new MyService()
console.log()
expect(obj.name).toEqual('MyService')
})

0 comments on commit 9b4a641

Please sign in to comment.