Skip to content

Commit

Permalink
Add first() / last() aliases for peekStart() / peek() respectively
Browse files Browse the repository at this point in the history
  • Loading branch information
erayd committed Sep 11, 2016
1 parent 225e7f0 commit 90d04df
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,22 @@ var myValue = s.pop();
Return the value at the end of the queue, and remove it from the queue. If the
queue is empty, then this method will return undefined.

### .peek()
### .last(), .peek()
```javascript
var myValue = s.last();
var myValue = s.peek();
```
Return the value at the end of the queue. The value is not removed. If the queue
is empty, then this method will return undefined.
is empty, then this method will return undefined. `last()` and `peek()` are synonymous.

### .peekStart()
### .first(), .peekStart()
```javascript
var myValue = s.first();
var myValue = s.peekStart();
```
Return the value at the head of the queue. The value is not removed. If the queue
is empty, then this method will return undefined.
is empty, then this method will return undefined. `first()` and `peekStart()` are
synonymous.

### Properties
#### .length
Expand Down
4 changes: 2 additions & 2 deletions spique.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ function Spique(maxItems, circumference) {
};

// peek at the end of the buffer
this.peek = function() {
this.last = this.peek = function() {
return lastRing.peek();
};

// peek at the start of the buffer
this.peekStart = function() {
this.first = this.peekStart = function() {
return firstRing.peekStart();
};

Expand Down

0 comments on commit 90d04df

Please sign in to comment.