petkaantonov/deque

Deque doesn't expose length

Opened this issue · 3 comments

Hi @petkaantonov -

I'd like to be able to iterate over the elements in a queue without converting it to an array. To do this I need to expose Deque's length attribute (i.e. change it from _length to length). I'd be happy to submit a PR for this if you think it's a reasonable change. Please let me know.

Ryan

Yes I am surprised it's not implemented :) go for it

Ah whoops. It's implemented as follows.

Object.defineProperty(Deque.prototype, "length", {
    get: function() {
        return this._length;
    },
    set: function() {
        throw new RangeError("");
    }
});

I missed that. Never mind!

Hrmmm, I thought this was missing as well. Seems like an oversight in the documentation.