if( -> if ( and for( -> for (
authorMichiel de Jong <michiel@unhosted.org>
Tue, 31 Dec 2013 09:48:07 +0000 (09:48 +0000)
committerMichiel de Jong <michiel@unhosted.org>
Tue, 31 Dec 2013 09:48:07 +0000 (09:48 +0000)
32 files changed:
src/access.js
src/baseclient.js
src/baseclient/types.js
src/caching.js
src/cachinglayer.js
src/debug/inspect.js
src/dropbox.js
src/env.js
src/eventhandling.js
src/googledrive.js
src/indexeddb.js
src/inmemorystorage.js
src/legacy.js
src/localstorage.js
src/remotestorage.js
src/sync.js
src/widget.js
src/wireclient.js
test/conformance.js
test/unit/authorize-suite.js
test/unit/baseclient-suite.js
test/unit/baseclient/types-suite.js
test/unit/discover-suite.js
test/unit/dropbox-suite.js
test/unit/googledrive-suite.js
test/unit/indexeddb-suite.js
test/unit/inmemorycaching-suite.js
test/unit/localstorage-suite.js
test/unit/node-wireclient-suite.js
test/unit/remotestorage-suite.js
test/unit/sync-suite.js
test/unit/wireclient-suite.js

index c0698df..6dd2252 100644 (file)
     remove: function(scope) {
       var savedMap = {};
       var name;
-      for(name in this.scopeModeMap) {
+      for (name in this.scopeModeMap) {
         savedMap[name] = this.scopeModeMap[name];
       }
       this.reset();
       delete savedMap[scope];
-      for(name in savedMap) {
+      for (name in savedMap) {
         this.set(name, savedMap[name]);
       }
     },
@@ -60,9 +60,9 @@
     },
 
     _adjustRootPaths: function(newScope) {
-      if('*' in this.scopeModeMap || newScope === '*') {
+      if ('*' in this.scopeModeMap || newScope === '*') {
         this.rootPaths = ['/'];
-      } else if(! (newScope in this.scopeModeMap)) {
+      } else if (! (newScope in this.scopeModeMap)) {
         this.rootPaths.push('/' + newScope + '/');
         this.rootPaths.push('/public/' + newScope + '/');
       }
 
   // documented in src/remotestorage.js
   RemoteStorage.prototype.claimAccess = function(scopes) {
-    if(typeof(scopes) === 'object') {
-      for(var key in scopes) {
+    if (typeof(scopes) === 'object') {
+      for (var key in scopes) {
         this.access.claim(key, scopes[key]);
       }
     } else {
index 75f61d9..bf2f61c 100644 (file)
     // END LEGACY
 
     extend: function(object) {
-      for(var key in object) {
+      for (var key in object) {
         this[key] = object[key];
       }
       return this;
      * Example:
      *   (start code)
      *   client.getAll('').then(function(objects) {
-     *     for(var key in objects) {
+     *     for (var key in objects) {
      *       console.log('- ' + key + ': ', objects[key]);
      *     }
      *   });
             // has changes that haven't been pushed out yet.
             return;
           }
-          for(var key in body) {
+          for (var key in body) {
             this.storage.get(this.makePath(path + key)).
               then(function(status, b) {
                 body[this.key] = b;
index 9a4d42d..3b8039f 100644 (file)
       if (schema.extends) {
         var extendedAlias;
         var parts = schema.extends.split('/');
-        if(parts.length === 1) {
+        if (parts.length === 1) {
           extendedAlias = moduleName + '/' + parts.shift();
         } else {
           extendedAlias = parts.join('/');
         }
         var extendedUri = this.uris[extendedAlias];
-        if(! extendedUri) {
+        if (! extendedUri) {
           throw "Type '" + fullAlias + "' tries to extend unknown schema '" + extendedAlias + "'";
         }
         schema.extends = this.schemas[extendedUri];
@@ -42,7 +42,7 @@
     inScope: function(moduleName) {
       var ml = moduleName.length;
       var schemas = {};
-      for(var alias in this.uris) {
+      for (var alias in this.uris) {
         if (alias.substr(0, ml + 1) === moduleName + '/') {
           var uri = this.uris[alias];
           schemas[uri] = this.schemas[uri];
@@ -76,7 +76,7 @@
      **/
     validate: function(object) {
       var schema = RemoteStorage.BaseClient.Types.getSchema(object['@context']);
-      if(schema) {
+      if (schema) {
         return tv4.validateResult(object, schema);
       } else {
         throw new SchemaNotFound(object['@context']);
@@ -87,7 +87,7 @@
     //  /* OR */
     // client.declareType(alias, uri, schema);
     declareType: function(alias, uri, schema) {
-      if(! schema) {
+      if (! schema) {
         schema = uri;
         uri = this._defaultTypeURI(alias);
       }
index 33d2934..4c2021a 100644 (file)
@@ -3,10 +3,10 @@
   var SETTINGS_KEY = "remotestorage:caching";
 
   function containingDir(path) {
-    if(path === '') {
+    if (path === '') {
       return '/';
     }
-    if(! path) {
+    if (! path) {
       throw "Path not given!";
     }
 
     },
 
     set: function(path, settings) {
-      if((typeof(settings) === 'object') && (settings.ready)) {
+      if ((typeof(settings) === 'object') && (settings.ready)) {
         this.resolveQueue(path);
       }
       this._validateDirPath(path);
-      if(typeof(settings) !== 'object') {
+      if (typeof(settings) !== 'object') {
         throw new Error("settings is required");
       }
       this._pathSettingsMap[path] = settings;
      */
     waitForPath: function(path) {
       var promise = promising();
-      if(this.cachePathReady(path)) {
+      if (this.cachePathReady(path)) {
         promise.fulfill();
       } else {
-        if(!this.queuedPromises) {
+        if (!this.queuedPromises) {
           this.queuedPromises = {};
         }
-        if(!this.queuedPromises[path]) {
+        if (!this.queuedPromises[path]) {
           this.queuedPromises[path] = [];
         }
         this.queuedPromises[path].push(promise);
      */
     resolveQueue: function(rootPath) {
       var path, i;
-      if(!this.queuedPromises) {
+      if (!this.queuedPromises) {
         return;
       }
-      for(path in this.queuedPromises) {
-        if(path.substring(0, rootPath.length) === rootPath) {
-          for(i=0; i<this.queuedPromises[path].length; i++) {
+      for (path in this.queuedPromises) {
+        if (path.substring(0, rootPath.length) === rootPath) {
+          for (i=0; i<this.queuedPromises[path].length; i++) {
             this.queuedPromises[path][i].fulfill();
           }
           delete this.queuedPromises[path];
     cachePath: function(path) {
       this._validatePath(path);
       var settings = this._query(path);
-      if(isDir(path)) {
+      if (isDir(path)) {
         return !!settings;
       } else {
         return !!settings && (settings.data === true);
      * Returns: true or false
      */
     cachePathReady: function(path) {
-      if(!this.cachePath(path)) {
+      if (!this.cachePath(path)) {
         return false;
       }
       var settings = this._query(path);
     },
 
     _validatePath: function(path) {
-      if(typeof(path) !== 'string') {
+      if (typeof(path) !== 'string') {
         throw new Error("path is required");
       }
     },
 
     _validateDirPath: function(path) {
       this._validatePath(path);
-      if(! isDir(path)) {
+      if (! isDir(path)) {
         throw new Error("not a directory path: " + path);
       }
-      if(path[0] !== '/') {
+      if (path[0] !== '/') {
         throw new Error("path not absolute: " + path);
       }
     },
 
     _updateRoots: function() {
       var roots = {};
-      for(var a in this._pathSettingsMap) {
+      for (var a in this._pathSettingsMap) {
         // already a root
-        if(roots[a]) {
+        if (roots[a]) {
           continue;
         }
         var added = false;
-        for(var b in this._pathSettingsMap) {
-          if(pathContains(a, b)) {
+        for (var b in this._pathSettingsMap) {
+          if (pathContains(a, b)) {
             roots[b] = true;
             added = true;
             break;
           }
         }
-        if(! added) {
+        if (! added) {
           roots[a] = true;
         }
       }
   Object.defineProperty(RemoteStorage.Caching.prototype, 'list', {
     get: function() {
       var list = [];
-      for(var path in this._pathSettingsMap) {
+      for (var path in this._pathSettingsMap) {
         list.push({ path: path, settings: this._pathSettingsMap[path] });
       }
       return list;
index 4a1a11c..6c65949 100644 (file)
@@ -6,7 +6,7 @@
 
     _createConflictEvent: function(path, attributes) {
       var event = { path: path };
-      for(var key in attributes) {
+      for (var key in attributes) {
         event[key] = attributes[key];
       }
 
@@ -39,7 +39,7 @@
    *   (end code)
    */
   RemoteStorage.cachingLayer = function(object) {
-    for(var key in methods) {
+    for (var key in methods) {
       object[key] = methods[key];
     }
   };
index b754445..b0df5eb 100644 (file)
@@ -32,7 +32,7 @@
           tbody.appendChild(tr);
           renderRow(tr, path, contentType, revision);
           if (path[path.length - 1] === '/') {
-            for(var key in body) {
+            for (var key in body) {
               loadRow(path + key);
             }
           }
index c9e81ff..20321a7 100644 (file)
@@ -67,7 +67,7 @@
     get : function(key) {
       key = key.toLowerCase();
       var stored = this._storage[key];
-      if(typeof stored === 'undefined'){
+      if (typeof stored === 'undefined'){
         stored = this.defaultValue;
         this._storage[key] = stored;
       }
       var len = dirs.length;
       var path = '';
 
-      for(var i = 0; i < len; i++){
+      for (var i = 0; i < len; i++){
         path += dirs[i]+'/';
-        if(!rev) {
+        if (!rev) {
           rev = this._storage[path]+1;
         }
         this._storage[path] =  rev;
     var self = this;
 
     onErrorCb = function(error){
-      if(error instanceof RemoteStorage.Unauthorized) {
+      if (error instanceof RemoteStorage.Unauthorized) {
         self.configure(null,null,null,null);
       }
     };
     this._revCache = new LowerCaseCache('rev');
     this._itemRefs = {};
 
-    if(hasLocalStorage){
+    if (hasLocalStorage){
       var settings;
       try {
         settings = JSON.parse(localStorage[SETTINGS_KEY]);
       } catch(e){}
-      if(settings) {
+      if (settings) {
         this.configure(settings.userAddress, undefined, undefined, settings.token);
       }
       try {
         this._itemRefs = JSON.parse(localStorage[ SETTINGS_KEY+':shares' ]);
       } catch(e) {  }
     }
-    if(this.connected) {
+    if (this.connected) {
       setTimeout(this._emit.bind(this), 0, 'connected');
     }
   };
     connect: function() {
       //ToDo handling when token is already present
       this.rs.setBackend('dropbox');
-      if(this.token){
+      if (this.token){
         hookIt(this.rs);
       } else {
         RS.Authorize(AUTH_URL, '', String(RS.Authorize.getLocation()), this.clientId);
       if (typeof token !== 'undefined') { this.token = token; }
       if (typeof userAddress !== 'undefined') { this.userAddress = userAddress; }
 
-      if(this.token){
+      if (this.token){
         this.connected = true;
-        if( !this.userAddress ){
+        if ( !this.userAddress ){
           this.info().then(function(info){
             this.userAddress = info.display_name;
             //FIXME propagate this to the view
       } else {
         this.connected = false;
       }
-      if(hasLocalStorage){
+      if (hasLocalStorage){
         localStorage[SETTINGS_KEY] = JSON.stringify( { token: this.token,
                                                        userAddress: this.userAddress } );
       }
       var promise = promising();
       var revCache = this._revCache;
       this._request('GET', url, {}, function(err, resp){
-        if(err){
+        if (err){
           promise.reject(err);
         }else{
           var status = resp.status;
           }
           rev = this._revCache.get(path);
           mime = 'application/json; charset=UTF-8';
-          if(body.contents) {
+          if (body.contents) {
             listing = body.contents.reduce(function(m, item) {
               var itemName = item.path.split('/').slice(-1)[0] + ( item.is_dir ? '/' : '' );
-              if(item.is_dir){
+              if (item.is_dir){
                 m[itemName] = revCache.get(path+itemName);
               } else {
                 m[itemName] = item.rev;
      **/
     get: function(path, options){
       console.log('dropbox.get', arguments);
-      if(! this.connected) { throw new Error("not connected (path: " + path + ")"); }
+      if (! this.connected) { throw new Error("not connected (path: " + path + ")"); }
       path = cleanPath(path);
       var url = 'https://api-content.dropbox.com/1/files/auto' + path;
       var promise = this._sharePromise(path);
 
       var savedRev = this._revCache.get(path);
-      if(savedRev === null) {
+      if (savedRev === null) {
         //file was deleted server side
         console.log(path,' deleted 404');
         promise.fulfill(404);
         return promise;
       }
-      if(options && options.ifNoneMatch &&
+      if (options && options.ifNoneMatch &&
          savedRev && (savedRev === options.ifNoneMatch)) {
         // nothing changed.
         console.log("nothing changed for",path,savedRev, options.ifNoneMatch);
       }
 
       //use _getDir for directories
-      if(path.substr(-1) === '/') { return this._getDir(path, options); }
+      if (path.substr(-1) === '/') { return this._getDir(path, options); }
 
       this._request('GET', url, {}, function(err, resp){
-        if(err) {
+        if (err) {
           promise.reject(err);
         } else {
           var status = resp.status;
             this._revCache.set(path, rev);
 
             // handling binary
-            if((! resp.getResponseHeader('Content-Type') ) || resp.getResponseHeader('Content-Type').match(/charset=binary/)) {
+            if ((! resp.getResponseHeader('Content-Type') ) || resp.getResponseHeader('Content-Type').match(/charset=binary/)) {
               RS.WireClient.readBinaryData(resp.response, mime, function(result) {
                 promise.fulfill(status, result, mime, rev);
               });
             } else {
               // handling json (always try)
-              if(mime && mime.search('application/json') >= 0 || true) {
+              if (mime && mime.search('application/json') >= 0 || true) {
                 try {
                   body = JSON.parse(body);
                   mime = 'application/json; charset=UTF-8';
 
       //check if file has changed and return 412
       var savedRev = revCache.get(path);
-      if(options && options.ifMatch &&  savedRev && (savedRev !== options.ifMatch) ) {
+      if (options && options.ifMatch &&  savedRev && (savedRev !== options.ifMatch) ) {
         promise.fulfill(412);
         return promise;
       }
-      if(! contentType.match(/charset=/)) {
+      if (! contentType.match(/charset=/)) {
         contentType += '; charset=' + ((body instanceof ArrayBuffer || RS.WireClient.isArrayBufferView(body)) ? 'binary' : 'utf-8');
       }
       var url = 'https://api-content.dropbox.com/1/files_put/auto' + path + '?';
-      if(options && options.ifMatch) {
+      if (options && options.ifMatch) {
         url += "parent_rev="+encodeURIComponent(options.ifMatch);
       }
-      if(body.length>150*1024*1024){ //FIXME actual content-length
+      if (body.length>150*1024*1024){ //FIXME actual content-length
         //https://www.dropbox.com/developers/core/docs#chunked-upload
         console.log('files larger than 150MB not supported yet');
       } else {
         this._request('PUT', url, {body:body, headers:{'Content-Type':contentType}}, function(err, resp) {
-          if(err) {
+          if (err) {
             promise.reject(err);
           } else {
             var response = JSON.parse(resp.responseText);
             // if dropbox reports an file conflict they just change the name of the file
             // TODO find out which stays the origianl and how to deal with this
-            if(response.path !== path){
+            if (response.path !== path){
               promise.fulfill(412);
               this.rs.log('Dropbox created conflicting File ', response.path);
             }
      **/
     'delete': function(path, options){
       console.log('dropbox.delete ', arguments);
-      if(! this.connected) { throw new Error("not connected (path: " + path + ")"); }
+      if (! this.connected) { throw new Error("not connected (path: " + path + ")"); }
       path = cleanPath(path);
 
       var promise = promising();
       var revCache = this._revCache;
       //check if file has changed and return 412
       var savedRev = revCache.get(path);
-      if(options.ifMatch && savedRev && (options.ifMatch !== savedRev)) {
+      if (options.ifMatch && savedRev && (options.ifMatch !== savedRev)) {
         promise.fulfill(412);
         return promise;
       }
 
       var url = 'https://api.dropbox.com/1/fileops/delete?root=auto&path='+encodeURIComponent(path);
       this._request('POST', url, {}, function(err, resp){
-        if(err) {
+        if (err) {
           promise.reject(error);
         } else {
           promise.fulfill(resp.status);
 
       // requesting shareing url
       this._request('POST', url, {}, function(err, resp){
-        if(err) {
+        if (err) {
           console.log(err);
           err.message = 'Shareing Dropbox Thingie("'+path+'") failed' + err.message;
           promise.reject(err);
             var url = response.url;
             itemRefs[path] = url;
             console.log("SHAREING URL :::: ",url,' for ',path);
-            if(hasLocalStorage) {
+            if (hasLocalStorage) {
               localStorage[SETTINGS_KEY+":shares"] = JSON.stringify(this._itemRefs);
             }
             promise.fulfill(url);
       var promise = promising();
       // requesting user info(mainly for userAdress)
       this._request('GET', url, {}, function(err, resp){
-        if(err) {
+        if (err) {
           promise.reject(err);
         } else {
           try {
       options.headers['Authorization'] = 'Bearer ' + this.token;
       RS.WireClient.request.call(this, method, url, options, function(err, xhr) {
         //503 means retry this later
-        if(xhr && xhr.status === 503) {
+        if (xhr && xhr.status === 503) {
           global.setTimeout(this._request(method, url, options, callback), 3210);
         } else {
           callback(err, xhr);
           'Content-Type': 'application/x-www-form-urlencoded'
         }
       }, function(error, response) {
-        if(error) {
+        if (error) {
           this.rs.log('fetchDeltas',error);
           this.rs._emit('error', new RemoteStorage.SyncError('fetchDeltas failed'+error));
           promise.reject(error);
           }
 
           // Dropbox sends the complete state
-          if(delta.reset) {
+          if (delta.reset) {
             this._revCache = new LowerCaseCache('rev');
             promise.then(function(){
               var args = Array.prototype.slice.call(arguments);
           }
 
           //saving the cursor for requesting further deltas in relation to the cursor position
-          if(delta.cursor) {
+          if (delta.cursor) {
             this._deltaCursor = delta.cursor;
           }
 
           delta.entries.forEach(function(entry) {
             var path = entry[0];
             var rev;
-            if(!entry[1]){
+            if (!entry[1]){
               rev = null;
             } else {
-              if(entry[1].is_dir) {
+              if (entry[1].is_dir) {
                 return;
               }
               rev = entry[1].rev;
   //hooking and unhooking the sync
 
   function hookSync(rs) {
-    if(rs._dropboxOrigSync) { return; } // already hooked
+    if (rs._dropboxOrigSync) { return; } // already hooked
     rs._dropboxOrigSync = rs.sync.bind(rs);
     rs.sync = function() {
       return this.dropbox.fetchDelta.apply(this.dropbox, arguments).
   }
 
   function unHookSync(rs) {
-    if(! rs._dropboxOrigSync) { return; } // not hooked
+    if (! rs._dropboxOrigSync) { return; } // not hooked
     rs.sync = rs._dropboxOrigSync;
     delete rs._dropboxOrigSync;
   }
   // hooking and unhooking getItemURL
 
   function hookGetItemURL(rs) {
-    if(rs._origBaseClientGetItemURL) { return; }
+    if (rs._origBaseClientGetItemURL) { return; }
     rs._origBaseClientGetItemURL = RS.BaseClient.prototype.getItemURL;
     RS.BaseClient.prototype.getItemURL = function(path){
       var ret = rs.dropbox._itemRefs[path];
   }
 
   function unHookGetItemURL(rs){
-    if(! rs._origBaseClieNtGetItemURL) { return; }
+    if (! rs._origBaseClieNtGetItemURL) { return; }
     RS.BaseClient.prototype.getItemURL = rs._origBaseClietGetItemURL;
     delete rs._origBaseClietGetItemURL;
   }
 
   function hookRemote(rs){
-    if(rs._origRemote) { return; }
+    if (rs._origRemote) { return; }
     rs._origRemote = rs.remote;
     rs.remote = rs.dropbox;
   }
 
   function unHookRemote(rs){
-    if(rs._origRemote) {
+    if (rs._origRemote) {
       rs.remote = rs._origRemote;
       delete rs._origRemote;
     }
 
   function hookIt(rs){
     hookRemote(rs);
-    if(rs.sync) {
+    if (rs.sync) {
       hookSync(rs);
     }
     hookGetItemURL(rs);
 
   RS.Dropbox._rs_init = function(rs) {
     hasLocalStorage = rs.localStorageAvailable();
-    if( rs.apiKeys.dropbox ) {
+    if ( rs.apiKeys.dropbox ) {
       rs.dropbox = new RS.Dropbox(rs);
     }
-    if(rs.backend === 'dropbox') {
+    if (rs.backend === 'dropbox') {
       hookIt(rs);
     }
   };
 
   RS.Dropbox._rs_cleanup = function(rs) {
     unHookIt(rs);
-    if(hasLocalStorage){
+    if (hasLocalStorage){
       delete localStorage[SETTINGS_KEY];
     }
     rs.removeEventListener('error', onErrorCb);
index a0ca887..21d86e8 100644 (file)
   RemoteStorage.Env._rs_init = function(remoteStorage) {
     RemoteStorage.eventHandling(RemoteStorage.Env, "background", "foreground");
 
-    if( mode === 'browser') {
-      if( typeof(document.hidden) !== "undefined" ) {
+    if ( mode === 'browser') {
+      if ( typeof(document.hidden) !== "undefined" ) {
         env.hiddenProperty = "hidden";
         env.visibilityChangeEvent = "visibilitychange";
-      } else if( typeof(document.mozHidden) !== "undefined" ) {
+      } else if ( typeof(document.mozHidden) !== "undefined" ) {
         env.hiddenProperty = "mozHidden";
         env.visibilityChangeEvent = "mozvisibilitychange";
-      } else if( typeof(document.msHidden) !== "undefined" ) {
+      } else if ( typeof(document.msHidden) !== "undefined" ) {
         env.hiddenProperty = "msHidden";
         env.visibilityChangeEvent = "msvisibilitychange";
-      } else if( typeof(document.webkitHidden) !== "undefined" ) {
+      } else if ( typeof(document.webkitHidden) !== "undefined" ) {
         env.hiddenProperty = "webkitHidden";
         env.visibilityChangeEvent = "webkitvisibilitychange";
       }
       document.addEventListener(env.visibilityChangeEvent, function () {
-        if( document[env.hiddenProperty] ) {
+        if ( document[env.hiddenProperty] ) {
           RemoteStorage.Env.goBackground();
         } else {
           RemoteStorage.Env.goForeground();
index bc49172..eb35b7c 100644 (file)
@@ -21,8 +21,8 @@
     removeEventListener: function(eventName, handler) {
       this._validateEvent(eventName);
       var hl = this._handlers[eventName].length;
-      for(var i=0;i<hl;i++) {
-        if(this._handlers[eventName][i] === handler) {
+      for (var i=0;i<hl;i++) {
+        if (this._handlers[eventName][i] === handler) {
           this._handlers[eventName].splice(i, 1);
           return;
         }
@@ -38,7 +38,7 @@
     },
 
     _validateEvent: function(eventName) {
-      if(! (eventName in this._handlers)) {
+      if (! (eventName in this._handlers)) {
         throw new Error("Unknown event: " + eventName);
       }
     },
@@ -88,7 +88,7 @@
    */
   RemoteStorage.eventHandling = function(object) {
     var eventNames = Array.prototype.slice.call(arguments, 1);
-    for(var key in methods) {
+    for (var key in methods) {
       object[key] = methods[key];
     }
     object._handlers = {};
index f4d1925..ca9fffc 100644 (file)
@@ -20,7 +20,7 @@
   }
 
   function metaTitleFromFileName(filename) {
-    if(filename.substr(-1) === '/') {
+    if (filename.substr(-1) === '/') {
       filename = filename.substr(0, filename.length - 1);
     }
     return decodeURIComponent(filename);
@@ -32,7 +32,7 @@
 
   function baseName(path) {
     var parts = path.split('/');
-    if(path.substr(-1) === '/') {
+    if (path.substr(-1) === '/') {
       return parts[parts.length-2]+'/';
     } else {
       return parts[parts.length-1];
@@ -76,7 +76,7 @@
   RS.GoogleDrive.prototype = {
 
     configure: function(_x, _y, _z, token) { // parameter list compatible with WireClient
-      if(token) {
+      if (token) {
         localStorage['remotestorage:googledrive:token'] = token;
         this.token = token;
         this.connected = true;
@@ -96,7 +96,7 @@
     },
 
     get: function(path, options) {
-      if(path.substr(-1) === '/') {
+      if (path.substr(-1) === '/') {
         return this._getDir(path, options);
       } else {
         return this._getFile(path, options);
     put: function(path, body, contentType, options) {
       var promise = promising();
       function putDone(error, response) {
-        if(error) {
+        if (error) {
           promise.reject(error);
-        } else if(response.status >= 200 && response.status < 300) {
+        } else if (response.status >= 200 && response.status < 300) {
           var meta = JSON.parse(response.responseText);
           promise.fulfill(200, undefined, meta.mimeType, meta.etag);
         } else {
         }
       }
       this._getFileId(path, function(idError, id) {
-        if(idError) {
+        if (idError) {
           promise.reject(idError);
           return;
-        } else if(id) {
+        } else if (id) {
           this._updateFile(id, path, body, contentType, options, putDone);
         } else {
           this._createFile(path, body, contentType, options, putDone);
     'delete': function(path, options) {
       var promise = promising();
       this._getFileId(path, function(idError, id) {
-        if(idError) {
+        if (idError) {
           promise.reject(idError);
-        } else if(id) {
+        } else if (id) {
           this._request('DELETE', BASE_URL + '/drive/v2/files/' + id, {}, function(deleteError, response) {
-            if(deleteError) {
+            if (deleteError) {
               promise.reject(deleteError);
-            } else if(response.status === 200 || response.status === 204) {
+            } else if (response.status === 200 || response.status === 204) {
               promise.fulfill(200);
             } else {
               promise.reject("Delete failed: " + response.status + " (" + response.responseText + ")");
           'Content-Type': 'application/json; charset=UTF-8'
         }
       }, function(metadataError, response) {
-        if(metadataError) {
+        if (metadataError) {
           callback(metadataError);
         } else {
           this._request('PUT', response.getResponseHeader('Location'), {
     _createFile: function(path, body, contentType, options, callback) {
       callback = callback.bind(this);
       this._getParentId(path, function(parentIdError, parentId) {
-        if(parentIdError) {
+        if (parentIdError) {
           callback(parentIdError);
           return;
         }
             'Content-Type': 'application/json; charset=UTF-8'
           }
         }, function(metadataError, response) {
-          if(metadataError) {
+          if (metadataError) {
             callback(metadataError);
           } else {
             this._request('POST', response.getResponseHeader('Location'), {
     _getFile: function(path, options) {
       var promise = promising();
       this._getFileId(path, function(idError, id) {
-        if(idError) {
+        if (idError) {
           promise.reject(idError);
         } else {
           this._getMeta(id, function(metaError, meta) {
-            if(metaError) {
+            if (metaError) {
               promise.reject(metaError);
-            } else if(meta.downloadUrl) {
+            } else if (meta.downloadUrl) {
               var options = {};
-              if(meta.mimeType.match(/charset=binary/)) {
+              if (meta.mimeType.match(/charset=binary/)) {
                 options.responseType = 'blob';
               }
               this._request('GET', meta.downloadUrl, options, function(downloadError, response) {
-                if(downloadError) {
+                if (downloadError) {
                   promise.reject(downloadError);
                 } else {
                   var body = response.response;
-                  if(meta.mimeType.match(/^application\/json/)) {
+                  if (meta.mimeType.match(/^application\/json/)) {
                     try {
                       body = JSON.parse(body);
                     } catch(e) {}
     _getDir: function(path, options) {
       var promise = promising();
       this._getFileId(path, function(idError, id) {
-        if(idError) {
+        if (idError) {
           promise.reject(idError);
-        } else if(! id) {
+        } else if (! id) {
           promise.fulfill(404);
         } else {
           this._request('GET', BASE_URL + '/drive/v2/files/' + id + '/children', {}, function(childrenError, response) {
-            if(childrenError) {
+            if (childrenError) {
               promise.reject(childrenError);
             } else {
-              if(response.status === 200) {
+              if (response.status === 200) {
                 var data = JSON.parse(response.responseText);
                 var n = data.items.length, i = 0;
-                if(n === 0) {
+                if (n === 0) {
                   // FIXME: add revision of directory!
                   promise.fulfill(200, {}, RS_DIR_MIME_TYPE, undefined);
                   return;
                 var result = {};
                 var idCache = {};
                 var gotMeta = function(err, meta) {
-                  if(err) {
+                  if (err) {
                     // FIXME: actually propagate the error.
                     console.error("getting meta stuff failed: ", err);
                   } else {
                     this._fileIdCache.set(path + fileName, meta.id);
                   }
                   i++;
-                  if(i === n) {
+                  if (i === n) {
                     promise.fulfill(200, result, RS_DIR_MIME_TYPE, undefined);
                   }
                 }.bind(this);
       callback = callback.bind(this);
       var dirname = parentPath(path);
       this._getFileId(dirname, function(idError, parentId) {
-        if(idError) {
+        if (idError) {
           callback(idError);
-        } else if(parentId) {
+        } else if (parentId) {
           callback(null, parentId);
         } else {
           this._createDir(dirname, callback);
     _createDir: function(path, callback) {
       callback = callback.bind(this);
       this._getParentId(path, function(idError, parentId) {
-        if(idError) {
+        if (idError) {
           callback(idError);
         } else {
           this._request('POST', BASE_URL + '/drive/v2/files', {
               'Content-Type': 'application/json; charset=UTF-8'
             }
           }, function(createError, response) {
-            if(createError) {
+            if (createError) {
               callback(createError);
             } else {
               var meta = JSON.parse(response.responseText);
     _getFileId: function(path, callback) {
       callback = callback.bind(this);
       var id;
-      if(path === '/') {
+      if (path === '/') {
         // "root" is a special alias for the fileId of the root directory
         callback(null, 'root');
-      } else if((id = this._fileIdCache.get(path))) {
+      } else if ((id = this._fileIdCache.get(path))) {
         // id is cached.
         callback(null, id);
       } else {
     _getMeta: function(id, callback) {
       callback = callback.bind(this);
       this._request('GET', BASE_URL + '/drive/v2/files/' + id, {}, function(err, response) {
-        if(err) {
+        if (err) {
           callback(err);
         } else {
-          if(response.status === 200) {
+          if (response.status === 200) {
             callback(null, JSON.parse(response.responseText));
           } else {
             callback("request (getting metadata for " + id + ") failed with status: " + response.status);
       options.headers['Authorization'] = 'Bearer ' + this.token;
       RS.WireClient.request.call(this, method, url, options, function(err, xhr) {
         // google tokens expire from time to time...
-        if(xhr && xhr.status === 401) {
+        if (xhr && xhr.status === 401) {
           this.connect();
           return;
         }
 
   RS.GoogleDrive._rs_init = function(remoteStorage) {
     var config = remoteStorage.apiKeys.googledrive;
-    if(config) {
+    if (config) {
       remoteStorage.googledrive = new RS.GoogleDrive(remoteStorage, config.client_id);
-      if(remoteStorage.backend === 'googledrive') {
+      if (remoteStorage.backend === 'googledrive') {
         remoteStorage._origRemote = remoteStorage.remote;
         remoteStorage.remote = remoteStorage.googledrive;
       }
 
   RS.GoogleDrive._rs_cleanup = function(remoteStorage) {
     remoteStorage.setBackend(undefined);
-    if(remoteStorage._origRemote) {
+    if (remoteStorage._origRemote) {
       remoteStorage.remote = remoteStorage._origRemote;
       delete remoteStorage._origRemote;
     }
index 6ae5e2d..0d29631 100644 (file)
       changes.get(path).onsuccess = function(evt) {
         change = evt.target.result || {};
         change.path = path;
-        for(var key in attributes) {
+        for (var key in attributes) {
           change[key] = attributes[key];
         }
         changes.put(change);
   RS.IndexedDB._rs_init = function(remoteStorage) {
     var promise = promising();
     RS.IndexedDB.open(DEFAULT_DB_NAME, function(err, db) {
-      if(err) {
+      if (err) {
         promise.reject(err);
       } else {
         DEFAULT_DB = db;
index f02028a..c6b0d5c 100644 (file)
 
     _recordChange: function(path, attributes) {
       var change = this._changes[path] || {};
-      for(var key in attributes) {
+      for (var key in attributes) {
         change[key] = attributes[key];
       }
       change.path = path;
     changesBelow: function(path) {
       var changes = [];
       var l = path.length;
-      for(var key in this._changes) {
+      for (var key in this._changes) {
         if (key.substr(0,l) === path) {
           changes.push(this._changes[key]);
         }
index 02794a6..eacc093 100644 (file)
@@ -12,7 +12,7 @@
     extend: function(target) {
       var sources = Array.prototype.slice.call(arguments, 1);
       sources.forEach(function(source) {
-        for(var key in source) {
+        for (var key in source) {
           target[key] = source[key];
         }
       });
@@ -30,7 +30,7 @@
       var results = [], errors = [];
       function oneDone() {
         i++;
-        if(i === n) {
+        if (i === n) {
           promise.fulfill(results, errors);
         }
       }
@@ -74,7 +74,7 @@
     },
 
     bindAll: function(object) {
-      for(var key in this) {
+      for (var key in this) {
         if (typeof(object[key]) === 'function') {
           object[key] = object[key].bind(object);
         }
index cbfe8b3..dfbd820 100644 (file)
@@ -60,7 +60,7 @@
     toBase64: function(data){
       var arr = new Uint8Array(data);
       var str = '';
-      for(var i = 0; i < arr.length; i++) {
+      for (var i = 0; i < arr.length; i++) {
         //atob(btoa(String.fromCharCode(arr[0]))).charCodeAt(0)
         str+=String.fromCharCode(arr[i]);
       }
       } catch(e) {
         change = {};
       }
-      for(var key in attributes) {
+      for (var key in attributes) {
         change[key] = attributes[key];
       }
       change.path = path;
       var changes = [];
       var kl = localStorage.length;
       var prefix = CHANGES_PREFIX + path, pl = prefix.length;
-      for(var i=0;i<kl;i++) {
+      for (var i=0;i<kl;i++) {
         var key = localStorage.key(i);
         if (key.substr(0, pl) === prefix) {
           changes.push(JSON.parse(localStorage[key]));
 
     fireInitial: function() {
       var l = localStorage.length, npl = NODES_PREFIX.length;
-      for(var i=0;i<l;i++) {
+      for (var i=0;i<l;i++) {
         var key = localStorage.key(i);
         if (key.substr(0, npl) === NODES_PREFIX) {
           var path = key.substr(npl);
     var l = localStorage.length;
     var npl = NODES_PREFIX.length, cpl = CHANGES_PREFIX.length;
     var remove = [];
-    for(var i=0;i<l;i++) {
+    for (var i=0;i<l;i++) {
       var key = localStorage.key(i);
       if (key.substr(0, npl) === NODES_PREFIX ||
          key.substr(0, cpl) === CHANGES_PREFIX) {
index 914c2ac..7770a42 100644 (file)
         if (this.remote) {
           this.remote.on('connected', function() {
             try {
-              if(!readyFired) {
+              if (!readyFired) {
                 this._emit('ready');
                 readyFired = true;
               }
           }.bind(this));
           if (this.remote.connected) {
             try {
-              if(!readyFired) {
+              if (!readyFired) {
                 this._emit('ready');
                 readyFired = true;
               }
       function featureSupportedCb(name) {
         return function(success) {
           self.log("[FEATURE "+name+"]" + success ? "":" not"+" supported");
-          if(!success) {
+          if (!success) {
             featureDone();
           }
         };
     },
 
     _dispatchEvent: function(eventName, event) {
-      for(var path in this._pathHandlers[eventName]) {
+      for (var path in this._pathHandlers[eventName]) {
         var pl = path.length;
         var self = this;
         this._pathHandlers[eventName][path].forEach(function(handler) {
           if (event.path.substr(0, pl) === path) {
             var ev = {};
-            for(var key in event) { ev[key] = event[key]; }
+            for (var key in event) { ev[key] = event[key]; }
             ev.relativePath = event.path.replace(new RegExp('^' + path), '');
             try {
               handler(ev);
index f73e49c..8c06805 100644 (file)
    *
    */
   RemoteStorage.prototype.setSyncInterval = function(interval) {
-    if(typeof(interval) !== 'number') {
+    if (typeof(interval) !== 'number') {
       throw interval + " is not a valid sync interval";
     }
     syncInterval = parseInt(interval, 10);
           var cachingState = rs.caching.get(path);
           RemoteStorage.Sync.sync(rs.remote, rs.local, path, cachingState).
             then(function() {
-              if(!cachingState.ready) {
+              if (!cachingState.ready) {
                 cachingState.ready = true;
                 rs.caching.set(path, cachingState);
               }
index 917cfd2..5df1783 100644 (file)
     setView: function(view) {
       this.view = view;
       this.view.on('connect', function(options) {
-        if(typeof(options) === 'string') {
+        if (typeof(options) === 'string') {
           // options is simply a useraddress
           this.rs.connect(options);
-        } else if(options.special) {
+        } else if (options.special) {
           this.rs[options.special].connect(options);
         }
       }.bind(this));
       this.view.on('disconnect', this.rs.disconnect.bind(this.rs));
-      if(this.rs.sync) {
+      if (this.rs.sync) {
         this.view.on('sync', this.rs.sync.bind(this.rs));
       }
       try {
           this.rs.disconnect();
         }.bind(this));
       } catch(e) {
-        if(e.message && e.message.match(/Unknown event/)) {
+        if (e.message && e.message.match(/Unknown event/)) {
           // ignored. (the 0.7 widget-view interface didn't have a 'reset' event)
         } else {
           throw e;
         }
       }
 
-      if(this._rememberedState) {
+      if (this._rememberedState) {
         setTimeout(stateSetter(this, this._rememberedState), 0);
         delete this._rememberedState;
       }
 
   RemoteStorage.Widget._rs_init = function(remoteStorage) {
     hasLocalStorage = remoteStorage.localStorageAvailable();
-    if(! remoteStorage.widget) {
+    if (! remoteStorage.widget) {
       remoteStorage.widget = new RemoteStorage.Widget(remoteStorage);
     }
   };
index 229a9c3..f36f559 100644 (file)
@@ -61,7 +61,7 @@
       Int32Array, Uint32Array, Float32Array, Float64Array
     ];
     isArrayBufferView = function(object) {
-      for(var i=0;i<8;i++) {
+      for (var i=0;i<8;i++) {
         if (object instanceof arrayBufferViews[i]) {
           return true;
         }
     RS.eventHandling(this, 'change', 'connected');
 
     onErrorCb = function(error){
-      if(error instanceof RemoteStorage.Unauthorized) {
+      if (error instanceof RemoteStorage.Unauthorized) {
         this.configure(undefined, undefined, undefined, null);
       }
     }.bind(this);
       xhr.responseType = options.responseType;
     }
     if (options.headers) {
-      for(var key in options.headers) {
+      for (var key in options.headers) {
         xhr.setRequestHeader(key, options.headers[key]);
       }
     }
index 4b59825..e0994d0 100644 (file)
@@ -8,7 +8,7 @@ var testRequest = helpers.testRequest;
 
 var baseUrl = process.argv[2];
 var token = process.argv[3];
-if(! (baseUrl && token)) {
+if (! (baseUrl && token)) {
   console.log("Usage: " + process.argv[1] + " <base-url> <token>");
   process.exit(127);
 }
index 7cb6e48..6b5237b 100644 (file)
@@ -25,8 +25,8 @@ define(['requirejs', 'fs'], function(requirejs, fs, undefined) {
         },
         removeEventListener: function(eventName, handler) {
           var hl = this._handlers[eventName].length;
-          for(var i=0;i<hl;i++) {
-            if(this._handlers[eventName][i] === handler) {
+          for (var i=0;i<hl;i++) {
+            if (this._handlers[eventName][i] === handler) {
               this._handlers[eventName].splice(i, 1);
               return;
             }
index fb4a4f3..d3208a7 100644 (file)
@@ -33,7 +33,7 @@ define(['requirejs'], function(requirejs, undefined) {
         global.rs_eventhandling = RemoteStorage.eventHandling;
       }
       require('./src/wireclient');
-      if(global.rs_wireclient) {
+      if (global.rs_wireclient) {
         RemoteStorage.WireClient = global.rs_wireclient;
       } else {
         global.rs_wireclient = RemoteStorage.WireClient;
@@ -117,13 +117,13 @@ define(['requirejs'], function(requirejs, undefined) {
   suites.push({
     desc: "BaseClient directory handling",
     setup: function(env, test) {
-      if(typeof(RemoteStorage) !== 'function') {
+      if (typeof(RemoteStorage) !== 'function') {
         global.RemoteStorage = function() {};
         RemoteStorage.prototype = {
           onChange: function() {}
         };
       }
-      if(typeof(RemoteStorage.BaseClient) !== 'function') {
+      if (typeof(RemoteStorage.BaseClient) !== 'function') {
         require('./src/eventhandling');
         require('./src/baseclient');
       }
@@ -313,7 +313,7 @@ define(['requirejs'], function(requirejs, undefined) {
         run: function(env, test) {
           var n = 10000;
           var uuids = {};
-          for(var i=0;i<n;i++) {
+          for (var i=0;i<n;i++) {
             uuids[env.client.uuid()] = true;
           }
           test.assert(Object.keys(uuids).length, n);
index 4a00089..113b9bd 100644 (file)
@@ -1,4 +1,4 @@
-if(typeof(define) !== 'function') {
+if (typeof(define) !== 'function') {
   var define = require('amdefine')(module);
 }
 define([], function() {
index cfbb385..c1ebe6f 100644 (file)
@@ -17,7 +17,7 @@ define(['requirejs', 'fs'], function(requirejs, fs, undefined) {
     },
 
     beforeEach: function(env, test) {
-      if(typeof(XMLHttpRequest) === 'function') {
+      if (typeof(XMLHttpRequest) === 'function') {
         XMLHttpRequest.instances = [];
         XMLHttpRequest.openCalls = [];
         XMLHttpRequest.sendCalls = [];
@@ -147,7 +147,7 @@ define(['requirejs', 'fs'], function(requirejs, fs, undefined) {
           RemoteStorage.Discover("foo@bar", function(href) {
             test.assertType(href, 'undefined');
           });
-          for(var i = 0; i < 4; i++) {
+          for (var i = 0; i < 4; i++) {
             var instance = XMLHttpRequest.instances[i];
             instance.status = 200;
             XMLHttpRequest.onloadFunction();
index 8a2c06b..a278b42 100644 (file)
@@ -25,14 +25,14 @@ define(['requirejs'], function(requirejs, undefined) {
       require('./lib/promising');
       require('./src/eventhandling');
 
-      if(global.rs_eventhandling) {
+      if (global.rs_eventhandling) {
         RemoteStorage.eventHandling = global.rs_eventhandling;
       } else {
         global.rs_eventhandling = RemoteStorage.eventHandling;
       }
       require('./src/wireclient');
 
-      if(global.rs_wireclient) {
+      if (global.rs_wireclient) {
         RemoteStorage.WireClient = global.rs_wireclient;
       } else {
         global.rs_wireclient = RemoteStorage.WireClient;
index 6664fe2..9655c09 100644 (file)
@@ -24,14 +24,14 @@ define(['requirejs'], function(requirejs, undefined) {
       require('./lib/promising');
       require('./src/eventhandling');
       
-      if(global.rs_eventhandling) {
+      if (global.rs_eventhandling) {
         RemoteStorage.eventHandling = global.rs_eventhandling;
       } else {
         global.rs_eventhandling = RemoteStorage.eventHandling;
       }
       require('./src/wireclient');
       
-      if(global.rs_wireclient) {
+      if (global.rs_wireclient) {
         RemoteStorage.WireClient = global.rs_wireclient;
       } else {
         global.rs_wireclient = RemoteStorage.WireClient;
index 267bcd1..9f6d363 100644 (file)
@@ -1,4 +1,4 @@
-if(typeof(define) !== 'function') {
+if (typeof(define) !== 'function') {
   var define = require('amdefine')(module);
 }
 define(['requirejs'], function(requirejs) {
@@ -11,13 +11,13 @@ define(['requirejs'], function(requirejs) {
       require('./lib/promising');
       global.RemoteStorage = function() {};
       require('./src/eventhandling');
-      if(global.rs_eventhandling) {
+      if (global.rs_eventhandling) {
         RemoteStorage.eventHandling = global.rs_eventhandling;
       } else {
         global.rs_eventhandling = RemoteStorage.eventHandling;
       }
       require('./src/cachinglayer');
-      if(global.rs_cachinglayer) {
+      if (global.rs_cachinglayer) {
         RemoteStorage.cachingLayer = global.rs_cachinglayer;
       } else {
         global.rs_cachinglayer = RemoteStorage.cachingLayer;
index b86c41b..03984b1 100644 (file)
@@ -1,4 +1,4 @@
-if(typeof(define) !== 'function') {
+if (typeof(define) !== 'function') {
   var define = require('amdefine')(module);
 }
 define(['requirejs'], function(requirejs) {
@@ -11,13 +11,13 @@ define(['requirejs'], function(requirejs) {
       require('./lib/promising');
       global.RemoteStorage = function() {};
       require('./src/eventhandling');
-      if( global.rs_eventhandling ) {
+      if ( global.rs_eventhandling ) {
         RemoteStorage.eventHandling = global.rs_eventhandling;
       } else {
         global.rs_eventhandling = RemoteStorage.eventHandling;
       }
       require('./src/cachinglayer');
-      if(global.rs_cachinglayer) {
+      if (global.rs_cachinglayer) {
         RemoteStorage.cachingLayer = global.rs_cachinglayer;
       } else {
         global.rs_cachinglayer = RemoteStorage.cachingLayer;
index b431f22..b08be6c 100644 (file)
@@ -1,4 +1,4 @@
-if(typeof(define) !== 'function') {
+if (typeof(define) !== 'function') {
   var define = require('amdefine')(module);
 }
 define(['requirejs'], function(requirejs) {
@@ -24,7 +24,7 @@ define(['requirejs'], function(requirejs) {
   function assertHaveNodes(test, expected) {
     var haveNodes = [];
     var keys = Object.keys(localStorage), kl = keys.length;
-    for(var i=0;i<kl;i++) {
+    for (var i=0;i<kl;i++) {
       if (keys[i].substr(0, NODES_PREFIX.length) === NODES_PREFIX) {
         haveNodes.push(keys[i].substr(NODES_PREFIX.length));
       }
@@ -45,7 +45,7 @@ define(['requirejs'], function(requirejs) {
         global.rs_eventhandling = RemoteStorage.eventHandling;
       }
       require('./src/cachinglayer');
-      if(global.rs_cachinglayer) {
+      if (global.rs_cachinglayer) {
         RemoteStorage.cachingLayer = global.rs_cachinglayer;
       } else {
         global.rs_cachinglayer = RemoteStorage.cachingLayer;
index ded2a2e..f4489c5 100644 (file)
@@ -15,13 +15,13 @@ define(['requirejs'], function(requirejs) {
       require('./lib/promising');
       require('./src/eventhandling');
 
-      if(global.rs_eventhandling) {
+      if (global.rs_eventhandling) {
         RemoteStorage.eventHandling = global.rs_eventhandling;
       } else {
         global.rs_eventhandling = RemoteStorage.eventHandling;
       }
       require('./src/wireclient');
-      if(global.rs_wireclient) {
+      if (global.rs_wireclient) {
         RemoteStorage.WireClient = global.rs_wireclient;
       } else {
         global.rs_wireclient = RemoteStorage.WireClient;
index fefdd7c..61c8479 100644 (file)
@@ -1,4 +1,4 @@
-if(typeof(define) !== 'function') {
+if (typeof(define) !== 'function') {
   var define = require('amdefine');
 }
 define([], function() {
@@ -16,7 +16,7 @@ define([], function() {
   function fakeRequest(path) {
     var promise = promising();
     console.log('GET CALLED');
-    if(path === '/testing403') {
+    if (path === '/testing403') {
       promise.fulfill(403);
     } else {
       promise.fulfill(200);
@@ -66,7 +66,7 @@ define([], function() {
       require('./src/remotestorage');
       require('./src/eventhandling');
       require('./lib/promising');
-      if(global.rs_eventhandling) {
+      if (global.rs_eventhandling) {
         RemoteStorage.eventHandling = global.rs_eventhandling;
       } else {
         global.rs_eventhandling = RemoteStorage.eventHandling;
index 9f31dc3..4b73c81 100644 (file)
@@ -1,4 +1,4 @@
-if(typeof(define) !== 'function') {
+if (typeof(define) !== 'function') {
   var define = require('amdefine');
 }
 
index a31de64..1473f29 100644 (file)
@@ -15,13 +15,13 @@ define(['requirejs'], function(requirejs, undefined) {
       require('./lib/promising');
       require('./src/eventhandling');
 
-      if(global.rs_eventhandling) {
+      if (global.rs_eventhandling) {
         RemoteStorage.eventHandling = global.rs_eventhandling;
       } else {
         global.rs_eventhandling = RemoteStorage.eventHandling;
       }
       require('./src/wireclient');
-      if(global.rs_wireclient) {
+      if (global.rs_wireclient) {
         RemoteStorage.WireClient = global.rs_wireclient;
       } else {
         global.rs_wireclient = RemoteStorage.WireClient;