Socket
Book a DemoInstallSign in
Socket

eventric-store-inmemory

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventric-store-inmemory - npm Package Compare versions

Comparing version

to
0.3.0

90

build/src/inmemory_store.js
var InMemoryStore;
InMemoryStore = (function() {
InMemoryStore.prototype.domainEventSequence = {
currentDomainEventId: 1
};
function InMemoryStore() {
this._domainEvents = {};
this._projections = {};
this._domainEventIdCounter = 1;
this._domainEvents = [];
}

@@ -15,4 +17,2 @@

_this._domainEventsCollectionName = _this._context.name + ".DomainEvents";
_this._projectionCollectionName = _this._context.name + ".Projections";
_this._domainEvents[_this._domainEventsCollectionName] = [];
return resolve();

@@ -26,4 +26,4 @@ };

return function(resolve) {
domainEvent.id = _this._domainEventIdCounter++;
_this._domainEvents[_this._domainEventsCollectionName].push(domainEvent);
domainEvent.id = _this.domainEventSequence.currentDomainEventId++;
_this._domainEvents.push(domainEvent);
return resolve(domainEvent);

@@ -34,15 +34,9 @@ };

InMemoryStore.prototype.findDomainEventsByName = function(name, callback) {
var checkFn, events;
if (name instanceof Array) {
checkFn = function(eventName) {
return (name.indexOf(eventName)) > -1;
};
} else {
checkFn = function(eventName) {
return eventName === name;
};
InMemoryStore.prototype.findDomainEventsByName = function(domainEventNames, callback) {
var events;
if (!(domainEventNames instanceof Array)) {
domainEventNames = [domainEventNames];
}
events = this._domainEvents[this._domainEventsCollectionName].filter(function(event) {
return checkFn(event.name);
events = this._domainEvents.filter(function(domainEvent) {
return domainEventNames.indexOf(domainEvent.name) > -1;
});

@@ -52,47 +46,31 @@ return callback(null, events);

InMemoryStore.prototype.findDomainEventsByNameAndAggregateId = function(name, aggregateId, callback) {
var checkAggregateIdFn, checkNameFn, events;
if (name instanceof Array) {
checkNameFn = function(eventName) {
return (name.indexOf(eventName)) > -1;
};
} else {
checkNameFn = function(eventName) {
return eventName === name;
};
InMemoryStore.prototype.findDomainEventsByAggregateId = function(aggregateIds, callback) {
var domainEvents;
if (!(aggregateIds instanceof Array)) {
aggregateIds = [aggregateIds];
}
if (aggregateId instanceof Array) {
checkAggregateIdFn = function(eventAggregateId) {
return (aggregateId.indexOf(eventAggregateId)) > -1;
};
} else {
checkAggregateIdFn = function(eventAggregateId) {
return eventAggregateId === aggregateId;
};
}
events = this._domainEvents[this._domainEventsCollectionName].filter(function(event) {
var ref;
return (checkNameFn(event.name)) && (checkAggregateIdFn((ref = event.aggregate) != null ? ref.id : void 0));
domainEvents = this._domainEvents.filter(function(domainEvent) {
return aggregateIds.indexOf(domainEvent.aggregate.id) > -1;
});
return callback(null, events);
return callback(null, domainEvents);
};
InMemoryStore.prototype.findDomainEventsByAggregateId = function(aggregateId, callback) {
var checkFn, events;
if (aggregateId instanceof Array) {
checkFn = function(eventAggregateId) {
return (aggregateId.indexOf(eventAggregateId)) > -1;
};
} else {
checkFn = function(eventAggregateId) {
return eventAggregateId === aggregateId;
};
InMemoryStore.prototype.findDomainEventsByNameAndAggregateId = function(domainEventNames, aggregateIds, callback) {
var domainEvents;
if (!(domainEventNames instanceof Array)) {
domainEventNames = [domainEventNames];
}
events = this._domainEvents[this._domainEventsCollectionName].filter(function(event) {
var ref;
return checkFn((ref = event.aggregate) != null ? ref.id : void 0);
if (!(aggregateIds instanceof Array)) {
aggregateIds = [aggregateIds];
}
domainEvents = this._domainEvents.filter(function(domainEvent) {
return domainEventNames.indexOf(domainEvent.name) > -1 && aggregateIds.indexOf(domainEvent.aggregate.id) > -1;
});
return callback(null, events);
return callback(null, domainEvents);
};
InMemoryStore.prototype.destroy = function() {
return Promise.resolve();
};
return InMemoryStore;

@@ -99,0 +77,0 @@

{
"name": "eventric-store-inmemory",
"version": "0.2.2",
"version": "0.3.0",
"description": "eventric inmemory store adapter",

@@ -21,6 +21,5 @@ "main": "build/src/inmemory_store.js",

"del": "2.2.1",
"eventric-store-specs": "1.1.0",
"eventric-store-specs": "2.0.0",
"gulp": "3.9.1",
"gulp-coffee": "2.3.2",
"gulp-exit": "0.0.2",
"gulp-util": "3.0.7",

@@ -27,0 +26,0 @@ "gulp-mocha": "3.0.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet