panic-client
Advanced tools
Comparing version 0.1.2 to 0.2.0
# Changelog | ||
## v0.2.0 | ||
Breaking changes: | ||
- The `done` callback is now the 1st parameter passed to peers instead of the second. | ||
- Variable injection no longer happens by default, and the flag has changed to `'@scope'`. | ||
Improvement: a number of things have changed to allow for IE6 compatibility (polyfill of arguments, function.length, and a function expression fix in `eval`). | ||
## v0.1.2 | ||
@@ -10,2 +17,2 @@ Bug fix: previous version build not updated. | ||
## v0.1.0 | ||
Initial minior release. | ||
Initial minor release. |
{ | ||
"name": "panic-client", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "Test client for panic-server", | ||
"main": "src/index.js", | ||
"dependencies": { | ||
"phantomjs-polyfill": "0.0.2", | ||
"platform": "^1.3.1", | ||
@@ -8,0 +9,0 @@ "socket.io-client": "^1.4.5" |
@@ -6,2 +6,5 @@ /*eslint "no-eval": "off", "id-length": "off"*/ | ||
// Function.prototype.bind | ||
require('phantomjs-polyfill'); | ||
Error.prototype.toJSON = function () { | ||
@@ -15,2 +18,16 @@ return { | ||
/* | ||
Sadly, since IE6 doesn't support | ||
Function.prototype.length (or getters), | ||
this is a simple "polyfill". | ||
*/ | ||
function params (raw) { | ||
var parens = raw.match(/\((.*?)\)/); | ||
var args = parens && parens[1]; | ||
if (args && args.length) { | ||
return args.split(',').length; | ||
} | ||
return 0; | ||
} | ||
function Job(raw, id, scope) { | ||
@@ -27,6 +44,6 @@ if (!(this instanceof Job)) { | ||
var cb; | ||
if ((scope || {})['export vars'] === false) { | ||
if (this.data['@scope'] === true) { | ||
cb = parse(raw, this.data); | ||
} else { | ||
cb = parse(raw, {}); | ||
} else { | ||
cb = parse(raw, this.data); | ||
} | ||
@@ -38,6 +55,6 @@ | ||
try { | ||
if (cb.length > 1) { | ||
cb.call(this, this, this.done); | ||
if (params(raw) > 0) { | ||
cb.call(this, this.done); | ||
} else { | ||
cb.call(this, this); | ||
cb.call(this); | ||
this.done(); | ||
@@ -44,0 +61,0 @@ } |
@@ -1,2 +0,2 @@ | ||
/*eslint "strict": "off", "no-with": "off", "no-eval": "off"*/ | ||
/*eslint-disable*/ | ||
@@ -17,6 +17,10 @@ /* | ||
// polyfill `arguments` for IE6 | ||
module.exports = function () { | ||
var arguments = module.exports.arguments || arguments; | ||
var PANIC_CB_FUNCTION; | ||
with (arguments[1] || {}) { | ||
return eval('(' + arguments[0] + ')'); | ||
eval('PANIC_CB_FUNCTION = ' + arguments[0]); | ||
return PANIC_CB_FUNCTION; | ||
} | ||
}; |
@@ -33,3 +33,3 @@ /*globals describe, it, beforeEach*/ | ||
it('should allow you to turn off local variables', function () { | ||
it('should not export local variables by default', function () { | ||
panic.connection.on(key, function (err) { | ||
@@ -42,5 +42,18 @@ expect(err).not.to.be.an.instanceof(Error); | ||
} | ||
}, key, { | ||
}.toString(), key, { | ||
scope: '"scope"' | ||
}); | ||
}); | ||
it('should allow you to export vars', function () { | ||
panic.connection.on(key, function (err) { | ||
expect(err).not.to.be.an.instanceof(Error); | ||
}); | ||
new Job(function () { | ||
if (typeof scope === 'undefined') { | ||
throw new Error('The scope variable should be defined'); | ||
} | ||
}.toString(), key, { | ||
scope: '"scope"', | ||
'export vars': false | ||
'@scope': true | ||
}); | ||
@@ -53,3 +66,3 @@ }); | ||
this.data.matches.platform = this.platform; | ||
}, key, { | ||
}.toString(), key, { | ||
matches: matches | ||
@@ -59,2 +72,23 @@ }); | ||
}); | ||
it('should allow async execution', function (done) { | ||
panic.connection.on(key, function (err) { | ||
expect(err).not.to.be.an.instanceof(Error); | ||
}); | ||
var obj = {}; | ||
new Job(function (done) { | ||
setTimeout(function () { | ||
obj.async = true; | ||
done(); | ||
}, 10); | ||
}.toString(), key, { | ||
obj: obj, | ||
'@scope': true | ||
}); | ||
expect(obj.async).to.eq(undefined); | ||
setTimeout(function () { | ||
expect(obj.async).to.eq(true); | ||
done(); | ||
}, 20); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
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
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
254456
8116
3
+ Addedphantomjs-polyfill@0.0.2
+ Addedphantomjs-polyfill@0.0.2(transitive)