mirror of
https://github.com/morluto/rea.git
synced 2026-11-16 03:33:25 +00:00
* refactor(native): report bounded string reads that stop at their allowance as decode limits * fix(verify): count generic and multi-line plain-Error limit classes
11 lines
525 B
JavaScript
11 lines
525 B
JavaScript
// Counts local limit classes declared on plain Error: a class whose name has
|
|
// Limit, Budget, Exhausted or Exceeded and that extends Error directly. Type
|
|
// parameters and line breaks between tokens are allowed, as a formatter or a
|
|
// generic declaration may write them.
|
|
const localLimitClass =
|
|
/\bclass\s+\w*(?:Limit|Budget|Exhausted|Exceeded)\w*\s*(?:<[^{]*?>)?\s*extends\s+Error\b/gu;
|
|
|
|
/** @param {string} content */
|
|
export const localLimitErrorClassCount = (content) =>
|
|
content.match(localLimitClass)?.length ?? 0;
|