node-structures
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -1,1 +0,2 @@ | ||
module.exports.Stack = require('./lib/stack'); | ||
module.exports.Stack = require('./lib/stack'); | ||
module.exports.Queue = require('./lib/queue'); |
{ | ||
"name": "node-structures", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"author": { | ||
@@ -16,3 +16,5 @@ "name": "Albert Hambardzumyan", | ||
"Stack", | ||
"stack" | ||
"stack", | ||
"Queue", | ||
"queue" | ||
], | ||
@@ -19,0 +21,0 @@ "homepage": "https://github.com/AlbertHambardzumyan/node-structures", |
@@ -21,2 +21,3 @@ # node-structures | ||
# Usage | ||
###Stack | ||
@@ -60,3 +61,42 @@ ```` javascript | ||
```` | ||
###Queue | ||
```` javascript | ||
const Queue = require('node-structures').Queue; | ||
let queue = new Queue(); | ||
/** | ||
* Tests if this queue is empty. | ||
* @returns {boolean} - true if and only if this queue contains no items; false otherwise. | ||
*/ | ||
queue.isEmpty(); | ||
/** | ||
* Inserts the specified element into this queue. | ||
* @param element - the element to add | ||
* @return {boolean} Returns true | ||
*/ | ||
queue.add(3); | ||
/** | ||
* Retrieves and removes the head of this queue. This method differs from poll only in that it throws an exception | ||
* if this queue is empty. | ||
* @throws {Error} when the queue is empty. | ||
* @return {*} Returns the head of this queue | ||
*/ | ||
queue.remove(); | ||
/** | ||
* Retrieves and removes the head of this queue, or returns null if this queue is empty. | ||
* @returns {*} Returns the head of this queue, or null if this queue is empty. | ||
*/ | ||
queue.poll(); | ||
/** | ||
* Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty. | ||
* @returns {*} Returns the head of this queue, or null if this queue is empty. | ||
*/ | ||
queue.peek(); | ||
```` | ||
# License | ||
MIT |
@@ -11,5 +11,5 @@ /** | ||
describe('Stack', function () { | ||
var stack = new Stack(); | ||
describe('isEmpty', function () { | ||
var stack = new Stack(); | ||
it('should be empty', function () { | ||
@@ -23,2 +23,3 @@ expect(stack.isEmpty()).to.be.equal(true); | ||
describe('Push', function () { | ||
var stack = new Stack(); | ||
it('should add a new element on top of the Stack', function () { | ||
@@ -25,0 +26,0 @@ var add = stack.push(7); |
13695
10
254
101