Closed jmakeig closed 8 years ago
It won't be possible to cover every iterable in a single implementation. Rather Iterable
should supply a default naïve implementation and then Take a look at an example inheritance technique.
function Iterable(iterable) { … }
Iterable.prototype = Object.assign({},
{ slice(start, end): { … } }
);
function SequenceIterable() { … }
SequenceIterable.prototype = Object.assign(
Object.create(Iterable.prototype),
{
slice(start, end): {
…
}
}
);
Need to update docs.
Closed in 1436ac234e7a807826d3cc810664b4b20a3bba56.
Iterable
is more like an interface. It should be possible for concrete instances to extend this with properties/methods that are specific to their own type, override existing implementations, or fallback to the built-in functionality.For example, for a MarkLogic
Sequence
, theslice()
implementation usesfn.subsequence()
internally. How can we decouple this from theIterable
interface? Thexpath()
method is an extension to theIterable
interface and likely not germain to otherIterable
instances.Symbol.species
might help here.