Attributes initialization refactoring (#19)

This commit is contained in:
barsdeveloper
2024-03-24 17:30:50 +01:00
committed by GitHub
parent 5973570911
commit cc9e3d833a
93 changed files with 4134 additions and 4082 deletions

View File

@@ -189,6 +189,12 @@ export default class Utility {
* @param {Attribute} b
*/
static equals(a, b) {
while (a instanceof MirroredEntity) {
a = a.get()
}
while (b instanceof MirroredEntity) {
b = b.get()
}
// Here we cannot check both instanceof IEntity because this would introduce a circular include dependency
if (/** @type {IEntity?} */(a)?.equals && /** @type {IEntity?} */(b)?.equals) {
return /** @type {IEntity} */(a).equals(/** @type {IEntity} */(b))
@@ -423,6 +429,11 @@ export default class Utility {
return Array.from({ length: Math.ceil((end - begin) / step) }, (_, i) => begin + (i * step))
}
/** @param {String[]} words */
static getFirstWordOrder(words) {
return new RegExp(/\s*/.source + words.join(/[^\n]+\n\s*/.source) + /\s*/.source)
}
/**
* @param {HTMLElement} element
* @param {String} value