@glandjs/emitter@1.1.5
Changelog — @glandjs/emitter
Release history for @glandjs/emitter, mirrored from the repository.
All notable changes to @glandjs/emitter will be documented in this file. This project follows Keep a Changelog and adheres to Semantic Versioning.
Entries are listed newest first.
[1.1.5] – 2026-10-03
Section titled “[1.1.5] – 2026-10-03”- Tree nodes now have a single shape. A node used to be an array when it was a leaf and a plain object when it was a branch, so a segment that was both a leaf and a prefix ended up as an array carrying extra keys. Registering the branch before its leaf threw
TypeError: node[part].push is not a function, andoffcould prune a subtree that still held live listeners. Every segment is now a node with its ownlistenersandchildren, which makes registration order irrelevant and keepsofffrom touching sibling branches. - Event names that exist on
Object.prototypeare safe.rootandcacheare null-prototype maps, soon('constructor'),on('__proto__')andemit('toString')no longer throw or resolve to an inherited member. - Emitting a literal
*fires once.emit('a:*')used to match both the exact subscription and the wildcard branch, invoking each listener twice. A literal*segment now matches only the exact branch. - The build succeeds again.
cachewas inferred as{}, so indexing it with a generic key failed to compile.bun run buildexited non-zero, which left the publisheddist/stale and made the suite unrunnable on a fresh clone. - The test script and the test filename.
bun test ./tests/*did not match on Windows shells, andemitter.integration.tsdid not follow Bun’s test-file naming convention. The suite now runs viabun test testsagainsttests/emitter.test.ts. - Benchmark methodology. The measured callback was awaited on every iteration, adding microtask overhead to a synchronous emitter and understating throughput by roughly 6x. The
awaitis gone, and a cache-sizing scenario was added so the eviction cliff stays visible.
Changed
Section titled “Changed”maxCacheSizenow defaults to64instead of6. Once the number of live event names exceeded the cache, LRU eviction sent every emit back to a tree walk: at 10 distinct events the old default measured ~112K ops/sec against ~3.6M ops/sec at 64. Pass a smaller value explicitly to restore the previous default. See the API reference.- The tree root was renamed from
treetoroot. Combined with the names introduced in 1.1.1, the current internal fields areroot,cache,id,maxCacheSizeandspliter— the last is misspelled in the source, not here. The single-letter names in the 1.1.0 entry below are a historical record of that release. - The suite grew from 5 to 34 cases, covering registration order, wildcard resolution, prototype-chain names, cache invalidation, mutation during emit and edge cases.
Unchanged
Section titled “Unchanged”- The public API is still
on,off,emit. - A listener that throws still propagates to the caller of
emitand skips the remaining listeners, matching Node’s ownEventEmitter. - Wildcards still match exactly one segment.
[1.1.4] – 2025-05-04
Section titled “[1.1.4] – 2025-05-04”-
mainandexportsinpackage.json.1.1.2dropped every entry-point field when it switched to a CommonJS build, and1.1.3restored onlymoduleandtypes. Withoutmainorexports, neither Node nor a bundler could locatedist/index.js. Both conditions now resolve to the single CommonJS entry:{"main": "./dist/index.js","exports": {".": {"import": "./dist/index.js","require": "./dist/index.js"}}}
[1.1.3] – 2025-05-04
Section titled “[1.1.3] – 2025-05-04”moduleandtypesinpackage.json, both pointing at thetscoutput. This restores the resolution hints that 1.1.2 removed, and is what lets TypeScript find the declarations.mainwas still absent at this point, which is what 1.1.4 fixed.
1.1.2, 1.1.3 and 1.1.4 were published within half an hour of each other. They are kept as separate entries because each is a distinct published version; read them together as one repair of the entry points broken in 1.1.2.
[1.1.2] – 2025-05-04
Section titled “[1.1.2] – 2025-05-04”Changed
Section titled “Changed”- Replaced Bun’s ESM-based build with a TypeScript-only CommonJS (
CJS) output to improve compatibility with Node.js and CommonJS environments. - Removed
bun buildfrom the build pipeline in favor of standardtsccompilation. - Updated
tsconfig.json:- Set
moduletoCommonJS - Changed
targettoES2021 - Removed unused or Bun-specific options (
moduleResolution: bundler,verbatimModuleSyntax, etc.)
- Set
- Removed
"type": "module"and"module"fields frompackage.json. - Output still located in
dist/, includes.jsand.d.ts. - Tightened the
offcleanup loop with non-null assertions sotsccompiles it understrict.
This release makes the package easier to consume in broader tooling and ecosystem setups (e.g., Jest, Node.js, older bundlers) while maintaining all functionality and TypeScript type support.
Dropping "type": "module" without adding a CommonJS entry point left the manifest with no way to resolve dist/index.js. 1.1.3 and 1.1.4 restored that.
[1.1.1] – 2025-04-27
Section titled “[1.1.1] – 2025-04-27”Changed
Section titled “Changed”- No functional changes.
- Renamed the internal fields for readability:
t→tree,c→cache,i→id,m→maxCacheSize, andd→spliter. The behavior and the state shape shown in the 1.1.0 entry below are unchanged; only the property names differ. - Added a
.prettierrcand reformatted the source.
[1.1.0] – 2025-04-26
Section titled “[1.1.0] – 2025-04-26”- Tree-based internal storage
Events are now organized in a nested tree under the emitter’s
tproperty, reflecting hierarchical namespaces (e.g.user:login→t.user.login) and enabling faster lookup for deeply namespaced events. - Hot-path LRU cache
By default the emitter now keeps a small, fixed-size cache (
c) of the 6 most-frequently-used events, with a true LRU eviction policy. Each cache entry tracks:f: array of listener functionst: a value from the emitter’s monotonic counter, used to order the cache
- Introspectable state dump
Logging the emitter instance now prints its full internal shape:
{t: { … }, // tree of all registered listenersc: { … }, // hot-path cache entriesi: 2, // monotonic counter, last value handed to a cache entrym: 6, // cache capacityd: ':', // delimiteron, off, emit}
- A throwing listener now propagates. 1.0.0-alpha logged listener errors and 1.0.0 swallowed them silently. From this release
emitlets the error reach the caller and skips the remaining listeners, matching Node’s ownEventEmitter.
Changed
Section titled “Changed”- Bundle size increased from ~0.77 KB (minified) to ~1.2 KB to accommodate the new tree structure and LRU cache.
- Internal fields renamed for clarity:
t(tree root)c(cache map)i(monotonic counter used to order the cache)m(cache max size)d(segment delimiter)
Performance
Section titled “Performance”- Fast path for hot events: emits for cached events bypass full tree traversal. A cache hit is a single property read; a miss walks the tree and then pays a linear scan of at most
mkeys to evict. - The tree makes
onandoffproportional to the depth of the event name.offadditionally checks whether a node is empty before pruning it, which is linear in that node’s child count.
[1.0.0] – 2025-04-26
Section titled “[1.0.0] – 2025-04-26”- Initial stable release of the
@glandjs/emitterpackage - Core API with fully typed methods:
on,off, andemit - Efficient event pattern matching with delimiter-based wildcards (e.g.,
user:*,data:*:changed) - Custom delimiter support via constructor parameter
- Performance optimizations:
- Fast listener lookup with Map-based storage
- Method chaining support for fluent API usage
- Comprehensive TypeScript type definitions for enhanced developer experience
- Zero dependencies with minimal bundle size (0.77 KB minified)
- Designed for both Gland internal usage and standalone applications
- Fully tested
Changed
Section titled “Changed”- Dropped the
asyncoption ononandemit, along with its timeout. Dispatch is synchronous. - Dropped the options-object constructor from 1.0.0-alpha. The constructor now takes the delimiter directly,
new EventEmitter('-'). - Dropped the
maxListenersandverboseMemoryLeakoptions. There is no listener budget and no leak warning.
A listener that throws is swallowed by an empty catch block in this release. It propagates from 1.1.0 onward.
Wildcards here are not segment-aware in the way later releases are: * is stripped from the name, and the empty segment it leaves behind matches any value, provided the name has the same number of segments.
[1.0.0-alpha] – 2025-04-25
Section titled “[1.0.0-alpha] – 2025-04-25”- Initial release of
@glandjs/emitter, a small event emitter written in TypeScript. - Core API:
on,off, andemit, all strongly typed. - Wildcard subscriptions, kept in a separate map keyed by a wildcard key in which each segment collapses to
*or#, and matched segment by segment against the emitted name. Pattern-match results were memoized per pattern. - Options object on the constructor:
delimiter,maxListenersandverboseMemoryLeak. - An
asyncoption ononandemitthat resolved through a promise and accepted a timeout. - A throwing listener was caught and logged with
console.error. - Zero dependencies, and usable standalone.
Every item above was reworked or removed before 1.0.0. Treat this alpha as a preview of the API shape, not of the implementation.