-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add feature for setting docs & protocolHandlers from constructor. #11
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #11 +/- ##
==========================================
+ Coverage 98.27% 98.49% +0.22%
==========================================
Files 2 2
Lines 116 133 +17
==========================================
+ Hits 114 131 +17
Misses 2 2
Continue to review full report in Codecov by Sentry.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Please add some docs/examples to the README for this feature.
- It might also be worth noting these are mutable params and direct changes or changes via the other API calls will effect every loader using the Maps.
- I do have a concern that this is exposing internal implementation details as an API. I'm not sure what the future ramifications of that might be, if any.
Co-authored-by: David I. Lehn <[email protected]>
…n for Constructor. Co-authored-by: David I. Lehn <[email protected]>
Co-authored-by: David I. Lehn <[email protected]>
9ff77e6
to
b55a2a3
Compare
Yeah, I agree with this. Perhaps it would be better to allow |
you do have a point, the Map is by reference and could be mutated elsewhere. Perhaps we could simply copy the Maps passed in? As protocolHandlers it's set in the constructor so I just included it there. did this here: 7a4bf3e Example: const mapOne = new Map([['one', 1]]);
const mapTwo = new Map(mapOne);
mapOne.set('one', 2);
mapOne.get('one');
// returns 2
mapTwo.get('one');
// returns 1 I can add a test to ensure mutations to a Map passed into the documentLoader do not mutate entries in documents if wanted. |
@davidlehn @dlongley also of note: the existing |
closing as this does not appear to be the direction this library wants to go in. |
Adds a new minor feature that allows you to pass in a documents Map and a protocolHandler map to the constructor avoiding the loop of using
addStatic
andsetProtocolHandler
.This makes creation of multiple documentLoaders much easier.
Also adds 2 tests to the project that use this constructor.