feat(List)

This commit is contained in:
2025-04-08 21:08:25 +03:00
commit 56be57ada1
12 changed files with 1942 additions and 0 deletions

34
src/utils/concept.js Normal file
View File

@ -0,0 +1,34 @@
export function satisfiesConcept(obj, pure_virtual, virtual, debug) {
if (typeof obj !== 'object' || obj === null) {
return false;
}
if (debug) {
const missingMethods = []
pure_virtual.forEach((method) => {
if (typeof obj[method] !== 'function') {
missingMethods.push(method)
}
})
virtual.forEach((method) => {
if (!(method in obj)) {
missingMethods.push(method)
}
})
if (missingMethods.length !== 0) {
console.debug(obj.constructor.name, missingMethods)
return false
}
} else {
if (!pure_virtual.every((method) => typeof obj[method] === 'function')) {
return false;
}
if (!virtual.every((method) => method in obj)) {
return false;
}
}
return true
}