Pushing changes
This commit is contained in:
30
node_modules/double-ended-queue/.npmignore
generated
vendored
Normal file
30
node_modules/double-ended-queue/.npmignore
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
node_modules/*
|
||||
todo.txt
|
||||
npm-debug.log
|
||||
test/*
|
||||
benchmark/*
|
||||
browser/*
|
||||
src/*
|
||||
async
|
||||
sync
|
||||
mixed
|
||||
bench.json
|
||||
js/browser
|
||||
js/browser/*
|
||||
js/debug
|
||||
js/debug/*
|
||||
reader.js
|
||||
read.txt
|
||||
bench
|
||||
.editorconfig
|
||||
.jshintrc
|
||||
ast_passes.js
|
||||
mocharun.js
|
||||
throwaway.js
|
||||
throwaway.html
|
||||
deque.sublime-workspace
|
||||
deque.sublime-project
|
||||
changelog.js
|
||||
.travis.yml
|
||||
sauce_connect.log
|
||||
nodex64.exe
|
188
node_modules/double-ended-queue/Gruntfile.js
generated
vendored
Normal file
188
node_modules/double-ended-queue/Gruntfile.js
generated
vendored
Normal file
@ -0,0 +1,188 @@
|
||||
"use strict";
|
||||
Error.stackTraceLimit = 100;
|
||||
var astPasses = require("./ast_passes.js");
|
||||
|
||||
module.exports = function( grunt ) {
|
||||
var isCI = !!grunt.option("ci");
|
||||
|
||||
var license;
|
||||
function getLicense() {
|
||||
if( !license ) {
|
||||
var fs = require("fs");
|
||||
var text = fs.readFileSync("LICENSE", "utf8");
|
||||
text = text.split("\n").map(function(line, index){
|
||||
return " * " + line;
|
||||
}).join("\n")
|
||||
license = "/**\n" + text + "\n */\n";
|
||||
}
|
||||
return license
|
||||
}
|
||||
|
||||
function writeFile( dest, content ) {
|
||||
grunt.file.write( dest, content );
|
||||
grunt.log.writeln('File "' + dest + '" created.');
|
||||
}
|
||||
|
||||
var gruntConfig = {};
|
||||
|
||||
var getGlobals = function() {
|
||||
var fs = require("fs");
|
||||
var file = "./src/constants.js";
|
||||
var contents = fs.readFileSync(file, "utf8");
|
||||
var rconstantname = /CONSTANT\(\s*([^,]+)/g;
|
||||
var m;
|
||||
var globals = {
|
||||
"console": false,
|
||||
"require": false,
|
||||
"module": false,
|
||||
"define": false
|
||||
};
|
||||
while( ( m = rconstantname.exec( contents ) ) ) {
|
||||
globals[m[1]] = false;
|
||||
}
|
||||
return globals;
|
||||
}
|
||||
|
||||
gruntConfig.pkg = grunt.file.readJSON("package.json");
|
||||
|
||||
gruntConfig.jshint = {
|
||||
all: {
|
||||
options: {
|
||||
globals: getGlobals(),
|
||||
|
||||
"bitwise": false,
|
||||
"camelcase": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"es3": true,
|
||||
"forin": true,
|
||||
"immed": true,
|
||||
"latedef": false,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"noempty": true,
|
||||
"nonew": true,
|
||||
"plusplus": false,
|
||||
"quotmark": "double",
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"strict": false,
|
||||
"trailing": true,
|
||||
"maxparams": 7,
|
||||
"maxlen": 80,
|
||||
|
||||
"asi": false,
|
||||
"boss": true,
|
||||
"eqnull": true,
|
||||
"evil": true,
|
||||
"expr": false,
|
||||
"funcscope": false,
|
||||
"globalstrict": false,
|
||||
"lastsemic": false,
|
||||
"laxcomma": false,
|
||||
"laxbreak": false,
|
||||
"loopfunc": true,
|
||||
"multistr": true,
|
||||
"proto": false,
|
||||
"scripturl": true,
|
||||
"smarttabs": false,
|
||||
"shadow": true,
|
||||
"sub": true,
|
||||
"supernew": false,
|
||||
"validthis": true,
|
||||
|
||||
"browser": true,
|
||||
"jquery": true,
|
||||
"devel": true,
|
||||
|
||||
|
||||
'-W014': true,
|
||||
'-W116': true,
|
||||
'-W106': true,
|
||||
'-W064': true,
|
||||
'-W097': true
|
||||
},
|
||||
|
||||
files: {
|
||||
src: [
|
||||
"./src/deque.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if( !isCI ) {
|
||||
gruntConfig.jshint.all.options.reporter = require("jshint-stylish");
|
||||
}
|
||||
|
||||
gruntConfig.bump = {
|
||||
options: {
|
||||
files: ['package.json'],
|
||||
updateConfigs: [],
|
||||
commit: true,
|
||||
commitMessage: 'Release v%VERSION%',
|
||||
commitFiles: ['-a'],
|
||||
createTag: true,
|
||||
tagName: 'v%VERSION%',
|
||||
tagMessage: 'Version %VERSION%',
|
||||
false: true,
|
||||
pushTo: 'master',
|
||||
gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d' // options to use with '$ git describe'
|
||||
}
|
||||
};
|
||||
|
||||
grunt.initConfig(gruntConfig);
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-bump');
|
||||
|
||||
|
||||
grunt.registerTask( "build", function() {
|
||||
var fs = require("fs");
|
||||
var CONSTANTS_FILE = "./src/constants.js";
|
||||
|
||||
astPasses.readConstants(fs.readFileSync(CONSTANTS_FILE, "utf8"), CONSTANTS_FILE);
|
||||
var fileNames = ["deque.js"];
|
||||
fileNames.forEach(function(fileName){
|
||||
var src = fs.readFileSync("./src/" + fileName, "utf8");
|
||||
src = astPasses.removeComments(src, fileName);
|
||||
src = astPasses.expandConstants(src, fileName);
|
||||
src = getLicense() + src;
|
||||
writeFile("./js/" + fileName, src);
|
||||
});
|
||||
});
|
||||
|
||||
grunt.registerTask( "testrun", function() {
|
||||
var fs = require("fs");
|
||||
var done = this.async();
|
||||
var Mocha = require("mocha");
|
||||
|
||||
var mochaOpts = {
|
||||
reporter: "spec",
|
||||
timeout: 500,
|
||||
slow: Infinity
|
||||
};
|
||||
|
||||
var mocha = new Mocha(mochaOpts);
|
||||
|
||||
fs.readdirSync("./test").forEach(function(fileName) {
|
||||
mocha.addFile("./test/" + fileName);
|
||||
});
|
||||
|
||||
mocha.run(function(err){
|
||||
if( err ) {
|
||||
process.stderr.write(test.title + "\n" + err.stack + "\n");
|
||||
done(err);
|
||||
}
|
||||
else {
|
||||
done();
|
||||
}
|
||||
}).on( "fail", function( test, err ) {
|
||||
process.stderr.write(test.title + "\n" + err.stack + "\n");
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
||||
grunt.registerTask( "test", ["jshint", "build", "testrun"] );
|
||||
grunt.registerTask( "default", ["jshint", "build"] );
|
||||
|
||||
};
|
19
node_modules/double-ended-queue/LICENSE
generated
vendored
Normal file
19
node_modules/double-ended-queue/LICENSE
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
Copyright (c) 2013 Petka Antonov
|
||||
|
||||
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:</p>
|
||||
|
||||
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.
|
280
node_modules/double-ended-queue/README.md
generated
vendored
Normal file
280
node_modules/double-ended-queue/README.md
generated
vendored
Normal file
@ -0,0 +1,280 @@
|
||||
|
||||
https://code.google.com/p/v8/issues/detail?id=3059
|
||||
|
||||
#Introduction
|
||||
|
||||
Extremely fast [double-ended queue](http://en.wikipedia.org/wiki/Double-ended_queue) implementation. Double-ended queue can also be used as a:
|
||||
|
||||
- [Stack](http://en.wikipedia.org/wiki/Stack_\(abstract_data_type\))
|
||||
- [Queue](http://en.wikipedia.org/wiki/Queue_\(data_structure\))
|
||||
|
||||
The implementation is GC and CPU cache friendly [circular buffer](http://en.wikipedia.org/wiki/Circular_buffer). It will run circles around any "linked list" implementation.
|
||||
|
||||
Every queue operation is done in constant `O(1)` - including random access from `.get()`.
|
||||
|
||||
#Topics
|
||||
|
||||
- [Quick start](#quick-start)
|
||||
- [Why not use an Array?](#why-not-use-an-array)
|
||||
- [Using double-ended queue as a normal queue](#using-double-ended-queue-as-a-normal-queue)
|
||||
- [API reference and examples](#api)
|
||||
|
||||
#Quick start
|
||||
|
||||
npm install double-ended-queue
|
||||
|
||||
```js
|
||||
var Deque = require("double-ended-queue");
|
||||
|
||||
var deque = new Deque([1,2,3,4]);
|
||||
deque.shift(); //1
|
||||
deque.pop(); //4
|
||||
```
|
||||
|
||||
#Why not use an Array?
|
||||
|
||||
Arrays take linear `O(N)` time to do `shift` and `unshift` operations. That means in theory that an array with 1000 items is 1000x slower to do those operations than a deque with 1000 items. 10000x slower with 10000 items and so on.
|
||||
|
||||
V8 implements [a trick for small arrays](https://code.google.com/p/v8/issues/detail?id=3059) where these operations are done in constant time, however even with this trick deque is still 4x faster.
|
||||
|
||||
But arrays use "native" methods, they must be faster!
|
||||
|
||||
In V8, there is almost no advantage for a method to be a built-in. In fact many times built-ins are at a severe disadvantage of having to implement far more complex semantics than is actually needed in practice. For example, sparse array handling punishes almost every built-in array method even though nobody uses sparse arrays as is evidenced by the popularity of the underscore library which doesn't handle sparse arrays in the same way across different browsers.
|
||||
|
||||
#Using double-ended queue as a normal queue
|
||||
|
||||
Queue is a more commonly needed data structure however a separate implementation does not provide any advantage in terms of performance. Aliases are provided specifically for the queue use-case. You may use `.enqueue(items...)` to enqueue item(s) and `.dequeue()` to dequeue an item.
|
||||
|
||||
#API
|
||||
|
||||
- [`new Deque()`](#new-deque---deque)
|
||||
- [`new Deque(Array items)`](#new-dequearray-items---deque)
|
||||
- [`new Deque(int capacity)`](#new-dequeint-capacity---deque)
|
||||
- [`push(dynamic items...)`](#pushdynamic-items---int)
|
||||
- [`unshift(dynamic items...)`](#unshiftdynamic-items---int)
|
||||
- [`pop()`](#pop---dynamic)
|
||||
- [`shift()`](#shift---dynamic)
|
||||
- [`toArray()`](#toarray---array)
|
||||
- [`peekBack()`](#peekback---dynamic)
|
||||
- [`peekFront()`](#peekfront---dynamic)
|
||||
- [`get(int index)`](#getint-index---dynamic)
|
||||
- [`isEmpty()`](#isempty---boolean)
|
||||
- [`clear()`](#clear---void)
|
||||
|
||||
#####`new Deque()` -> `Deque`
|
||||
|
||||
Creates an empty double-ended queue with initial capacity of 16. If you know the optimal size before-hand, use [].
|
||||
|
||||
```js
|
||||
var deque = new Deque();
|
||||
deque.push(1, 2, 3);
|
||||
deque.shift(); //1
|
||||
deque.pop(); //3
|
||||
```
|
||||
|
||||
<hr>
|
||||
|
||||
#####`new Deque(Array items)` -> `Deque`
|
||||
|
||||
Creates a double-ended queue from the `items`.
|
||||
|
||||
```js
|
||||
var deque = new Deque([1,2,3,4]);
|
||||
deque.shift(); //1
|
||||
deque.pop(); //4
|
||||
```
|
||||
|
||||
<hr>
|
||||
|
||||
#####`new Deque(int capacity)` -> `Deque`
|
||||
|
||||
Creates an empty double-ended queue with the given `capacity`. `Capacity` should be the maximum amount of items the queue will hold at a given time.
|
||||
|
||||
The reason to give an initial capacity is to avoid potentially expensive resizing operations at runtime.
|
||||
|
||||
```js
|
||||
var deque = new Deque(100);
|
||||
deque.push(1, 2, 3);
|
||||
deque.shift(); //1
|
||||
deque.pop(); //3
|
||||
```
|
||||
|
||||
<hr>
|
||||
|
||||
#####`push(dynamic items...)` -> `int`
|
||||
|
||||
Push items to the back of this queue. Returns the amount of items currently in the queue after the operation.
|
||||
|
||||
```js
|
||||
var deque = new Deque();
|
||||
deque.push(1);
|
||||
deque.pop(); //1
|
||||
deque.push(1, 2, 3);
|
||||
deque.shift(); //1
|
||||
deque.shift(); //2
|
||||
deque.shift(); //3
|
||||
```
|
||||
|
||||
**Aliases:** `enqueue`, `insertBack`
|
||||
|
||||
<hr>
|
||||
|
||||
#####`unshift(dynamic items...)` -> `int`
|
||||
|
||||
Unshift items to the front of this queue. Returns the amount of items currently in the queue after the operation.
|
||||
|
||||
```js
|
||||
var deque = new Deque([2,3]);
|
||||
deque.unshift(1);
|
||||
deque.toString(); //"1,2,3"
|
||||
deque.unshift(-2, -1, 0);
|
||||
deque.toString(); //"-2,-1,0,1,2,3"
|
||||
```
|
||||
|
||||
**Aliases:** `insertFront`
|
||||
|
||||
<hr>
|
||||
|
||||
|
||||
#####`pop()` -> `dynamic`
|
||||
|
||||
Pop off the item at the back of this queue.
|
||||
|
||||
Note: The item will be removed from the queue. If you simply want to see what's at the back of the queue use [`peekBack()`](#peekback---dynamic) or [`.get(-1)`](#getint-index---dynamic).
|
||||
|
||||
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.
|
||||
|
||||
```js
|
||||
var deque = new Deque([1,2,3]);
|
||||
deque.pop(); //3
|
||||
deque.pop(); //2
|
||||
deque.pop(); //1
|
||||
deque.pop(); //undefined
|
||||
```
|
||||
|
||||
**Aliases:** `removeBack`
|
||||
|
||||
<hr>
|
||||
|
||||
#####`shift()` -> `dynamic`
|
||||
|
||||
Shifts off the item at the front of this queue.
|
||||
|
||||
Note: The item will be removed from the queue. If you simply want to see what's at the front of the queue use [`peekFront()`](#peekfront---dynamic) or [`.get(0)`](#getint-index---dynamic).
|
||||
|
||||
If the queue is empty, `undefined` is returned. If you need to differentiate between `undefined` values in the queue and `shift()` return value -
|
||||
check the queue `.length` before shifting.
|
||||
|
||||
```js
|
||||
var deque = new Deque([1,2,3]);
|
||||
deque.shift(); //1
|
||||
deque.shift(); //2
|
||||
deque.shift(); //3
|
||||
deque.shift(); //undefined
|
||||
```
|
||||
|
||||
**Aliases:** `removeFront`, `dequeue`
|
||||
|
||||
<hr>
|
||||
|
||||
#####`toArray()` -> `Array`
|
||||
|
||||
Returns the items in the queue as an array. Starting from the item in the front of the queue and ending to the item at the back of the queue.
|
||||
|
||||
```js
|
||||
var deque = new Deque([1,2,3]);
|
||||
deque.push(4);
|
||||
deque.unshift(0);
|
||||
deque.toArray(); //[0,1,2,3,4]
|
||||
```
|
||||
|
||||
**Aliases:** `toJSON`
|
||||
|
||||
<hr>
|
||||
|
||||
#####`peekBack()` -> `dynamic`
|
||||
|
||||
Returns the item that is at the back of this queue without removing it.
|
||||
|
||||
If the queue is empty, `undefined` is returned.
|
||||
|
||||
```js
|
||||
var deque = new Deque([1,2,3]);
|
||||
deque.push(4);
|
||||
deque.peekBack(); //4
|
||||
```
|
||||
|
||||
<hr>
|
||||
|
||||
#####`peekFront()` -> `dynamic`
|
||||
|
||||
Returns the item that is at the front of this queue without removing it.
|
||||
|
||||
If the queue is empty, `undefined` is returned.
|
||||
|
||||
```js
|
||||
var deque = new Deque([1,2,3]);
|
||||
deque.push(4);
|
||||
deque.peekFront(); //1
|
||||
```
|
||||
|
||||
<hr>
|
||||
|
||||
#####`get(int index)` -> `dynamic`
|
||||
|
||||
Returns the item that is at the given `index` of this queue without removing it.
|
||||
|
||||
The index is zero-based, so `.get(0)` will return the item that is at the front, `.get(1)` will return
|
||||
the item that comes after and so on.
|
||||
|
||||
The index can be negative to read items at the back of the queue. `.get(-1)` returns the item that is at the back of the queue,
|
||||
`.get(-2)` will return the item that comes before and so on.
|
||||
|
||||
Returns `undefined` if `index` is not a valid index into the queue.
|
||||
|
||||
```js
|
||||
var deque = new Deque([1,2,3]);
|
||||
deque.get(0); //1
|
||||
deque.get(1); //2
|
||||
deque.get(2); //3
|
||||
|
||||
deque.get(-1); //3
|
||||
deque.get(-2); //2
|
||||
deque.get(-3); //1
|
||||
```
|
||||
|
||||
**Note**: Even though indexed accessor (e.g. `queue[0]`) could *appear* to return a correct value *sometimes*, this is completely unreliable. The numeric slots
|
||||
of the deque object are internally used as an optimization and have no meaningful order or meaning to outside. Always use `.get()`.
|
||||
|
||||
**Note**: The implementation has O(1) random access using `.get()`.
|
||||
|
||||
<hr>
|
||||
|
||||
#####`isEmpty()` -> `boolean`
|
||||
|
||||
Return `true` if this queue is empty, `false` otherwise.
|
||||
|
||||
```js
|
||||
var deque = new Deque();
|
||||
deque.isEmpty(); //true
|
||||
deque.push(1);
|
||||
deque.isEmpty(); //false
|
||||
```
|
||||
|
||||
<hr>
|
||||
|
||||
#####`clear()` -> `void`
|
||||
|
||||
Remove all items from this queue. Does not change the queue's capacity.
|
||||
|
||||
```js
|
||||
var deque = new Deque([1,2,3]);
|
||||
deque.toString(); //"1,2,3"
|
||||
deque.clear();
|
||||
deque.toString(); //""
|
||||
```
|
||||
<hr>
|
||||
|
||||
#Performance
|
||||
|
287
node_modules/double-ended-queue/js/deque.js
generated
vendored
Normal file
287
node_modules/double-ended-queue/js/deque.js
generated
vendored
Normal file
@ -0,0 +1,287 @@
|
||||
/**
|
||||
* Copyright (c) 2013 Petka Antonov
|
||||
*
|
||||
* 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:</p>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
"use strict";
|
||||
function Deque(capacity) {
|
||||
this._capacity = getCapacity(capacity);
|
||||
this._length = 0;
|
||||
this._front = 0;
|
||||
this._makeCapacity();
|
||||
if (isArray(capacity)) {
|
||||
var len = capacity.length;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
this[i] = capacity[i];
|
||||
}
|
||||
this._length = len;
|
||||
}
|
||||
}
|
||||
|
||||
Deque.prototype.toArray = function Deque$toArray() {
|
||||
var len = this._length;
|
||||
var ret = new Array(len);
|
||||
var front = this._front;
|
||||
var capacity = this._capacity;
|
||||
for (var j = 0; j < len; ++j) {
|
||||
ret[j] = this[(front + j) & (capacity - 1)];
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
Deque.prototype.push = function Deque$push(item) {
|
||||
var argsLength = arguments.length;
|
||||
var length = this._length;
|
||||
if (argsLength > 1) {
|
||||
var capacity = this._capacity;
|
||||
if (length + argsLength > capacity) {
|
||||
for (var i = 0; i < argsLength; ++i) {
|
||||
this._checkCapacity(length + 1);
|
||||
var j = (this._front + length) & (this._capacity - 1);
|
||||
this[j] = arguments[i];
|
||||
length++;
|
||||
this._length = length;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
else {
|
||||
var j = this._front;
|
||||
for (var i = 0; i < argsLength; ++i) {
|
||||
this[(j + length) & (capacity - 1)] = arguments[i];
|
||||
j++;
|
||||
}
|
||||
this._length = length + argsLength;
|
||||
return length + argsLength;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (argsLength === 0) return length;
|
||||
|
||||
this._checkCapacity(length + 1);
|
||||
var i = (this._front + length) & (this._capacity - 1);
|
||||
this[i] = item;
|
||||
this._length = length + 1;
|
||||
return length + 1;
|
||||
};
|
||||
|
||||
Deque.prototype.pop = function Deque$pop() {
|
||||
var length = this._length;
|
||||
if (length === 0) {
|
||||
return void 0;
|
||||
}
|
||||
var i = (this._front + length - 1) & (this._capacity - 1);
|
||||
var ret = this[i];
|
||||
this[i] = void 0;
|
||||
this._length = length - 1;
|
||||
return ret;
|
||||
};
|
||||
|
||||
Deque.prototype.shift = function Deque$shift() {
|
||||
var length = this._length;
|
||||
if (length === 0) {
|
||||
return void 0;
|
||||
}
|
||||
var front = this._front;
|
||||
var ret = this[front];
|
||||
this[front] = void 0;
|
||||
this._front = (front + 1) & (this._capacity - 1);
|
||||
this._length = length - 1;
|
||||
return ret;
|
||||
};
|
||||
|
||||
Deque.prototype.unshift = function Deque$unshift(item) {
|
||||
var length = this._length;
|
||||
var argsLength = arguments.length;
|
||||
|
||||
|
||||
if (argsLength > 1) {
|
||||
var capacity = this._capacity;
|
||||
if (length + argsLength > capacity) {
|
||||
for (var i = argsLength - 1; i >= 0; i--) {
|
||||
this._checkCapacity(length + 1);
|
||||
var capacity = this._capacity;
|
||||
var j = (((( this._front - 1 ) &
|
||||
( capacity - 1) ) ^ capacity ) - capacity );
|
||||
this[j] = arguments[i];
|
||||
length++;
|
||||
this._length = length;
|
||||
this._front = j;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
else {
|
||||
var front = this._front;
|
||||
for (var i = argsLength - 1; i >= 0; i--) {
|
||||
var j = (((( front - 1 ) &
|
||||
( capacity - 1) ) ^ capacity ) - capacity );
|
||||
this[j] = arguments[i];
|
||||
front = j;
|
||||
}
|
||||
this._front = front;
|
||||
this._length = length + argsLength;
|
||||
return length + argsLength;
|
||||
}
|
||||
}
|
||||
|
||||
if (argsLength === 0) return length;
|
||||
|
||||
this._checkCapacity(length + 1);
|
||||
var capacity = this._capacity;
|
||||
var i = (((( this._front - 1 ) &
|
||||
( capacity - 1) ) ^ capacity ) - capacity );
|
||||
this[i] = item;
|
||||
this._length = length + 1;
|
||||
this._front = i;
|
||||
return length + 1;
|
||||
};
|
||||
|
||||
Deque.prototype.peekBack = function Deque$peekBack() {
|
||||
var length = this._length;
|
||||
if (length === 0) {
|
||||
return void 0;
|
||||
}
|
||||
var index = (this._front + length - 1) & (this._capacity - 1);
|
||||
return this[index];
|
||||
};
|
||||
|
||||
Deque.prototype.peekFront = function Deque$peekFront() {
|
||||
if (this._length === 0) {
|
||||
return void 0;
|
||||
}
|
||||
return this[this._front];
|
||||
};
|
||||
|
||||
Deque.prototype.get = function Deque$get(index) {
|
||||
var i = index;
|
||||
if ((i !== (i | 0))) {
|
||||
return void 0;
|
||||
}
|
||||
var len = this._length;
|
||||
if (i < 0) {
|
||||
i = i + len;
|
||||
}
|
||||
if (i < 0 || i >= len) {
|
||||
return void 0;
|
||||
}
|
||||
return this[(this._front + i) & (this._capacity - 1)];
|
||||
};
|
||||
|
||||
Deque.prototype.isEmpty = function Deque$isEmpty() {
|
||||
return this._length === 0;
|
||||
};
|
||||
|
||||
Deque.prototype.clear = function Deque$clear() {
|
||||
this._length = 0;
|
||||
this._front = 0;
|
||||
this._makeCapacity();
|
||||
};
|
||||
|
||||
Deque.prototype.toString = function Deque$toString() {
|
||||
return this.toArray().toString();
|
||||
};
|
||||
|
||||
Deque.prototype.valueOf = Deque.prototype.toString;
|
||||
Deque.prototype.removeFront = Deque.prototype.shift;
|
||||
Deque.prototype.removeBack = Deque.prototype.pop;
|
||||
Deque.prototype.insertFront = Deque.prototype.unshift;
|
||||
Deque.prototype.insertBack = Deque.prototype.push;
|
||||
Deque.prototype.enqueue = Deque.prototype.push;
|
||||
Deque.prototype.dequeue = Deque.prototype.shift;
|
||||
Deque.prototype.toJSON = Deque.prototype.toArray;
|
||||
|
||||
Object.defineProperty(Deque.prototype, "length", {
|
||||
get: function() {
|
||||
return this._length;
|
||||
},
|
||||
set: function() {
|
||||
throw new RangeError("");
|
||||
}
|
||||
});
|
||||
|
||||
Deque.prototype._makeCapacity = function Deque$_makeCapacity() {
|
||||
var len = this._capacity;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
this[i] = void 0;
|
||||
}
|
||||
};
|
||||
|
||||
Deque.prototype._checkCapacity = function Deque$_checkCapacity(size) {
|
||||
if (this._capacity < size) {
|
||||
this._resizeTo(getCapacity(this._capacity * 1.5 + 16));
|
||||
}
|
||||
};
|
||||
|
||||
Deque.prototype._resizeTo = function Deque$_resizeTo(capacity) {
|
||||
var oldFront = this._front;
|
||||
var oldCapacity = this._capacity;
|
||||
var oldDeque = new Array(oldCapacity);
|
||||
var length = this._length;
|
||||
|
||||
arrayCopy(this, 0, oldDeque, 0, oldCapacity);
|
||||
this._capacity = capacity;
|
||||
this._makeCapacity();
|
||||
this._front = 0;
|
||||
if (oldFront + length <= oldCapacity) {
|
||||
arrayCopy(oldDeque, oldFront, this, 0, length);
|
||||
} else { var lengthBeforeWrapping =
|
||||
length - ((oldFront + length) & (oldCapacity - 1));
|
||||
|
||||
arrayCopy(oldDeque, oldFront, this, 0, lengthBeforeWrapping);
|
||||
arrayCopy(oldDeque, 0, this, lengthBeforeWrapping,
|
||||
length - lengthBeforeWrapping);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var isArray = Array.isArray;
|
||||
|
||||
function arrayCopy(src, srcIndex, dst, dstIndex, len) {
|
||||
for (var j = 0; j < len; ++j) {
|
||||
dst[j + dstIndex] = src[j + srcIndex];
|
||||
}
|
||||
}
|
||||
|
||||
function pow2AtLeast(n) {
|
||||
n = n >>> 0;
|
||||
n = n - 1;
|
||||
n = n | (n >> 1);
|
||||
n = n | (n >> 2);
|
||||
n = n | (n >> 4);
|
||||
n = n | (n >> 8);
|
||||
n = n | (n >> 16);
|
||||
return n + 1;
|
||||
}
|
||||
|
||||
function getCapacity(capacity) {
|
||||
if (typeof capacity !== "number") {
|
||||
if (isArray(capacity)) {
|
||||
capacity = capacity.length;
|
||||
}
|
||||
else {
|
||||
return 16;
|
||||
}
|
||||
}
|
||||
return pow2AtLeast(
|
||||
Math.min(
|
||||
Math.max(16, capacity), 1073741824)
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = Deque;
|
95
node_modules/double-ended-queue/package.json
generated
vendored
Normal file
95
node_modules/double-ended-queue/package.json
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "double-ended-queue@^0.9.7",
|
||||
"scope": null,
|
||||
"escapedName": "double-ended-queue",
|
||||
"name": "double-ended-queue",
|
||||
"rawSpec": "^0.9.7",
|
||||
"spec": ">=0.9.7 <0.10.0",
|
||||
"type": "range"
|
||||
},
|
||||
"/home/burchettm/statsbot/node_modules/discordie"
|
||||
]
|
||||
],
|
||||
"_from": "double-ended-queue@>=0.9.7 <0.10.0",
|
||||
"_id": "double-ended-queue@0.9.7",
|
||||
"_inCache": true,
|
||||
"_location": "/double-ended-queue",
|
||||
"_npmUser": {
|
||||
"name": "esailija",
|
||||
"email": "petka_antonov@hotmail.com"
|
||||
},
|
||||
"_npmVersion": "1.3.14",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "double-ended-queue@^0.9.7",
|
||||
"scope": null,
|
||||
"escapedName": "double-ended-queue",
|
||||
"name": "double-ended-queue",
|
||||
"rawSpec": "^0.9.7",
|
||||
"spec": ">=0.9.7 <0.10.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/discordie"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-0.9.7.tgz",
|
||||
"_shasum": "8ae0a7265df66cdc3f07dce558e9716adb586ab8",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "double-ended-queue@^0.9.7",
|
||||
"_where": "/home/burchettm/statsbot/node_modules/discordie",
|
||||
"author": {
|
||||
"name": "Petka Antonov",
|
||||
"email": "petka_antonov@hotmail.com",
|
||||
"url": "http://github.com/petkaantonov/"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "http://github.com/petkaantonov/deque/issues"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Extremely fast double-ended queue implementation",
|
||||
"devDependencies": {
|
||||
"acorn": "~0.3.1",
|
||||
"benchmark": "latest",
|
||||
"bluebird": "~0.11",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-cli": "~0.1.9",
|
||||
"grunt-contrib-jshint": "~0.6.4",
|
||||
"jshint-stylish": "latest",
|
||||
"mocha": "~1.12.1"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "8ae0a7265df66cdc3f07dce558e9716adb586ab8",
|
||||
"tarball": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-0.9.7.tgz"
|
||||
},
|
||||
"homepage": "https://github.com/petkaantonov/deque",
|
||||
"keywords": [
|
||||
"data-structure",
|
||||
"data-structures",
|
||||
"queue",
|
||||
"deque",
|
||||
"double-ended-queue"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./js/deque.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "esailija",
|
||||
"email": "petka_antonov@hotmail.com"
|
||||
}
|
||||
],
|
||||
"name": "double-ended-queue",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/petkaantonov/deque.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "grunt test"
|
||||
},
|
||||
"version": "0.9.7"
|
||||
}
|
Reference in New Issue
Block a user