Skip to content

Instantly share code, notes, and snippets.

@jmakeig
Created November 20, 2019 00:04
Show Gist options
  • Save jmakeig/4b1f1a893d7016619d2d3e4eb267c4e5 to your computer and use it in GitHub Desktop.
Save jmakeig/4b1f1a893d7016619d2d3e4eb267c4e5 to your computer and use it in GitHub Desktop.
Are ArrayNode instances in MarkLogic iterable? (Yes, by duck typing.)
const letters = xdmp.toJSON(['a', 'b', 'c']).root; // ArrayNode
Array.from(letters); // [Text, Text, Text]
ArrayNode.prototype[Symbol.iterator] = function*() {
for (let i = 0; i < this.length; i++) {
yield this[String(i)];
}
};
Array.from(letters); // [Text, Text, Text]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment