X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fmodules%2Fstorage.jsm;h=6cc704f0040c477242a61d3ee7705160621a9961;hb=354a049cce8415487552ce405cce167b7071fe1f;hp=0f4cc06e7a83a41c0ca3e89dada9b422948c613e;hpb=8b6fcae7eaa413bc62d645d2d0c99835c47265e6;p=dactyl.git diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm index 0f4cc06..6cc704f 100644 --- a/common/modules/storage.jsm +++ b/common/modules/storage.jsm @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2012 Kris Maglione +// Copyright (c) 2008-2013 Kris Maglione // // 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; @@ -162,7 +162,7 @@ var ObjectStore = Class("ObjectStore", StoreBase, { } }); -var sessionGlobal = Cu.import("resource://gre/modules/Services.jsm", {}) +var sessionGlobal = Cu.import("resource://gre/modules/Services.jsm", {}); var Storage = Module("Storage", { Local: function Local(dactyl, modules, window) ({ @@ -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)), @@ -241,7 +241,6 @@ var Storage = Module("Storage", { }, newObject: function newObject(key, constructor, params) { - let self = this; if (params == null || !isObject(params)) throw Error("Invalid argument type"); @@ -261,10 +260,10 @@ var Storage = Module("Storage", { if (key in this && !reload) throw Error("Cannot add storage key with that name."); - let load = function () self._loadData(key, params.store, params.type || myObject); + let load = () => this._loadData(key, params.store, params.type || myObject); this.keys[key] = new constructor(key, params.store, load, params); - this.keys[key].timer = new Timer(1000, 10000, function () self.save(key)); + this.keys[key].timer = new Timer(1000, 10000, () => this.save(key)); this.__defineGetter__(key, function () this.keys[key]); } return this.keys[key]; @@ -293,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) { @@ -303,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]; }, @@ -428,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. @@ -496,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; }, @@ -694,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 ~ @@ -762,7 +762,6 @@ var File = Class("File", { } }, - isAbsolutePath: function isAbsolutePath(path) { try { services.File().initWithPath(path); @@ -793,7 +792,7 @@ let (file = services.directory.get("ProfD", Ci.nsIFile)) { if (!(prop in File.prototype)) { let isFunction; try { - isFunction = callable(file[prop]) + isFunction = callable(file[prop]); } catch (e) {} @@ -814,4 +813,4 @@ endModule(); // catch(e){ dump(e + "\n" + (e.stack || Error().stack)); Components.utils.reportError(e) } -// vim: set fdm=marker sw=4 sts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: