invertase/denque

push(undefined) has a confusing behavior

rinick opened this issue ยท 2 comments

denque/index.js

Line 131 in ebe332b

if (item === undefined) return this.size();

in js Array you can push(undefined) or unshift(undefined) and it works exactly as what people expect.
in Denque, push(undefined) is ignored and wont change the queue at all.

So if someone just replaces his Array with Denque for better performance, he might hit this hidden trap and spend hours to figure out what causes the new issues.

and the readme also says

If the queue is empty, undefined is returned. 
If you need to differentiate between undefined values in the queue and pop() return value,
check the queue .length before popping.

Which implies undefined value is allowed in the Denque. But that's not the case

Fixed this in #35 - releasing v2.0.0 shortly - sorry it took a while ๐Ÿ˜