mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-11 22:13:20 +03:00
78be4b55c9
no-issue This is only ever used in this directory so it makes sense to be colocated.
42 lines
663 B
JavaScript
42 lines
663 B
JavaScript
/**
|
|
* @template T
|
|
*/
|
|
class ValueObject {
|
|
/** @type {{value: T}} */
|
|
props
|
|
|
|
/** @type T */
|
|
get value() {
|
|
return this.props.value;
|
|
}
|
|
|
|
/**
|
|
* @protected
|
|
* @param {T} value
|
|
*/
|
|
constructor(value) {
|
|
/** @private */
|
|
this.props = {value};
|
|
}
|
|
|
|
/**
|
|
* @param {any} other
|
|
* @returns {boolean}
|
|
*/
|
|
equals(other) {
|
|
if (this === other) {
|
|
return true;
|
|
}
|
|
|
|
if (other instanceof ValueObject) {
|
|
if (this.value === other.value) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
module.exports = ValueObject;
|