@event-driven-io/emmett 0.43.0-beta.20 → 0.43.0-beta.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1742,14 +1742,16 @@ const DATABASE_REQUIRED_ERROR_MESSAGE = "Database is required in context for InM
1742
1742
  */
1743
1743
  const handleInMemoryProjections = async (options) => {
1744
1744
  const { projections, events, database, eventStore, observability } = options;
1745
- const eventTypes = events.map((e) => e.type);
1746
- const relevantProjections = projections.filter((p) => p.canHandle.some((type) => eventTypes.includes(type)));
1747
1745
  const { startScope } = (0, _event_driven_io_almanac.ObservabilityScope)(observability);
1748
- for (const projection of relevantProjections) await startScope("eventStore.inlineProjection", async (observabilityScope) => projection.handle(events, {
1749
- eventStore,
1750
- database,
1751
- observabilityScope
1752
- }));
1746
+ for (const projection of projections) {
1747
+ const filteredEvents = events.filter(({ type }) => projection.canHandle.includes(type));
1748
+ if (filteredEvents.length === 0) continue;
1749
+ await startScope("eventStore.inlineProjection", async (observabilityScope) => projection.handle(filteredEvents, {
1750
+ eventStore,
1751
+ database,
1752
+ observabilityScope
1753
+ }));
1754
+ }
1753
1755
  };
1754
1756
  /**
1755
1757
  * Creates an InMemory projection