]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/modules/storage.jsm
Import r6976 from upstream hg supporting Firefox up to 25.*
[dactyl.git] / common / modules / storage.jsm
index f37524d843e79186c40ad36c5e02627b775f2276..6cc704f0040c477242a61d3ee7705160621a9961 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail>
+// Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
 //
 // This work is licensed for reuse under an MIT license. Details are
 // given in the LICENSE.txt file included with this file.
@@ -27,8 +27,8 @@ var StoreBase = Class("StoreBase", {
         this._load = load;
         this._options = options;
 
-        this.__defineGetter__("store", function () store);
-        this.__defineGetter__("name", function () name);
+        this.__defineGetter__("store", () => store);
+        this.__defineGetter__("name", () => name);
         for (let [k, v] in Iterator(options))
             if (this.OPTIONS.indexOf(k) >= 0)
                 this[k] = v;
@@ -224,7 +224,7 @@ var Storage = Module("Storage", {
             delete this.dactylSession[key];
     },
 
-    infoPath: Class.Memoize(function ()
+    infoPath: Class.Memoize(() =>
         File(IO.runtimePath.replace(/,.*/, ""))
             .child("info").child(config.profileName)),
 
@@ -292,8 +292,9 @@ var Storage = Module("Storage", {
         if (!(key in this.observers))
             this.observers[key] = [];
 
-        if (!this.observers[key].some(function (o) o.callback.get() == callback))
-            this.observers[key].push({ ref: ref && Cu.getWeakReference(ref), callback: callbackRef });
+        if (!this.observers[key].some(o => o.callback.get() == callback))
+            this.observers[key].push({ ref: ref && Cu.getWeakReference(ref),
+                                       callback: callbackRef });
     },
 
     removeObserver: function (key, callback) {
@@ -302,7 +303,7 @@ var Storage = Module("Storage", {
         if (!(key in this.observers))
             return;
 
-        this.observers[key] = this.observers[key].filter(function (elem) elem.callback.get() != callback);
+        this.observers[key] = this.observers[key].filter(elem => elem.callback.get() != callback);
         if (this.observers[key].length == 0)
             delete obsevers[key];
     },
@@ -427,7 +428,7 @@ var File = Class("File", {
         return this;
     },
 
-    charset: Class.Memoize(function () File.defaultEncoding),
+    charset: Class.Memoize(() => File.defaultEncoding),
 
     /**
      * @property {nsIFileURL} Returns the nsIFileURL object for this file.
@@ -495,7 +496,8 @@ var File = Class("File", {
 
         let array = [e for (e in this.iterDirectory())];
         if (sort)
-            array.sort(function (a, b) b.isDirectory() - a.isDirectory() || String.localeCompare(a.path, b.path));
+            array.sort((a, b) => (b.isDirectory() - a.isDirectory() ||
+                                  String.localeCompare(a.path, b.path)));
         return array;
     },
 
@@ -693,10 +695,9 @@ var File = Class("File", {
         // Kris reckons we shouldn't replicate this 'bug'. --djk
         // TODO: should we be doing this for all paths?
         function expand(path) path.replace(
-            !win32 ? /\$(\w+)\b|\${(\w+)}/g
-                   : /\$(\w+)\b|\${(\w+)}|%(\w+)%/g,
-            function (m, n1, n2, n3) getenv(n1 || n2 || n3) || m
-        );
+            win32 ? /\$(\w+)\b|\${(\w+)}|%(\w+)%/g
+                  : /\$(\w+)\b|\${(\w+)}/g,
+            (m, n1, n2, n3) => (getenv(n1 || n2 || n3) || m));
         path = expand(path);
 
         // expand ~