27 lines
535 B
JavaScript
27 lines
535 B
JavaScript
/**
|
|
* @module utils
|
|
*/
|
|
|
|
import { Y } from '../utils/Y.mjs' // eslint-disable-line
|
|
import { Type } from '../structs/Type.mjs' // eslint-disable-line
|
|
|
|
/**
|
|
* Check if `parent` is a parent of `child`.
|
|
*
|
|
* @param {Type | Y} parent
|
|
* @param {Type | Y} child
|
|
* @return {Boolean} Whether `parent` is a parent of `child`.
|
|
*
|
|
* @public
|
|
*/
|
|
export const isParentOf = (parent, child) => {
|
|
child = child._parent
|
|
while (child !== null) {
|
|
if (child === parent) {
|
|
return true
|
|
}
|
|
child = child._parent
|
|
}
|
|
return false
|
|
}
|