Merge branch 'master' into mrazator/scene-static-methods-removal

This commit is contained in:
Marcel Mraz 2025-04-23 13:16:53 +02:00
commit d438cdf83a
No known key found for this signature in database
GPG key ID: 4EBD6E62DC830CD2
29 changed files with 741 additions and 644 deletions

View file

@ -1218,3 +1218,18 @@ export const elementCenterPoint = (
return pointFrom<GlobalPoint>(centerXPoint, centerYPoint);
};
/** hack for Array.isArray type guard not working with readonly value[] */
export const isReadonlyArray = (value?: any): value is readonly any[] => {
return Array.isArray(value);
};
export const sizeOf = (
value: readonly number[] | Readonly<Map<any, any>> | Record<any, any>,
): number => {
return isReadonlyArray(value)
? value.length
: value instanceof Map
? value.size
: Object.keys(value).length;
};