firefox/profile.js
function loadUserPrefs(f) {
  var done = promise.defer();
  fs.readFile(f, function(err, contents) {
    if (err && err.code === 'ENOENT') {
      done.fulfill({});
      return;
    }

    if (err) {
      done.reject(err);
      return;
    }

    var prefs = {};
    var context = vm.createContext({
      'user_pref': function(key, value) {
        prefs[key] = value;
      }
    });

    vm.runInContext(contents, context, f);
    done.fulfill(prefs);
  });
  return done.promise;
}
function loadUserPrefs(f) {
  var done = promise.defer();
  fs.readFile(f, function(err, contents) {
    if (err && err.code === 'ENOENT') {
      done.fulfill({});
      return;
    }

    if (err) {
      done.reject(err);
      return;
    }

    var prefs = {};
    var context = vm.createContext({
      'user_pref': function(key, value) {
        prefs[key] = value;
      }
    });

    vm.runInContext(contents, context, f);
    done.fulfill(prefs);
  });
  return done.promise;
}
function loadUserPrefs ( f ) { var done = promise . defer ( ) ; fs . readFile ( f , function ( err , contents ) { if ( err && err . code === 'ENOENT' ) { done . fulfill ( { } ) ; return ; } if ( err ) { done . reject ( err ) ; return ; } var prefs = { } ; var context = vm . createContext ( { 'user_pref' : function ( key , value ) { prefs [ key ] = value ; } } ) ; vm . runInContext ( contents , context , f ) ; done . fulfill ( prefs ) ; } ) ; return done . promise ; }
Parses a user.js file in a Firefox profile directory.
@param {string} f Path to the file to parse.
@return {!promise.Promise.<!Object>} A promise for the parsed preferences as
a JSON object. If the file does not exist, an empty object will be
returned.
Parses a user . js file in a Firefox profile directory .