Skip to content

Instantly share code, notes, and snippets.

@geersch
geersch / gist:d7d2c04a3d5730b86065fe8ba92150d3
Last active April 17, 2024 14:58
Streams: backpressure
import { blue, bold, cyan, green, yellow } from 'kleur';
import { clear, log } from 'node:console';
import { createReadStream } from 'node:fs';
import { join } from 'node:path';
import { PassThrough, Readable } from 'node:stream';
clear();
// const path = join(__dirname, '../files/13KB.pdf');
// const path = join(__dirname, '../files/1MB.pdf');
@geersch
geersch / gist:edd75a600e86fb59130b
Last active August 29, 2015 14:01
#1 - Creating a projection
// Compose a projection.
// - Tell what type of state the projection maintains (List<WizardActivity>)
var projection = Compose<List<WizardActivity>>.Projection()
.Initialize(() => new List<WizardActivity>()) // How do you want to initialize the state when you run the projection?
// When a wizard was started we want to know about it.
.When<WizardStarted>((@event, state) =>
{
var activity = new WizardActivity(@event.CorrelationId.Value, @event.TimeStamp);
if (!state.Contains(activity))
state.Add(activity);