-
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 function to get full revisions #3
Comments
Another thought I had was that there should maybe be an optional |
Needs tests. Should also go in the README, but in a separate commit, since PageByPageId and RevisionByRevisionId should also be in there. I also realized that the interface needs more consideration, see #3.
One option would be to attach the outer page object as a member of the revision object – with a symbol as the key, and probably as a non-enumerable property. The symbol would be an anonymous one (i.e. not using I’m not sure if I would want to add the page object to the original |
Alternatively, the page we attach could be a shallow copy from which we’ve removed the |
I think at the moment I’m leaning towards doing both: attach, to a shallow copy of the revision, a shallow copy of the page without revisions. Note that destructuring assignment makes it very easy to get that shallow copy of the page: let { revisions, ...remainingPage } = page;
if ( revisions === undefined ) {
revisions = [];
} |
Introduce a symbol which we use to decorate a revision object, returned by the various revision functions, with its surrounding page. This is expected to be useful in some situations where you want information about the page as well – especially in the upcoming queryFullRevisions (see #3), but also in the existing functions. The symbol is not enumerable, so that it doesn’t pollute e.g. console.log() output and generally doesn’t disturb anyone who’s not interested in it; but it is writable and configurable, so that users who want to change something about it can do so. In the tests, a bunch of .equal() assertions need to change to .eql(), since the returned object is no longer the same instance as the input revision. For practical usage outside of tests, this should be fine. (You could even argue that all the assertions, including for the “page” functions, should use .eql() to start with, I think.)
Introduce a symbol which we use to decorate a revision object, returned by the various revision functions, with its surrounding page. This is expected to be useful in some situations where you want information about the page as well – especially in the upcoming queryFullRevisions (see #3), but also in the existing functions. The symbol is not enumerable, so that it doesn’t pollute e.g. console.log() output and generally doesn’t disturb anyone who’s not interested in it; but it is writable and configurable, so that users who want to change something about it can do so. In the tests, a bunch of .equal() assertions need to change to .eql(), since the returned object is no longer the same instance as the input revision. For practical usage outside of tests, this should be fine. (You could even argue that all the assertions, including for the “page” functions, should use .eql() to start with, I think.)
The function should probably also yield missing revisions (if it was called with |
This function is analogous to queryFullPages(), and should address the potential pitfall of using prop=revisions with the “full pages” functions (which would try to assemble all revisions of the page). It’ll receive some further improvements, but this should be good enough as an initial version. Part of #3.
I assume this can only happen when you use revids instead of a generator, but still, it seems better to yield them (with the missing key added if needed, so extract the missingRevision() helper function) than to silently drop them. Part of #3.
I assume this can only happen when you use revids instead of a generator, but still, it seems better to yield them (with the missing key added if needed, so extract the missingRevision() helper function) than to silently drop them. Part of #3.
I thought a
queryFullRevisions()
function, analogous toqueryFullPages()
(yield all the revisions in a continued response, e.g. from a generator), would make sense:But I just realized that this leaves the caller with no way to know which page the revision belongs to. With the default
rvprop
, a revision looks like this:There’s no indication here of the surrounding page, nor in any of the other available props (which makes sense in the context of a full API response).
This needs some more thinking about what the interface should look like. The
session, params, options
parameters should probably be the same, and it should return a generator, but I’m not sure what kind of objects the generator should yield.The text was updated successfully, but these errors were encountered: