@mzedeler/fast-aria-query
v5.3.6
Published
Fast drop-in replacement for aria-query with proper TypeScript types
Readme
@mzedeler/fast-aria-query
A fast-loading drop-in replacement for aria-query with the same API and built-in TypeScript types.
Why?
aria-query performs significant computation at module load time: resolving role superclass inheritance, building element-to-role and role-to-element indexes, and setting up iteration decorators. This work runs every time the module is imported.
@mzedeler/fast-aria-query moves all of that computation to install time. A postinstall script snapshots the fully-computed data into a static file. At runtime, the module simply loads the pre-computed data and wraps it in a lightweight map interface - no inheritance resolution, no index building, no repeated work.
Installation
npm install @mzedeler/fast-aria-queryUsage
The API is identical to aria-query. You can use it as a direct replacement:
import { roles, aria, dom, elementRoles, roleElements } from '@mzedeler/fast-aria-query'
// All the same map-like methods work
roles.get('button') // ARIARoleDefinition
roles.has('button') // true
roles.keys() // ARIARoleDefinitionKey[]
roles.values() // ARIARoleDefinition[]
roles.entries() // [ARIARoleDefinitionKey, ARIARoleDefinition][]
roles.forEach((def, key) => { /* ... */ })
for (const [key, def] of roles) { /* ... */ }All five maps are available: aria, dom, roles, elementRoles, and roleElements.
TypeScript
Types are included — no need for @types/aria-query. All ARIA role, property, and state types are exported:
import type {
ARIARole,
ARIARoleDefinitionKey,
ARIARoleDefinition,
ARIAProperty,
ARIAPropertyDefinition,
// ... and more
} from '@mzedeler/fast-aria-query'Benchmark
You can verify the speedup yourself:
npm run benchmarkTypical results (200 iterations, Node.js, cold require per iteration):
| Module | Median | Mean | p95 |
|--------|--------|------|-----|
| aria-query | 35.82 ms | 36.01 ms | 38.06 ms |
| @mzedeler/fast-aria-query | 5.67 ms | 5.79 ms | 6.61 ms |
| Speedup | 6.3x | | |
Versioning
Package versions are locked to the corresponding aria-query version. For example, @mzedeler/[email protected] contains the data from [email protected].
License
ISC
