code: function preferencesSet(name, value) {
            return this.initializedPromise.then(function () {
              if (this.defaults[name] === undefined) {
                throw new Error('preferencesSet: \'' + name + '\' is undefined.');
              } else if (value === undefined) {
                throw new Error('preferencesSet: no value is specified.');
              }
              var valueType = typeof value;
              var defaultType = typeof this.defaults[name];
              if (valueType !== defaultType) {
                if (valueType === 'number' && defaultType === 'string') {
                  value = value.toString();
                } else {
                  throw new Error('Preferences_set: \'' + value + '\' is a \"' + valueType + '\", expected \"' + defaultType + '\".');
                }
              } else {
                if (valueType === 'number' && (value | 0) !== value) {
                  throw new Error('Preferences_set: \'' + value + '\' must be an \"integer\".');
                }
              }
              this.prefs[name] = value;
              return this._writeToStorage(this.prefs);
            }.bind(this));
          }
docs: Set the value of a preference.
  @param {string} name The name of the preference that should be changed.
  @param {boolean|number|string} value The new value of the preference.
  @return {Promise} A promise that is resolved when the value has been set,
  provided that the preference exists and the types match.