ddd-es-node
Advanced tools
Comparing version 0.0.14 to 0.0.15
export declare module Clock { | ||
function freeze(at: number): void; | ||
function freeze(at?: number): void; | ||
function unfreeze(): void; | ||
function now(): number; | ||
} |
@@ -6,3 +6,3 @@ "use strict"; | ||
(function (Clock) { | ||
function freeze(at) { | ||
function freeze(at = 0) { | ||
time = at; | ||
@@ -9,0 +9,0 @@ } |
@@ -0,1 +1,3 @@ | ||
export declare const useIncrementalUUID: (value: boolean) => void; | ||
export declare const uuid: () => string; | ||
export declare class EntityEvent { | ||
@@ -59,3 +61,1 @@ uuid: string; | ||
} | ||
export declare const useIncrementalUUID: (value: boolean) => void; | ||
export declare const uuid: () => string; |
@@ -5,5 +5,13 @@ "use strict"; | ||
const index_1 = require("./../index"); | ||
let incrementalUUID = false; | ||
let uidCount = 0; | ||
exports.useIncrementalUUID = (value) => { | ||
incrementalUUID = value; | ||
}; | ||
exports.uuid = () => { | ||
return incrementalUUID ? `${uidCount++}` : uuid_1.v4(); | ||
}; | ||
class EntityEvent { | ||
constructor() { | ||
this.uuid = uuid_1.v4(); | ||
this.uuid = exports.uuid(); | ||
this.typeNameMetaData = this.constructor.name; | ||
@@ -102,10 +110,2 @@ this.name = this.typeNameMetaData; | ||
exports.Entity = Entity; | ||
let incrementalUUID = false; | ||
let uidCount = 0; | ||
exports.useIncrementalUUID = (value) => { | ||
incrementalUUID = value; | ||
}; | ||
exports.uuid = () => { | ||
return incrementalUUID ? `${uidCount++}` : uuid_1.v4(); | ||
}; | ||
//# sourceMappingURL=entity.js.map |
@@ -1,3 +0,7 @@ | ||
export { Entity, EntityRepository, EntityEvent, EventBus, EventBusSubscription, EventDispatcher, EventHandler, EventProcessor, EventStore, BaseEntityRepository, uuid, useIncrementalUUID } from './core/entity'; | ||
export { Clock } from './core/clock'; | ||
import { Clock } from './core/clock'; | ||
import { useIncrementalUUID } from './core/entity'; | ||
export { Entity, EntityRepository, EntityEvent, EventBus, EventBusSubscription, EventDispatcher, EventHandler, EventProcessor, EventStore, BaseEntityRepository, uuid } from './core/entity'; | ||
export { useIncrementalUUID }; | ||
export { Clock }; | ||
export { eventBus, entityRepository, eventStore } from './runtime/es'; | ||
export declare const testMode: (value: boolean) => void; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var entity_1 = require("./core/entity"); | ||
exports.Entity = entity_1.Entity; | ||
exports.EntityEvent = entity_1.EntityEvent; | ||
exports.EventProcessor = entity_1.EventProcessor; | ||
exports.BaseEntityRepository = entity_1.BaseEntityRepository; | ||
exports.uuid = entity_1.uuid; | ||
const clock_1 = require("./core/clock"); | ||
exports.Clock = clock_1.Clock; | ||
const entity_1 = require("./core/entity"); | ||
exports.useIncrementalUUID = entity_1.useIncrementalUUID; | ||
var clock_1 = require("./core/clock"); | ||
exports.Clock = clock_1.Clock; | ||
var entity_2 = require("./core/entity"); | ||
exports.Entity = entity_2.Entity; | ||
exports.EntityEvent = entity_2.EntityEvent; | ||
exports.EventProcessor = entity_2.EventProcessor; | ||
exports.BaseEntityRepository = entity_2.BaseEntityRepository; | ||
exports.uuid = entity_2.uuid; | ||
var es_1 = require("./runtime/es"); | ||
@@ -16,2 +17,12 @@ exports.eventBus = es_1.eventBus; | ||
exports.eventStore = es_1.eventStore; | ||
exports.testMode = (value) => { | ||
if (value === undefined ? true : value) { | ||
clock_1.Clock.freeze(); | ||
entity_1.useIncrementalUUID(true); | ||
} | ||
else { | ||
clock_1.Clock.unfreeze(); | ||
entity_1.useIncrementalUUID(false); | ||
} | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "ddd-es-node", | ||
"version": "0.0.14", | ||
"version": "0.0.15", | ||
"description": "ddd-es-node", | ||
@@ -5,0 +5,0 @@ "main": "./dist/src/index.js", |
@@ -5,3 +5,3 @@ let time : number = -1; | ||
export function freeze(at : number) : void { | ||
export function freeze(at : number = 0) : void { | ||
time = at; | ||
@@ -8,0 +8,0 @@ } |
import { v4 } from 'uuid'; | ||
import { Clock } from './../index'; | ||
let incrementalUUID : boolean = false; | ||
let uidCount : number = 0; | ||
export const useIncrementalUUID = (value : boolean) => { | ||
incrementalUUID = value; | ||
}; | ||
export const uuid = () : string => { | ||
return incrementalUUID ? `${uidCount++}` : v4(); | ||
}; | ||
export class EntityEvent { | ||
@@ -12,3 +23,3 @@ public uuid : string; | ||
constructor() { | ||
this.uuid = v4(); | ||
this.uuid = uuid(); | ||
this.typeNameMetaData = this.constructor.name; | ||
@@ -158,12 +169,1 @@ this.name = this.typeNameMetaData; | ||
} | ||
let incrementalUUID : boolean = false; | ||
let uidCount : number = 0; | ||
export const useIncrementalUUID = (value : boolean) => { | ||
incrementalUUID = value; | ||
}; | ||
export const uuid = () : string => { | ||
return incrementalUUID ? `${uidCount++}` : v4(); | ||
}; |
@@ -0,1 +1,9 @@ | ||
import { | ||
Clock | ||
} from './core/clock'; | ||
import { | ||
useIncrementalUUID | ||
} from './core/entity'; | ||
export { | ||
@@ -12,9 +20,12 @@ Entity, | ||
BaseEntityRepository, | ||
uuid, | ||
useIncrementalUUID | ||
uuid | ||
} from './core/entity'; | ||
export { | ||
useIncrementalUUID | ||
}; | ||
export { | ||
Clock | ||
} from './core/clock'; | ||
}; | ||
@@ -26,1 +37,11 @@ export { | ||
} from './runtime/es'; | ||
export const testMode = (value : boolean) => { | ||
if (value === undefined ? true : value) { | ||
Clock.freeze(); | ||
useIncrementalUUID(true); | ||
} else { | ||
Clock.unfreeze(); | ||
useIncrementalUUID(false); | ||
} | ||
}; |
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
66201
36
1467