Index: lib/compat.js |
diff --git a/lib/compat.js b/lib/compat.js |
index d544edca8faa300d5ff3833b0470131b43d7b4a6..e7d284072abf118e981771c47d9b4e6a1a7eea7c 100644 |
--- a/lib/compat.js |
+++ b/lib/compat.js |
@@ -33,28 +33,28 @@ require.scopes = Object.create(null); |
function importAll(module, globalObj) |
{ |
- var exports = require(module); |
- for (var key in exports) |
+ let exports = require(module); |
+ for (let key in exports) |
globalObj[key] = exports[key]; |
} |
onShutdown = { |
done: false, |
- add: function() {}, |
- remove: function() {} |
+ add: () => {}, |
+ remove: () => {} |
}; |
// |
// XPCOM emulation |
// |
-var Components = |
+let Components = |
{ |
interfaces: |
{ |
nsIFile: {DIRECTORY_TYPE: 0}, |
- nsIFileURL: function() {}, |
- nsIHttpChannel: function() {}, |
+ nsIFileURL: () => {}, |
+ nsIHttpChannel: () => {}, |
nsITimer: {TYPE_REPEATING_SLACK: 0}, |
nsIInterfaceRequestor: null, |
nsIChannelEventSink: null |
@@ -63,44 +63,35 @@ var Components = |
{ |
"@mozilla.org/timer;1": |
{ |
- createInstance: function() |
- { |
- return new FakeTimer(); |
- } |
+ createInstance: () => new FakeTimer() |
}, |
"@mozilla.org/xmlextras/xmlhttprequest;1": |
{ |
- createInstance: function() |
- { |
- return new XMLHttpRequest(); |
- } |
+ createInstance: () => new XMLHttpRequest() |
} |
}, |
results: {}, |
utils: { |
- import: function() |
+ import: () => |
{ |
}, |
- reportError: function(e) |
+ reportError: e => |
{ |
console.error(e); |
console.trace(); |
} |
}, |
manager: null, |
- ID: function() |
- { |
- return null; |
- } |
+ ID: () => null |
}; |
const Cc = Components.classes; |
const Ci = Components.interfaces; |
const Cr = Components.results; |
const Cu = Components.utils; |
-var XPCOMUtils = |
+let XPCOMUtils = |
{ |
- generateQI: function() {} |
+ generateQI: () => {} |
}; |
// |
@@ -131,30 +122,30 @@ FakeFile.prototype = |
}, |
get parent() |
{ |
- return {create: function() {}}; |
+ return {create: () => {}}; |
}, |
- normalize: function() {} |
+ normalize: () => {} |
}; |
// |
// Services.jsm module emulation |
// |
-var Services = |
+let Services = |
{ |
obs: { |
- addObserver: function() {}, |
- removeObserver: function() {} |
+ addObserver: () => {}, |
+ removeObserver: () => {} |
}, |
vc: { |
- compare: function(v1, v2) |
+ compare: (v1, v2) => |
{ |
function parsePart(s) |
{ |
if (!s) |
return parsePart("0"); |
- var part = { |
+ let part = { |
numA: 0, |
strB: "", |
numC: 0, |
@@ -167,7 +158,7 @@ var Services = |
return part; |
} |
- var matches = s.match(/(\d*)(\D*)(\d*)(.*)/); |
+ let matches = s.match(/(\d*)(\D*)(\d*)(.*)/); |
part.numA = parseInt(matches[1], 10) || part.numA; |
part.strB = matches[2] || part.strB; |
part.numC = parseInt(matches[3], 10) || part.numC; |
@@ -193,9 +184,9 @@ var Services = |
function compareParts(p1, p2) |
{ |
- var result = 0; |
- var elements = ["numA", "strB", "numC", "extraD"]; |
- elements.some(function(element) |
+ let result = 0; |
+ let elements = ["numA", "strB", "numC", "extraD"]; |
+ elements.some(element => |
{ |
result = comparePartElement(p1[element], p2[element]); |
return result; |
@@ -203,11 +194,11 @@ var Services = |
return result; |
} |
- var parts1 = v1.split("."); |
- var parts2 = v2.split("."); |
- for (var i = 0; i < Math.max(parts1.length, parts2.length); i++) |
+ let parts1 = v1.split("."); |
+ let parts2 = v2.split("."); |
+ for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) |
{ |
- var result = compareParts(parsePart(parts1[i]), parsePart(parts2[i])); |
+ let result = compareParts(parsePart(parts1[i]), parsePart(parts2[i])); |
if (result) |
return result; |
} |
@@ -220,7 +211,7 @@ var Services = |
// FileUtils.jsm module emulation |
// |
-var FileUtils = |
+let FileUtils = |
{ |
PERMS_DIRECTORY: 0 |
}; |
@@ -240,18 +231,17 @@ FakeTimer.prototype = |
}, |
scheduleTimeout: function() |
{ |
- var me = this; |
- window.setTimeout(function() |
+ window.setTimeout(() => |
{ |
try |
{ |
- me.callback(); |
+ this.callback(); |
} |
catch(e) |
{ |
Cu.reportError(e); |
} |
- me.scheduleTimeout(); |
+ this.scheduleTimeout(); |
}, this.delay); |
} |
}; |