-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathutil.js
40 lines (32 loc) · 823 Bytes
/
util.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
(function() {
var chrome = require("chrome");
var currentDir = chrome.Cc["@mozilla.org/file/directory_service;1"]
.getService(chrome.Ci.nsIDirectoryServiceProvider)
.getFile("CurWorkD", {}).path;
function shuffle(array) {
return array.sort(function(x, y) {
if (Math.random() > 0.5)
return -1;
else
return 1;
});
}
function unwrapObject(object) {
if (!object)
return object;
try {
if (object.wrappedJSObject) {
return object.wrappedJSObject;
}
} catch (e) {
console.log("Problem w/ unwrapping: " + e.trace);
}
return object;
}
function getCurrentDir() {
return currentDir;
}
exports.shuffle = shuffle;
exports.unwrapObject = unwrapObject;
exports.getCurrentDir = getCurrentDir;
})();