digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.66k stars 195 forks source link

Add event handler #366

Open davidlehn opened 4 years ago

davidlehn commented 4 years ago
davidlehn commented 4 years ago

Some rambling thoughts on this patch:

davidlehn commented 4 years ago

Some of the events happen in createTermDefinition. If event handlers were to be async, we'd have to make that async, and callers like _expandIri async, and maybe others up the stack. I was afraid that might have performance effects, but I didn't check. Another case where the in-progress benchmarking code needs to be improved so we can test such changes. I figured for version 1 the handlers could be sync and if we change to async/await in the future, they'll still work.

codecov-commenter commented 2 years ago

Codecov Report

Merging #366 (1ebcc1f) into main (b7bc6d6) will increase coverage by 0.70%. The diff coverage is 94.44%.

@@            Coverage Diff             @@
##             main     #366      +/-   ##
==========================================
+ Coverage   92.67%   93.37%   +0.70%     
==========================================
  Files          23       24       +1     
  Lines        2880     2899      +19     
==========================================
+ Hits         2669     2707      +38     
+ Misses        211      192      -19     
Impacted Files Coverage Δ
lib/jsonld.js 83.17% <ø> (+0.32%) :arrow_up:
lib/events.js 89.28% <89.28%> (ø)
lib/context.js 94.56% <100.00%> (+3.25%) :arrow_up:
lib/expand.js 95.95% <100.00%> (+0.28%) :arrow_up:
lib/fromRdf.js 99.20% <100.00%> (+0.81%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b7bc6d6...1ebcc1f. Read the comment docs.