
Security News
152 Chrome Live Wallpaper Extensions Hid Ad Tracking and Faked Google Search Traffic
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.
Stalagmite is a library that helps you building event sourced aggregates.
npm install stalagmite
Access documentation here with examples
In this example we will create a simple aggregate for a counter. Find the complete counter example here
import { buildAggregate, Aggregate, AggregateState } from 'stalagmite';
export interface Counter extends Aggregate<CounterState, CounterEvents> {
init(counterId: string, initialCount: number): Outcome;
count(number: number): Outcome;
reset(): Outcome;
}
export interface CounterState extends AggregateState {
id: string;
count: number;
}
function counterEventResolver( // It's this function that mutate the state when applying an event.
state: CounterState,
event: CounterEvents,
): Outcome {
/*...*/
}
const commandId = 'command-id'; // The command you are building the aggregate for.
const aggregate = buildAggregate(commandId, initialState, eventResolver, {
snapshotEvery: 2, // This options will generate snapshots every 2 events added
});
// Expose your business methods and expose aggregate methods.
return {
init: () => {
/*...*/
},
count: () => {
/*...*/
},
reset: () => {
/*...*/
},
...aggregate,
};
To see an eventResolver example click here
// Aggregate interface
aggregate.apply(events: Event | Event[]): ApplyEventOutcome; // Apply an event to the aggregate.
aggregate.addEvent(events: E): Outcome; // Add and apply a new event to the aggregate.
aggregate.getUncommmitedEvents(): E[]; // Returns new events created not commited yet.
aggregate.eventsCommited(): void; // Call this function when you have saved those events in your event store. It clear the uncommited events array.
aggregate.getSequence(): number; // Returns aggregate sequence.
aggregate.state(): S; // Returns a deep copy of the current state.
aggregate.snapshot(): S; // Create an aggregate snapshot and return it.
aggregate.getSnapshot(): S[]; // Get all snapshots created.
aggregate.snapshotsCommited(): void; // Empty the list of snapshots.
FAQs
Event sourcing library that helps you building event sourced aggregates.
We found that stalagmite demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A network of 152 Chrome live wallpaper extensions hid ad tracking and made extension-driven traffic look like Google search clicks.

Company News
Socket’s first CISO brings deep experience securing high-growth SaaS companies as open source supply chain threats accelerate.

Company News
Replit is integrating Socket Firewall into its AI-powered development experience to help protect builders from malicious open source packages.