Comparing version 2.0.2 to 2.0.3
@@ -20,2 +20,5 @@ ;(function() { | ||
var clientLog = require('debug')('help-fem:client'); | ||
var serverLog = require('debug')('help-fem:server'); | ||
// ## HelpFem | ||
@@ -54,17 +57,3 @@ // `HelpFem` is really just a synonym for `module.exports`. | ||
// Toggle debugging | ||
if (options.debug) { | ||
this.debug = true; | ||
} else if (this.inBrowser && window.localStorage.getItem('debug')) { | ||
var deb = window.localStorage.getItem('debug'); | ||
this.debug = deb.indexOf('help-fem') > -1 || deb === '*'; | ||
} else { | ||
this.debug = this.uri.indexOf('localhost') > -1 || this.uri.indexOf('127.0.0.1') > -1; | ||
} | ||
// Toggle expanding the debug messages | ||
this.debugExpand = _.isBoolean(options.debugExpand) ? | ||
options.debugExpand | ||
: true; | ||
// Set the `organizationId` and `namespace`. | ||
@@ -91,7 +80,12 @@ var org = options.organizationId || options.namespace; | ||
/* istanbul ignore next */ | ||
if (this.inBrowser) { | ||
var transports = window.WebSocket && window.WebSocket.CLOSING === 2 | ||
? ['websocket', 'polling'] | ||
: ['polling']; | ||
} else { | ||
var transports = options.transports || ['websocket', 'polling']; | ||
} | ||
// Connect to the FEMIO server and store the socket information. | ||
var transports = window.WebSocket && window.WebSocket.CLOSING === 2 | ||
? ['websocket', 'polling'] | ||
: ['polling']; | ||
this.socket = io(this.uri, { | ||
@@ -221,38 +215,9 @@ transports: transports, | ||
log: function log(event, payload) { | ||
if (!this.debug) { | ||
return; | ||
} | ||
var meta = _.result(payload, 'meta', {}); | ||
var style = ['padding: 0 0.25em', 'color: #fff']; | ||
if (event.indexOf('server') > -1) { | ||
style.push('background: #1abc9c'); | ||
} else if (event.indexOf('client') > -1) { | ||
style.push('background: #3498db'); | ||
serverLog('%s: %o', meta.type, payload); | ||
} else { | ||
style.push('background: #f1c40f'); | ||
clientLog('%s: %o', meta.type, payload); | ||
} | ||
var meta = _.result(payload, 'meta', {}); | ||
// If it's an error or failure, log it as an error. | ||
console[ | ||
event.indexOf('server') > -1 && | ||
meta.type && | ||
meta.type !== 'connection' && | ||
(meta.type === 'error' || meta.result !== 'SUCCESS') ? | ||
'error' | ||
: 'log' | ||
]( | ||
// The event category | ||
['%c', event].join(''), | ||
style.join('; '), | ||
// The type of message | ||
meta.type, | ||
// If we want the message expanded, stringify it. | ||
this.debugExpand ? | ||
JSON.stringify(payload, false, 2) | ||
: payload | ||
); | ||
}, | ||
@@ -259,0 +224,0 @@ |
{ | ||
"name": "help-fem", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "A Browserify/Node.js client module for the Help.com team's FEM.", | ||
@@ -10,3 +10,3 @@ "main": "help-fem.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "tap test/unit/*.js --cov" | ||
}, | ||
@@ -29,6 +29,11 @@ "repository": { | ||
"dependencies": { | ||
"femio-client": "git+ssh://git@github.com/helpdotcom/femio-client.git#v1.0.2", | ||
"debug": "~2.2.0", | ||
"femio-client": "git+ssh://git@github.com/helpdotcom/femio-client.git#v1.0.3", | ||
"underscore": "^1.8.2", | ||
"uuid": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"tap": "~2.2.1", | ||
"ws": "~0.8.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Git dependency
Supply chain riskContains a dependency which resolves to a remote git URL. Dependencies fetched from git URLs are not immutable can be used to inject untrusted code or reduce the likelihood of a reproducible install.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
62254
16
1926
1
4
2
+ Addeddebug@~2.2.0
+ Addeddebug@2.2.0(transitive)
+ Addedms@0.7.1(transitive)
Updatedfemio-client@git+ssh://git@github.com/helpdotcom/femio-client.git#v1.0.3