code: function(api, id, obj) {
    if(!api) {
      throw new Error('WebStorage not available.');
    }
  
    var rval;
    if(obj === null) {
      rval = api.removeItem(id);
    } else {
      // json-encode and base64-encode object
      obj = util.encode64(JSON.stringify(obj));
      rval = api.setItem(id, obj);
    }
  
    // handle potential flash error
    if(typeof(rval) !== 'undefined' && rval.rval !== true) {
      var error = new Error(rval.error.message);
      error.id = rval.error.id;
      error.name = rval.error.name;
      throw error;
    }
  }
docs: Sets a storage object.
  
  @param api the storage interface.
  @param id the storage ID to use.
  @param obj the storage object, null to remove.