Skip to content

Instantly share code, notes, and snippets.

@lightsofapollo
Created July 25, 2012 20:27
Show Gist options
  • Save lightsofapollo/3178455 to your computer and use it in GitHub Desktop.
Save lightsofapollo/3178455 to your computer and use it in GitHub Desktop.
ICAL bikeshed
// some ical string;
var rawIcalString;
// my ical data - remove decorate parameter
var data = ICAL.parse(rawIcalString);
var component = new ICAL.Component(data);
// later I store it in the DB
var structuredCloneData;
var component = new ICAL.Component(structuredCloneData);
// mutate it
component.removeSubcomponent('FOO');
component.addPropertyWithValue('foo', 'bar');
// save it back to db
// this is now undecorated
var storable = component.toJSON();
@lightsofapollo
Copy link
Author

and natually we can also have

ICAL.stringify(object)

And store objects as raw JSON strings.

var json = JSON.stringify(component);
var component = new ICAL.Component(JSON.parse(json));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment