first commit
This commit is contained in:
39
build/node_modules/queue-fifo/.circleci/config.yml
generated
vendored
Normal file
39
build/node_modules/queue-fifo/.circleci/config.yml
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# Javascript Node CircleCI 2.0 configuration file
|
||||
#
|
||||
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
|
||||
#
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
docker:
|
||||
# specify the version you desire here
|
||||
- image: circleci/node:7.10
|
||||
|
||||
# Specify service dependencies here if necessary
|
||||
# CircleCI maintains a library of pre-built images
|
||||
# documented at https://circleci.com/docs/2.0/circleci-images/
|
||||
# - image: circleci/mongo:3.4.4
|
||||
|
||||
working_directory: ~/projects/queue-fifo
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
|
||||
# Download and cache dependencies
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-dependencies-{{ checksum "package.json" }}
|
||||
# fallback to using the latest cache if no exact match is found
|
||||
- v1-dependencies-
|
||||
|
||||
- run: yarn install
|
||||
|
||||
- save_cache:
|
||||
paths:
|
||||
- node_modules
|
||||
key: v1-dependencies-{{ checksum "package.json" }}
|
||||
|
||||
# run tests!
|
||||
- run: yarn test
|
||||
|
||||
|
||||
7
build/node_modules/queue-fifo/.eslintrc.json
generated
vendored
Normal file
7
build/node_modules/queue-fifo/.eslintrc.json
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "eslint:recommended",
|
||||
"env": {
|
||||
"node": true,
|
||||
"mocha": true
|
||||
}
|
||||
}
|
||||
21
build/node_modules/queue-fifo/LICENSE-MIT
generated
vendored
Normal file
21
build/node_modules/queue-fifo/LICENSE-MIT
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
Queue: Javascript implementation of queue data structure
|
||||
|
||||
Copyright (C) 2015 Jason S. Jones
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
156
build/node_modules/queue-fifo/README.md
generated
vendored
Normal file
156
build/node_modules/queue-fifo/README.md
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
[![npm version][npm-image]][npm-url]
|
||||
[![Build Status][circleci-image]][circleci-url]
|
||||
[![dependency status][dm-image]][dm-url]
|
||||
[![devDependency status][devdep-image]][devdep-url]
|
||||
[]()
|
||||
|
||||
# Queue Data Structure
|
||||
|
||||
## Description
|
||||
|
||||
This is a javascript implementation of a
|
||||
[queue](http://en.wikipedia.org/wiki/Queue%28abstract_data_type%29)
|
||||
data structure.
|
||||
|
||||
A queue data structure models the notion of 'First in First Out', or FIFO—
|
||||
image the line at the grocery store. The first item to be removed from a queue
|
||||
is the first item placed in the queue. Basically, the order in which items
|
||||
are placed in the queue matters.
|
||||
|
||||
This particular implementation utilizes a
|
||||
[linked list](https://www.npmjs.com/package/dbly-linked-list) as the
|
||||
underlying data structure. This offers several benefits.
|
||||
|
||||
* We can leverage the work that has already been done to implement the
|
||||
linked list.
|
||||
|
||||
* This lends itself to a level of composition and abstraction which greatly
|
||||
simplifies this implementation. It provides a wrapper around only those
|
||||
methods of the linked list that we need to construct the properties of a
|
||||
queue data structure.
|
||||
|
||||
* The 'queue' or 'dequeue' operations can be completed in O(1) time.
|
||||
|
||||
* No additional overhead is required to 'resize' the data structure to add
|
||||
more elements to the queue. When elements are 'queued' up in the queue, the
|
||||
underlying linked list will adjust its size dynamically.
|
||||
|
||||
*For specific examples and documentation, see the below sections*
|
||||
|
||||
### Motivation:
|
||||
|
||||
The main purpose of this project is revisit the basics, and focus on the
|
||||
development process.
|
||||
|
||||
*I wholehearedly acknowledge that the basic data structure space is populated
|
||||
with well-written code and efficient implementations, and one could easily grab
|
||||
one of those libraries and integrate it in their project. However, the main
|
||||
difference between those libraries/implementations and this one is that this is
|
||||
the best implementation I have ever written. My hope is that someone else will
|
||||
find this useful, but understand, this code is not the goal; this will simply
|
||||
be a useful bi-product of the journey. The underlying motivation is to
|
||||
understand and, more importantly, learn from the process to get to the desired
|
||||
end-state—for me it is all about the joy of the journey.*
|
||||
|
||||
#### Environment:
|
||||
|
||||
Although this implementation is designed to be used with
|
||||
[Node.js](http://www.nodejs.org), it could be used in other contexts with minor
|
||||
modifications. This implementation does not have any external dependencies
|
||||
that would preclude it from being used in the browser--just include it with a
|
||||
`<script>` tag and it should be good to go. _Disclaimer: I have not tested
|
||||
this implementation in any other context/environment; only tested with node.js_
|
||||
|
||||
----
|
||||
|
||||
## Basic Usage
|
||||
|
||||
Install with npm :
|
||||
|
||||
```bash
|
||||
npm install queue-fifo --save
|
||||
```
|
||||
|
||||
Install with yarn :
|
||||
|
||||
```bash
|
||||
yarn add queue-fifo
|
||||
```
|
||||
|
||||
Basic usage example below. _Note: it does not cover all the available
|
||||
methods, rather just highlights the main functionality to get up and running
|
||||
with this data structure. For a description of all the methods, see the
|
||||
API section._
|
||||
|
||||
```javascript
|
||||
var Queue = require('queue-fifo');
|
||||
var queue = new Queue();
|
||||
|
||||
queue.isEmpty();
|
||||
// --> true
|
||||
|
||||
queue.enqueue('data item 1');
|
||||
queue.enqueue('data item 2');
|
||||
queue.enqueue('data item 3');
|
||||
queue.enqueue('data item 4');
|
||||
// queue contains:
|
||||
// 'data item 1', <-- front
|
||||
// ... ,
|
||||
// 'data item 4'
|
||||
|
||||
queue.isEmpty();
|
||||
// --> false
|
||||
|
||||
queue.size();
|
||||
// --> 4
|
||||
|
||||
queue.dequeue();
|
||||
// --> removes 'data item 1'
|
||||
|
||||
queue.peek()
|
||||
// --> 'data item 2'
|
||||
|
||||
queue.size();
|
||||
// --> 3
|
||||
|
||||
queue.clear();
|
||||
queue.isEmpty();
|
||||
// --> true
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
**Available methods for a queue instance:**
|
||||
|
||||
* ### isEmpty()
|
||||
Determines if the queue is empty or not. Returns true if is empty, false
|
||||
otherwise.
|
||||
|
||||
* ### size()
|
||||
Returns the size of the queue, or number of items
|
||||
|
||||
* ### clear()
|
||||
Clears the queue of all data
|
||||
|
||||
* ### enqueue(data)
|
||||
Adds an new item containing 'data' to the back of the queue
|
||||
|
||||
* ### dequeue()
|
||||
Removes the item from the front of the queue
|
||||
|
||||
* ### peek()
|
||||
Returns the data of the item at the front of the queue,
|
||||
but does not remove it
|
||||
|
||||
----
|
||||
## License
|
||||
MIT © Jason Jones
|
||||
|
||||
[npm-image]:https://badge.fury.io/js/queue-fifo.svg
|
||||
[npm-url]:http://npmjs.org/package/queue-fifo
|
||||
[circleci-image]: https://img.shields.io/circleci/project/github/jasonsjones/queue-fifo.svg?style=flat-square
|
||||
[circleci-url]: https://circleci.com/gh/jasonsjones/queue-fifo
|
||||
[dm-image]:https://david-dm.org/jasonsjones/queue-fifo.svg?style=flat-square
|
||||
[dm-url]:https://david-dm.org/jasonsjones/queue-fifo
|
||||
[devdep-image]:https://david-dm.org/jasonsjones/queue-fifo/dev-status.svg?style=flat-square
|
||||
[devdep-url]:https://david-dm.org/jasonsjones/queue-fifo?type=dev
|
||||
101
build/node_modules/queue-fifo/index.js
generated
vendored
Normal file
101
build/node_modules/queue-fifo/index.js
generated
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* @fileOverview Implementation of a queue (FIFO) data structure
|
||||
* @author Jason S. Jones
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
/***********************************************************
|
||||
* Queue Data Structure
|
||||
*
|
||||
* This is a 'queue' data structure that implements the notion
|
||||
* of a 'First in First Out', or FIFO, protocol. The underlying data
|
||||
* structure is a doubly linked list. This linked list data structure
|
||||
* does all the heavy lifting, enabling this implementation to be a
|
||||
* simple wrapper around the linked list to leverage the applicable
|
||||
* methods and properties. This provides a very clean and simple
|
||||
* implementation for this queue data structure.
|
||||
*
|
||||
***********************************************************/
|
||||
|
||||
// bring in the one dependency which will be the underlying
|
||||
// data structure for this queue implementation
|
||||
var LinkedList = require('dbly-linked-list');
|
||||
|
||||
/**
|
||||
* Creates a new queue instance and initializes the underlying data
|
||||
* structure
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
function Queue() {
|
||||
this._list = new LinkedList();
|
||||
}
|
||||
|
||||
/* Functions attached to the Queue prototype. All queue instances
|
||||
* will share these methods, meaning there will NOT be copies made for each
|
||||
* instance. This will be a huge memory savings since there may be several
|
||||
* different queue instances.
|
||||
*/
|
||||
Queue.prototype = {
|
||||
|
||||
/**
|
||||
* Determines if the queue is empty
|
||||
*
|
||||
* @returns {boolean} true if the queue is empty, false otherwise
|
||||
*/
|
||||
isEmpty: function() {
|
||||
return this._list.isEmpty();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the size, or number of items in the queue
|
||||
*
|
||||
* @returns {number} the number of items in the queue
|
||||
*/
|
||||
size: function() {
|
||||
return this._list.getSize();
|
||||
},
|
||||
|
||||
/**
|
||||
* Clears the queue of all data
|
||||
*/
|
||||
clear: function () {
|
||||
return this._list.clear();
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a new item containing 'data' to the back of the queue
|
||||
*
|
||||
* @param {object} data the data to add to the back of the queue
|
||||
*/
|
||||
enqueue: function (data) {
|
||||
return this._list.insert(data);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the item from the front of the queue
|
||||
*
|
||||
* @returns {object} the item, or data, from the front of the queue
|
||||
*/
|
||||
dequeue: function () {
|
||||
return this._list.removeFirst().getData();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the data of the item at the front of the queue,
|
||||
* but does not remove it
|
||||
*
|
||||
* @returns {object} the item, or data, from the top of the stack
|
||||
*/
|
||||
peek: function () {
|
||||
return this._list.getHeadNode().getData();
|
||||
}
|
||||
};
|
||||
|
||||
// export the constructor fn to make it available for use outside
|
||||
// this file
|
||||
module.exports = Queue;
|
||||
}());
|
||||
63
build/node_modules/queue-fifo/package.json
generated
vendored
Normal file
63
build/node_modules/queue-fifo/package.json
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"_from": "queue-fifo@^0.2.3",
|
||||
"_id": "queue-fifo@0.2.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-o2xWptfzdw4QLIozUUcRPnppoTNK+X1DxWGd8csnJ1gQUsATfQaDryaGB1MhAu1L48vqPMtH69PZ1kZD82zlVw==",
|
||||
"_location": "/queue-fifo",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "queue-fifo@^0.2.3",
|
||||
"name": "queue-fifo",
|
||||
"escapedName": "queue-fifo",
|
||||
"rawSpec": "^0.2.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^0.2.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/prepack"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/queue-fifo/-/queue-fifo-0.2.4.tgz",
|
||||
"_shasum": "8276bf59122abcae9ac5a3234f534e696699bf25",
|
||||
"_spec": "queue-fifo@^0.2.3",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/prepack",
|
||||
"author": {
|
||||
"name": "Jason Jones"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/jasonsjones/queue-fifo/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"dbly-linked-list": "0.2.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Javascript implementation of a queue data structure",
|
||||
"devDependencies": {
|
||||
"chai": "^4.1.2",
|
||||
"eslint": "^4.12.1",
|
||||
"mocha": "^4.0.1",
|
||||
"nyc": "^11.3.0"
|
||||
},
|
||||
"homepage": "https://github.com/jasonsjones/queue-fifo",
|
||||
"keywords": [
|
||||
"queue",
|
||||
"FIFO",
|
||||
"abstract data-type",
|
||||
"data structure"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"name": "queue-fifo",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jasonsjones/queue-fifo.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint index.js test/*.js",
|
||||
"pretest": "npm run lint",
|
||||
"test": "nyc mocha"
|
||||
},
|
||||
"version": "0.2.4"
|
||||
}
|
||||
75
build/node_modules/queue-fifo/test/queue-test.js
generated
vendored
Normal file
75
build/node_modules/queue-fifo/test/queue-test.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
/* globals describe it beforeEach afterEach */
|
||||
var chai = require('chai');
|
||||
var Queue = require('../');
|
||||
|
||||
chai.should();
|
||||
|
||||
describe('Queue Unit Tests', function() {
|
||||
|
||||
var queue;
|
||||
|
||||
beforeEach(function () {
|
||||
queue = new Queue();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
queue = null;
|
||||
});
|
||||
|
||||
it('should have a working test environment', function() {
|
||||
true.should.equal(true);
|
||||
});
|
||||
|
||||
it('should instantiate a queue instance', function () {
|
||||
queue.should.be.ok;
|
||||
});
|
||||
|
||||
it('should be empty when first instantiated', function () {
|
||||
queue.isEmpty().should.equal(true);
|
||||
queue.size().should.equal(0);
|
||||
});
|
||||
|
||||
it('should queue up data at the back of queue', function () {
|
||||
queue.enqueue('some test data');
|
||||
queue.enqueue('some more test data');
|
||||
queue.enqueue('and yet some more...');
|
||||
queue.size().should.equal(3);
|
||||
});
|
||||
|
||||
it('should dequeue data from the front of the queue', function () {
|
||||
queue.enqueue('some test data');
|
||||
queue.enqueue('some more test data');
|
||||
queue.enqueue('and yet some more...');
|
||||
queue.size().should.equal(3);
|
||||
|
||||
var first = queue.dequeue();
|
||||
first.should.equal('some test data');
|
||||
|
||||
queue.size().should.equal(2);
|
||||
|
||||
queue.dequeue().should.equal('some more test data');
|
||||
queue.size().should.equal(1);
|
||||
});
|
||||
|
||||
it('should peek at the data at the front of the queue', function () {
|
||||
queue.enqueue('some test data');
|
||||
queue.enqueue('some more test data');
|
||||
queue.enqueue('and yet some more');
|
||||
queue.enqueue('and even more data');
|
||||
queue.size().should.equal(4);
|
||||
var first = queue.peek();
|
||||
first.should.equal('some test data');
|
||||
queue.size().should.equal(4);
|
||||
});
|
||||
|
||||
it('should clear the queue of all data', function () {
|
||||
queue.enqueue('some test data');
|
||||
queue.enqueue('some more test data');
|
||||
queue.enqueue('and yet some more');
|
||||
queue.enqueue('and even more data');
|
||||
queue.size().should.equal(4);
|
||||
queue.clear();
|
||||
queue.size().should.equal(0);
|
||||
queue.isEmpty().should.equal(true);
|
||||
});
|
||||
});
|
||||
1838
build/node_modules/queue-fifo/yarn.lock
generated
vendored
Normal file
1838
build/node_modules/queue-fifo/yarn.lock
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user