invertase / denque

The fastest javascript implementation of a double-ended queue. Used by the official Redis, MongoDB, MariaDB & MySQL libraries for Node.js and many other libraries.
https://docs.page/invertase/denque
Apache License 2.0
354 stars 33 forks source link

splicing elements into an empty array #11

Closed rlidwka closed 6 years ago

rlidwka commented 6 years ago

Trying to add multiple elements to the array. Found that splice doesn't work there:

var a;

a = new (require('denque'))([])
a.splice(0,0, 1,2,3,4,5)
console.log(a.toArray())
// []

a = []
a.splice(0,0, 1,2,3,4,5)
console.log(a)
// [ 1, 2, 3, 4, 5 ]

Splice stops on this empty array check.

Salakar commented 6 years ago

@rlidwka ah ye I see the issue, thanks for reporting it - will push a fix + tests for it in the next day or so.