Last active
May 11, 2017 21:20
-
-
Save jmakeig/cf67640486e06335cb19bbe765dcfe7a to your computer and use it in GitHub Desktop.
Monkey patch of MarkLogic’s JSearch API to change the default values for slice(). Proof-of-concept. Don’t actually do this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const jsearch = require('/MarkLogic/jsearch'); | |
// Monkey patch | |
const proto = Object.getPrototypeOf( | |
// Doesn’t actually run a query | |
jsearch.collections('.').documents().where(cts.trueQuery()) | |
); | |
const _slice = proto.slice; | |
Object.assign(proto, { | |
slice(start = 0, end = 9007199254740991) { | |
// Call the stashed original slice method with the new defaults | |
return _slice.call(this, start, end); | |
} | |
}); | |
jsearch.documents().where(cts.trueQuery()).slice().result().results.length; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment