@piggly/ddd-toolkit
Advanced tools
Comparing version 3.3.1 to 3.3.2
@@ -66,2 +66,32 @@ "use strict"; | ||
/** | ||
* Append a raw item to the collection. | ||
* Will replace no matter what. | ||
* | ||
* @param {OptionalEntity<Entity, ID>} item | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.0 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
appendRaw(item) { | ||
this._items.set(this.idToKey(item.id), item); | ||
return this; | ||
} | ||
/** | ||
* Append an array of raw items to the collection. | ||
* Will replace no matter what. | ||
* | ||
* @param {Array<OptionalEntity<Entity, ID>>} items | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.0 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
appendManyRaw(items) { | ||
items.forEach(item => this.appendRaw(item)); | ||
return this; | ||
} | ||
/** | ||
* Reload an item to the collection. Only if the item is already in the collection. | ||
@@ -68,0 +98,0 @@ * |
@@ -62,4 +62,20 @@ "use strict"; | ||
} | ||
/** | ||
* Clone the collection. | ||
* | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
clone() { | ||
const collection = new CollectionOfEntity(); | ||
this._items.forEach(item => { | ||
collection.appendRaw(item.clone()); | ||
}); | ||
return collection; | ||
} | ||
} | ||
exports.CollectionOfEntity = CollectionOfEntity; | ||
//# sourceMappingURL=CollectionOfEntity.js.map |
@@ -10,4 +10,20 @@ "use strict"; | ||
class CollectionOfRelatedEnhancedEntity extends CollectionOfEntity_1.CollectionOfEntity { | ||
/** | ||
* Clone the collection. | ||
* | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
clone() { | ||
const collection = new CollectionOfRelatedEnhancedEntity(); | ||
this._items.forEach(item => { | ||
collection.appendRaw(item.clone()); | ||
}); | ||
return collection; | ||
} | ||
} | ||
exports.CollectionOfRelatedEnhancedEntity = CollectionOfRelatedEnhancedEntity; | ||
//# sourceMappingURL=CollectionOfRelatedEnhancedEntity.js.map |
@@ -10,4 +10,20 @@ "use strict"; | ||
class CollectionOfRelatedEntity extends CollectionOfEntity_1.CollectionOfEntity { | ||
/** | ||
* Clone the collection. | ||
* | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
clone() { | ||
const collection = new CollectionOfRelatedEntity(); | ||
this._items.forEach(item => { | ||
collection.appendRaw(item.clone()); | ||
}); | ||
return collection; | ||
} | ||
} | ||
exports.CollectionOfRelatedEntity = CollectionOfRelatedEntity; | ||
//# sourceMappingURL=CollectionOfRelatedEntity.js.map |
@@ -140,2 +140,14 @@ "use strict"; | ||
/** | ||
* Clone the optional entity. | ||
* | ||
* @returns {OptionalEntity<Entity, ID>} The cloned optional entity. | ||
* @public | ||
* @memberof OptionalEntity | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
clone() { | ||
return new OptionalEntity(this._pack.id, this._pack.entity); | ||
} | ||
/** | ||
* Check if the entity is equal to another entity. | ||
@@ -142,0 +154,0 @@ * |
@@ -63,2 +63,32 @@ import { OptionalEntity } from './OptionalEntity.js'; | ||
/** | ||
* Append a raw item to the collection. | ||
* Will replace no matter what. | ||
* | ||
* @param {OptionalEntity<Entity, ID>} item | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.0 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
appendRaw(item) { | ||
this._items.set(this.idToKey(item.id), item); | ||
return this; | ||
} | ||
/** | ||
* Append an array of raw items to the collection. | ||
* Will replace no matter what. | ||
* | ||
* @param {Array<OptionalEntity<Entity, ID>>} items | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.0 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
appendManyRaw(items) { | ||
items.forEach(item => this.appendRaw(item)); | ||
return this; | ||
} | ||
/** | ||
* Reload an item to the collection. Only if the item is already in the collection. | ||
@@ -65,0 +95,0 @@ * |
@@ -59,3 +59,19 @@ import { AbstractCollectionOfEntities } from './AbstractCollectionOfEntities.js'; | ||
} | ||
/** | ||
* Clone the collection. | ||
* | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
clone() { | ||
const collection = new CollectionOfEntity(); | ||
this._items.forEach(item => { | ||
collection.appendRaw(item.clone()); | ||
}); | ||
return collection; | ||
} | ||
} | ||
//# sourceMappingURL=CollectionOfEntity.js.map |
@@ -7,3 +7,19 @@ import { CollectionOfEntity } from './CollectionOfEntity.js'; | ||
export class CollectionOfRelatedEnhancedEntity extends CollectionOfEntity { | ||
/** | ||
* Clone the collection. | ||
* | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
clone() { | ||
const collection = new CollectionOfRelatedEnhancedEntity(); | ||
this._items.forEach(item => { | ||
collection.appendRaw(item.clone()); | ||
}); | ||
return collection; | ||
} | ||
} | ||
//# sourceMappingURL=CollectionOfRelatedEnhancedEntity.js.map |
@@ -7,3 +7,19 @@ import { CollectionOfEntity } from './CollectionOfEntity.js'; | ||
export class CollectionOfRelatedEntity extends CollectionOfEntity { | ||
/** | ||
* Clone the collection. | ||
* | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
clone() { | ||
const collection = new CollectionOfRelatedEntity(); | ||
this._items.forEach(item => { | ||
collection.appendRaw(item.clone()); | ||
}); | ||
return collection; | ||
} | ||
} | ||
//# sourceMappingURL=CollectionOfRelatedEntity.js.map |
@@ -137,2 +137,14 @@ import { EntityIdMismatchError } from './errors/EntityIdMismatchError.js'; | ||
/** | ||
* Clone the optional entity. | ||
* | ||
* @returns {OptionalEntity<Entity, ID>} The cloned optional entity. | ||
* @public | ||
* @memberof OptionalEntity | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
clone() { | ||
return new OptionalEntity(this._pack.id, this._pack.entity); | ||
} | ||
/** | ||
* Check if the entity is equal to another entity. | ||
@@ -139,0 +151,0 @@ * |
import type { EntityID } from './EntityID'; | ||
import type { IEntity } from './types'; | ||
import { OptionalEntity } from './OptionalEntity'; | ||
import type { IEntity } from './types'; | ||
/** | ||
@@ -53,2 +53,26 @@ * @file A collection of something. | ||
/** | ||
* Append a raw item to the collection. | ||
* Will replace no matter what. | ||
* | ||
* @param {OptionalEntity<Entity, ID>} item | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.0 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
appendRaw(item: OptionalEntity<Entity, ID>): this; | ||
/** | ||
* Append an array of raw items to the collection. | ||
* Will replace no matter what. | ||
* | ||
* @param {Array<OptionalEntity<Entity, ID>>} items | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.0 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
appendManyRaw(items: Array<OptionalEntity<Entity, ID>>): this; | ||
/** | ||
* Reload an item to the collection. Only if the item is already in the collection. | ||
@@ -349,2 +373,12 @@ * | ||
/** | ||
* Clone the collection. | ||
* | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
abstract clone(): AbstractCollectionOfEntities<Key, Entity, ID>; | ||
/** | ||
* Get the key for an item. | ||
@@ -351,0 +385,0 @@ * |
@@ -53,2 +53,12 @@ import { AbstractCollectionOfEntities } from './AbstractCollectionOfEntities'; | ||
protected idToKey(id: ID): string; | ||
/** | ||
* Clone the collection. | ||
* | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
clone(): CollectionOfEntity<Entity, ID>; | ||
} |
@@ -9,2 +9,12 @@ import { CollectionOfEntity } from './CollectionOfEntity'; | ||
export declare class CollectionOfRelatedEnhancedEntity<Entity extends IEntity<ID>, ID extends EntityID<any> = EntityID<any>> extends CollectionOfEntity<Entity, ID> { | ||
/** | ||
* Clone the collection. | ||
* | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
clone(): CollectionOfRelatedEnhancedEntity<Entity, ID>; | ||
} |
@@ -9,2 +9,12 @@ import type { EntityID } from './EntityID'; | ||
export declare class CollectionOfRelatedEntity<Entity extends IEntity<ID>, ID extends EntityID<any> = EntityID<any>> extends CollectionOfEntity<Entity, ID> { | ||
/** | ||
* Clone the collection. | ||
* | ||
* @returns {this} | ||
* @public | ||
* @memberof AbstractCollectionOfEntities | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
clone(): CollectionOfRelatedEntity<Entity, ID>; | ||
} |
@@ -112,2 +112,12 @@ import { EntityID } from './EntityID'; | ||
/** | ||
* Clone the optional entity. | ||
* | ||
* @returns {OptionalEntity<Entity, ID>} The cloned optional entity. | ||
* @public | ||
* @memberof OptionalEntity | ||
* @since 3.3.2 | ||
* @author Caique Araujo <caique@piggly.com.br> | ||
*/ | ||
clone(): OptionalEntity<Entity, ID>; | ||
/** | ||
* Check if the entity is equal to another entity. | ||
@@ -114,0 +124,0 @@ * |
{ | ||
"name": "@piggly/ddd-toolkit", | ||
"version": "3.3.1", | ||
"version": "3.3.2", | ||
"description": "A bunch of tools to use Model-Driven Design and Domain-Driven Design architecture in a back-end application.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
357550
9426