Created
November 20, 2019 00:04
-
-
Save jmakeig/4b1f1a893d7016619d2d3e4eb267c4e5 to your computer and use it in GitHub Desktop.
Are ArrayNode instances in MarkLogic iterable? (Yes, by duck typing.)
This file contains 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
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