I have a need for getting the calendar as a stream instead of as a string. My requirement is about pushing the calendar up to a pkgcloud service but perhaps others also want another way to serve calendars; see why you should use streams.
I'm wondering if you'd accept a pull request along those lines and if so looking for any guidance you might have.
There are certainly good arguments to be made that much of the calendar object is already in memory so streaming it only saves from creating a large string representation of the objects already in memory. As I said, my request is a bit about convenience operating with things expecting a stream and so performance while nice isn't my top line goal.
Currently I'm using the following to take the calendar toString method and coerce it into into a stream.
var _ = require('lodash');
var ical = require('icalendar');
var Readable = require('stream').Readable;
var calendar = new ical.iCalendar();
var s = new Readable();
s._read = _.noop;
s.push(calendar.toString());
s.push(null);
var stream3 = s3.uploadStream('ical', 'uid.ics');
s.pipe(stream3);
My plan is to make the following changes:
Use the Readable stream
var Readable = require('stream').Readable;
CalendarObject inherits from Readable
util.inherits(CalendarObject, Readable);
Add a _read function which mimics the format and toString function
Hi -
I have a need for getting the calendar as a stream instead of as a string. My requirement is about pushing the calendar up to a pkgcloud service but perhaps others also want another way to serve calendars; see why you should use streams.
I'm wondering if you'd accept a pull request along those lines and if so looking for any guidance you might have.
There are certainly good arguments to be made that much of the calendar object is already in memory so streaming it only saves from creating a large string representation of the objects already in memory. As I said, my request is a bit about convenience operating with things expecting a stream and so performance while nice isn't my top line goal.
Currently I'm using the following to take the calendar
toString
method and coerce it into into a stream.My plan is to make the following changes:
var Readable = require('stream').Readable;
util.inherits(CalendarObject, Readable);
CalendarObject.prototype._read = function(n) {
Probably insert the _read function between the toString and format functions. https://github.com/tritech/node-icalendar/blob/master/lib/base.js#L236
This change should give the Calendar object ( by inheritance ) the ability to be piped like a stream.
Maybe I'll just write it now that I spec'd it all out.