Skip to content

Commit

Permalink
Add comment about how it works (#2)
Browse files Browse the repository at this point in the history
Co-authored-by: Sindre Sorhus <[email protected]>
  • Loading branch information
Richienb and sindresorhus authored Jan 7, 2021
1 parent af91c37 commit 005fd9b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
How it works:
`this._head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this._head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this._tail` so that it can reference it to add a new value.
*/

class Node {
/// value;
/// next;
Expand Down

0 comments on commit 005fd9b

Please sign in to comment.