nav tabs on admin dashboard
This commit is contained in:
2
node_modules/handle-thing/.npmignore
generated
vendored
2
node_modules/handle-thing/.npmignore
generated
vendored
@@ -1,2 +0,0 @@
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
14
node_modules/handle-thing/.travis.yml
generated
vendored
14
node_modules/handle-thing/.travis.yml
generated
vendored
@@ -1,5 +1,13 @@
|
||||
sudo: false
|
||||
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
- "iojs"
|
||||
- "6"
|
||||
- "8"
|
||||
- "10"
|
||||
|
||||
script:
|
||||
- npm run lint
|
||||
- npm test
|
||||
- npm run coverage
|
||||
|
||||
17
node_modules/handle-thing/README.md
generated
vendored
17
node_modules/handle-thing/README.md
generated
vendored
@@ -1,9 +1,22 @@
|
||||
# Handle Thing
|
||||
|
||||
[](http://travis-ci.org/indutny/handle-thing)
|
||||
[](http://travis-ci.org/spdy-http2/handle-thing)
|
||||
[](http://badge.fury.io/js/handle-thing)
|
||||
[](https://david-dm.org/spdy-http2/handle-thing)
|
||||
[](http://standardjs.com/)
|
||||
[](https://waffle.io/spdy-http2/node-spdy)
|
||||
|
||||
The right thing when you need it
|
||||
> Wrap Streams2 instance into a HandleWrap. The right thing when you need it
|
||||
|
||||
## Usage
|
||||
|
||||
### Examples
|
||||
|
||||
`soon™`
|
||||
|
||||
### API
|
||||
|
||||
`soon™`
|
||||
|
||||
## LICENSE
|
||||
|
||||
|
||||
570
node_modules/handle-thing/lib/handle.js
generated
vendored
570
node_modules/handle-thing/lib/handle.js
generated
vendored
@@ -1,437 +1,243 @@
|
||||
var assert = require('assert');
|
||||
var util = require('util');
|
||||
var assert = require('assert')
|
||||
var util = require('util')
|
||||
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var Buffer = require('buffer').Buffer;
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
var Buffer = require('buffer').Buffer
|
||||
|
||||
var Queue = require('./queue');
|
||||
var Queue = require('./queue')
|
||||
|
||||
// Node.js version
|
||||
var mode = /^v0\.8\./.test(process.version) ? 'rusty' :
|
||||
/^v0\.(9|10)\./.test(process.version) ? 'old' :
|
||||
'modern';
|
||||
var mode = 'modern'
|
||||
|
||||
function Handle(stream, options) {
|
||||
EventEmitter.call(this);
|
||||
function Handle (stream, options) {
|
||||
EventEmitter.call(this)
|
||||
|
||||
this._stream = stream;
|
||||
this._flowing = false;
|
||||
this._reading = false;
|
||||
this._options = options || {};
|
||||
this._stream = stream
|
||||
this._flowing = false
|
||||
this._reading = false
|
||||
this._options = options || {}
|
||||
|
||||
this.onread = null;
|
||||
this.onread = null
|
||||
|
||||
// Pending requests
|
||||
this.pending = new Queue();
|
||||
|
||||
// Start handle once `onread` is set
|
||||
if (mode === 'rusty') {
|
||||
var self = this;
|
||||
Object.defineProperty(this, 'onread', {
|
||||
set: function(value) {
|
||||
Object.defineProperty(self, 'onread', {
|
||||
value: value
|
||||
});
|
||||
process.nextTick(function() {
|
||||
self.readStart();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// NOTE: v0.8 has some odd .pause()/.resume() semantics in http.js
|
||||
if (mode === 'rusty')
|
||||
this.writeQueueSize = 0;
|
||||
else if (mode !== 'modern')
|
||||
this.writeQueueSize = 1;
|
||||
|
||||
if (mode === 'rusty') {
|
||||
if (this._stream)
|
||||
this._rustyInit();
|
||||
else
|
||||
this.once('stream', this._rustyInit);
|
||||
}
|
||||
this.pending = new Queue()
|
||||
}
|
||||
util.inherits(Handle, EventEmitter);
|
||||
module.exports = Handle;
|
||||
util.inherits(Handle, EventEmitter)
|
||||
module.exports = Handle
|
||||
|
||||
Handle.mode = mode;
|
||||
Handle.mode = mode
|
||||
|
||||
Handle.create = function create(stream, options) {
|
||||
return new Handle(stream, options);
|
||||
};
|
||||
Handle.create = function create (stream, options) {
|
||||
return new Handle(stream, options)
|
||||
}
|
||||
|
||||
Handle.prototype._queueReq = function _queueReq(type, req) {
|
||||
return this.pending.append(type, req);
|
||||
};
|
||||
Handle.prototype._queueReq = function _queueReq (type, req) {
|
||||
return this.pending.append(type, req)
|
||||
}
|
||||
|
||||
Handle.prototype._pendingList = function _pendingList() {
|
||||
var list = [];
|
||||
while (!this.pending.isEmpty())
|
||||
list.push(this.pending.first().dequeue());
|
||||
return list;
|
||||
};
|
||||
Handle.prototype._pendingList = function _pendingList () {
|
||||
var list = []
|
||||
while (!this.pending.isEmpty()) { list.push(this.pending.first().dequeue()) }
|
||||
return list
|
||||
}
|
||||
|
||||
Handle.prototype.setStream = function setStream(stream) {
|
||||
assert(this._stream === null, 'Can\'t set stream two times');
|
||||
this._stream = stream;
|
||||
Handle.prototype.setStream = function setStream (stream) {
|
||||
assert(this._stream === null, 'Can\'t set stream two times')
|
||||
this._stream = stream
|
||||
|
||||
this.emit('stream', stream);
|
||||
};
|
||||
this.emit('stream', stream)
|
||||
}
|
||||
|
||||
Handle.prototype.readStart = function readStart() {
|
||||
this._reading = true;
|
||||
Handle.prototype.readStart = function readStart () {
|
||||
this._reading = true
|
||||
|
||||
if (!this._stream) {
|
||||
this.once('stream', this.readStart);
|
||||
return 0;
|
||||
this.once('stream', this.readStart)
|
||||
return 0
|
||||
}
|
||||
|
||||
if (!this._flowing) {
|
||||
this._flowing = true;
|
||||
this._flow();
|
||||
this._flowing = true
|
||||
this._flow()
|
||||
}
|
||||
|
||||
this._stream.resume();
|
||||
return 0;
|
||||
};
|
||||
this._stream.resume()
|
||||
return 0
|
||||
}
|
||||
|
||||
Handle.prototype.readStop = function readStop() {
|
||||
this._reading = false;
|
||||
Handle.prototype.readStop = function readStop () {
|
||||
this._reading = false
|
||||
|
||||
if (!this._stream) {
|
||||
this.once('stream', this.readStop);
|
||||
return 0;
|
||||
this.once('stream', this.readStop)
|
||||
return 0
|
||||
}
|
||||
this._stream.pause();
|
||||
return 0;
|
||||
};
|
||||
this._stream.pause()
|
||||
return 0
|
||||
}
|
||||
|
||||
if (mode === 'modern') {
|
||||
var uv = process.binding('uv');
|
||||
var uv = process.binding('uv')
|
||||
|
||||
Handle.prototype._flow = function flow() {
|
||||
var self = this;
|
||||
this._stream.on('data', function(chunk) {
|
||||
self.onread(chunk.length, chunk);
|
||||
});
|
||||
Handle.prototype._flow = function flow () {
|
||||
var self = this
|
||||
this._stream.on('data', function (chunk) {
|
||||
self.onread(chunk.length, chunk)
|
||||
})
|
||||
|
||||
this._stream.on('end', function() {
|
||||
self.onread(uv.UV_EOF, new Buffer(0));
|
||||
});
|
||||
this._stream.on('end', function () {
|
||||
self.onread(uv.UV_EOF, Buffer.alloc(0))
|
||||
})
|
||||
|
||||
this._stream.on('close', function() {
|
||||
setImmediate(function() {
|
||||
if (self._reading)
|
||||
self.onread(uv.UV_ECONNRESET, new Buffer(0));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Handle.prototype._close = function _close() {
|
||||
var list = this._pendingList();
|
||||
|
||||
var self = this;
|
||||
setImmediate(function() {
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var req = list[i];
|
||||
req.oncomplete(uv.UV_ECANCELED, self, req);
|
||||
this._stream.on('close', function () {
|
||||
setImmediate(function () {
|
||||
if (self._reading) {
|
||||
self.onread(uv.UV_ECONNRESET, Buffer.alloc(0))
|
||||
}
|
||||
});
|
||||
|
||||
this.readStop();
|
||||
};
|
||||
} else if (mode === 'old') {
|
||||
Handle.prototype._flow = function flow() {
|
||||
var self = this;
|
||||
this._stream.on('data', function(chunk) {
|
||||
self.onread(chunk, 0, chunk.length);
|
||||
});
|
||||
|
||||
this._stream.on('end', function() {
|
||||
var errno = process._errno;
|
||||
process._errno = 'EOF';
|
||||
self.onread(null, 0, 0);
|
||||
if (process._errno === 'EOF')
|
||||
process._errno = errno;
|
||||
});
|
||||
|
||||
this._stream.on('close', function() {
|
||||
setImmediate(function() {
|
||||
if (!self._reading)
|
||||
return;
|
||||
|
||||
var errno = process._errno;
|
||||
process._errno = 'ECONNRESET';
|
||||
self.onread(null, 0, 0);
|
||||
if (process._errno === 'ECONNRESET')
|
||||
process._errno = errno;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Handle.prototype._close = function _close() {
|
||||
var list = this._pendingList();
|
||||
|
||||
var self = this;
|
||||
setImmediate(function() {
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
process._errno = 'CANCELED';
|
||||
var req = list[i];
|
||||
req.oncomplete(-1, self, req);
|
||||
}
|
||||
});
|
||||
|
||||
this.readStop();
|
||||
};
|
||||
} else {
|
||||
Handle.prototype._rustyInit = function _rustyInit() {
|
||||
var self = this;
|
||||
|
||||
this._stream.on('close', function() {
|
||||
process.nextTick(function() {
|
||||
if (!self._reading)
|
||||
return;
|
||||
|
||||
var errno = global.errno;
|
||||
global.errno = 'ECONNRESET';
|
||||
self.onread(null, 0, 0);
|
||||
if (global.errno === 'ECONNRESET')
|
||||
global.errno = errno;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Handle.prototype._flow = function flow() {
|
||||
var self = this;
|
||||
this._stream.on('data', function(chunk) {
|
||||
self.onread(chunk, 0, chunk.length);
|
||||
});
|
||||
|
||||
this._stream.on('end', function() {
|
||||
var errno = global.errno;
|
||||
global.errno = 'EOF';
|
||||
self.onread(null, 0, 0);
|
||||
if (global.errno === 'EOF')
|
||||
global.errno = errno;
|
||||
});
|
||||
};
|
||||
|
||||
Handle.prototype._close = function _close() {
|
||||
var list = this._pendingList();
|
||||
|
||||
var self = this;
|
||||
process.nextTick(function() {
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var req = list[i];
|
||||
global.errno = 'CANCELED';
|
||||
req.oncomplete(-1, self, req);
|
||||
}
|
||||
});
|
||||
|
||||
this.readStop();
|
||||
};
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
if (mode === 'modern') {
|
||||
Handle.prototype.shutdown = function shutdown(req) {
|
||||
var wrap = this._queueReq('shutdown', req);
|
||||
Handle.prototype._close = function _close () {
|
||||
var list = this._pendingList()
|
||||
|
||||
if (!this._stream) {
|
||||
this.once('stream', function() {
|
||||
this._shutdown(wrap);
|
||||
});
|
||||
return 0;
|
||||
var self = this
|
||||
setImmediate(function () {
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
var req = list[i]
|
||||
req.oncomplete(uv.UV_ECANCELED, self, req)
|
||||
}
|
||||
})
|
||||
|
||||
return this._shutdown(wrap);
|
||||
};
|
||||
|
||||
Handle.prototype._shutdown = function _shutdown(wrap) {
|
||||
var self = this;
|
||||
this._stream.end(function() {
|
||||
var req = wrap.dequeue();
|
||||
if (!req)
|
||||
return;
|
||||
|
||||
req.oncomplete(0, self, req);
|
||||
});
|
||||
return 0;
|
||||
};
|
||||
} else {
|
||||
Handle.prototype.shutdown = function shutdown(req) {
|
||||
if (!req)
|
||||
req = {};
|
||||
|
||||
var wrap = this._queueReq('shutdown', req);
|
||||
|
||||
if (!this._stream) {
|
||||
this.once('stream', function() {
|
||||
this._shutdown(wrap);
|
||||
});
|
||||
return req;
|
||||
}
|
||||
|
||||
this._shutdown(wrap);
|
||||
|
||||
return req;
|
||||
};
|
||||
|
||||
Handle.prototype._shutdown = function _shutdown(wrap) {
|
||||
var self = this;
|
||||
this._stream.end(function() {
|
||||
var req = wrap.dequeue();
|
||||
if (!req)
|
||||
return;
|
||||
req.oncomplete(0, self, req);
|
||||
});
|
||||
};
|
||||
this.readStop()
|
||||
}
|
||||
|
||||
if (mode !== 'rusty') {
|
||||
Handle.prototype.close = function close(callback) {
|
||||
this._close();
|
||||
Handle.prototype.shutdown = function shutdown (req) {
|
||||
var wrap = this._queueReq('shutdown', req)
|
||||
|
||||
if (!this._stream) {
|
||||
this.once('stream', function() {
|
||||
this.close(callback);
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
if (!this._stream) {
|
||||
this.once('stream', function () {
|
||||
this._shutdown(wrap)
|
||||
})
|
||||
return 0
|
||||
}
|
||||
|
||||
if (this._options.close)
|
||||
this._options.close(callback);
|
||||
else
|
||||
process.nextTick(callback);
|
||||
|
||||
return 0;
|
||||
};
|
||||
} else {
|
||||
Handle.prototype.close = function close() {
|
||||
this._close();
|
||||
|
||||
if (!this._stream)
|
||||
this.once('stream', this.close);
|
||||
else if (this._options.close)
|
||||
this._options.close(function() {});
|
||||
|
||||
return 0;
|
||||
};
|
||||
return this._shutdown(wrap)
|
||||
}
|
||||
|
||||
if (mode === 'modern') {
|
||||
Handle.prototype.writeEnc = function writeEnc(req, data, enc) {
|
||||
var wrap = this._queueReq('write', req);
|
||||
Handle.prototype._shutdown = function _shutdown (wrap) {
|
||||
var self = this
|
||||
this._stream.end(function () {
|
||||
var req = wrap.dequeue()
|
||||
if (!req) { return }
|
||||
|
||||
if (!this._stream) {
|
||||
this.once('stream', function() {
|
||||
this._writeEnc(wrap, req, data, enc);
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return this._writeEnc(wrap, req, data, enc);
|
||||
};
|
||||
|
||||
Handle.prototype._writeEnc = function _writeEnc(wrap, req, data, enc) {
|
||||
var self = this;
|
||||
|
||||
req.async = true;
|
||||
req.bytes = data.length;
|
||||
|
||||
if (wrap.isEmpty())
|
||||
return 0;
|
||||
|
||||
this._stream.write(data, enc, function() {
|
||||
var req = wrap.dequeue();
|
||||
if (!req)
|
||||
return;
|
||||
req.oncomplete(0, self, req);
|
||||
});
|
||||
|
||||
return 0;
|
||||
};
|
||||
} else {
|
||||
Handle.prototype.writeEnc = function writeEnc(data, ignored, enc, req) {
|
||||
if (!req)
|
||||
req = { bytes: data.length };
|
||||
|
||||
var wrap = this._queueReq('write', req);
|
||||
|
||||
if (!this._stream) {
|
||||
this.once('stream', function() {
|
||||
this._writeEnc(data, ignored, enc, wrap);
|
||||
});
|
||||
return req;
|
||||
}
|
||||
|
||||
this._writeEnc(data, ignored, enc, wrap);
|
||||
return req;
|
||||
};
|
||||
|
||||
Handle.prototype._writeEnc = function _writeEnc(data, ignored, enc, wrap) {
|
||||
var self = this;
|
||||
var buffer = new Buffer(data, enc);
|
||||
|
||||
if (wrap.isEmpty())
|
||||
return;
|
||||
|
||||
this._stream.write(buffer, function() {
|
||||
var req = wrap.dequeue();
|
||||
if (!req)
|
||||
return;
|
||||
req.oncomplete(0, self, req);
|
||||
});
|
||||
};
|
||||
req.oncomplete(0, self, req)
|
||||
})
|
||||
return 0
|
||||
}
|
||||
|
||||
Handle.prototype.writeBuffer = function writeBuffer(req, data) {
|
||||
return this.writeEnc(req, data, null);
|
||||
};
|
||||
Handle.prototype.close = function close (callback) {
|
||||
this._close()
|
||||
|
||||
Handle.prototype.writeAsciiString = function writeAsciiString(req, data) {
|
||||
return this.writeEnc(req, data, 'ascii');
|
||||
};
|
||||
if (!this._stream) {
|
||||
this.once('stream', function () {
|
||||
this.close(callback)
|
||||
})
|
||||
return 0
|
||||
}
|
||||
|
||||
Handle.prototype.writeUtf8String = function writeUtf8String(req, data) {
|
||||
return this.writeEnc(req, data, 'utf8');
|
||||
};
|
||||
if (this._options.close) {
|
||||
this._options.close(callback)
|
||||
} else {
|
||||
process.nextTick(callback)
|
||||
}
|
||||
|
||||
Handle.prototype.writeUcs2String = function writeUcs2String(req, data) {
|
||||
return this.writeEnc(req, data, 'ucs2');
|
||||
};
|
||||
return 0
|
||||
}
|
||||
|
||||
Handle.prototype.writeBinaryString = function writeBinaryString(req, data) {
|
||||
return this.writeEnc(req, data, 'binary');
|
||||
};
|
||||
Handle.prototype.writeEnc = function writeEnc (req, data, enc) {
|
||||
var wrap = this._queueReq('write', req)
|
||||
|
||||
Handle.prototype.writeLatin1String = function writeLatin1String(req, data) {
|
||||
return this.writeEnc(req, data, 'binary');
|
||||
};
|
||||
if (!this._stream) {
|
||||
this.once('stream', function () {
|
||||
this._writeEnc(wrap, req, data, enc)
|
||||
})
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
return this._writeEnc(wrap, req, data, enc)
|
||||
}
|
||||
|
||||
Handle.prototype._writeEnc = function _writeEnc (wrap, req, data, enc) {
|
||||
var self = this
|
||||
|
||||
req.async = true
|
||||
req.bytes = data.length
|
||||
|
||||
if (wrap.isEmpty()) {
|
||||
return 0
|
||||
}
|
||||
|
||||
this._stream.write(data, enc, function () {
|
||||
var req = wrap.dequeue()
|
||||
if (!req) { return }
|
||||
req.oncomplete(0, self, req)
|
||||
})
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {WriteWrap} req
|
||||
* @param {string[]} chunks
|
||||
* @param {Boolean} allBuffers
|
||||
*/
|
||||
Handle.prototype.writev = function _writev (req, chunks, allBuffers) {
|
||||
while (chunks.length > 0) {
|
||||
this._stream.write(chunks.shift(), chunks.shift())
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
Handle.prototype.writeBuffer = function writeBuffer (req, data) {
|
||||
return this.writeEnc(req, data, null)
|
||||
}
|
||||
|
||||
Handle.prototype.writeAsciiString = function writeAsciiString (req, data) {
|
||||
return this.writeEnc(req, data, 'ascii')
|
||||
}
|
||||
|
||||
Handle.prototype.writeUtf8String = function writeUtf8String (req, data) {
|
||||
return this.writeEnc(req, data, 'utf8')
|
||||
}
|
||||
|
||||
Handle.prototype.writeUcs2String = function writeUcs2String (req, data) {
|
||||
return this.writeEnc(req, data, 'ucs2')
|
||||
}
|
||||
|
||||
Handle.prototype.writeBinaryString = function writeBinaryString (req, data) {
|
||||
return this.writeEnc(req, data, 'binary')
|
||||
}
|
||||
|
||||
Handle.prototype.writeLatin1String = function writeLatin1String (req, data) {
|
||||
return this.writeEnc(req, data, 'binary')
|
||||
}
|
||||
|
||||
// v0.8
|
||||
Handle.prototype.getsockname = function getsockname() {
|
||||
if (this._options.getPeerName)
|
||||
return this._options.getPeerName();
|
||||
return null;
|
||||
};
|
||||
|
||||
if (mode === 'modern') {
|
||||
Handle.prototype.getpeername = function getpeername(out) {
|
||||
var res = this.getsockname();
|
||||
if (!res)
|
||||
return -1;
|
||||
|
||||
Object.keys(res).forEach(function(key) {
|
||||
out[key] = res[key];
|
||||
});
|
||||
|
||||
return 0;
|
||||
};
|
||||
} else {
|
||||
// v0.10
|
||||
Handle.prototype.getpeername = function getpeername() {
|
||||
return this.getsockname();
|
||||
};
|
||||
Handle.prototype.getsockname = function getsockname () {
|
||||
if (this._options.getPeerName) {
|
||||
return this._options.getPeerName()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
Handle.prototype.getpeername = function getpeername (out) {
|
||||
var res = this.getsockname()
|
||||
if (!res) { return -1 }
|
||||
|
||||
Object.keys(res).forEach(function (key) {
|
||||
out[key] = res[key]
|
||||
})
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
80
node_modules/handle-thing/lib/queue.js
generated
vendored
80
node_modules/handle-thing/lib/queue.js
generated
vendored
@@ -1,48 +1,48 @@
|
||||
function Queue() {
|
||||
this.head = new Item('head', null);
|
||||
function Queue () {
|
||||
this.head = new Item('head', null)
|
||||
}
|
||||
module.exports = Queue;
|
||||
module.exports = Queue
|
||||
|
||||
Queue.prototype.append = function append(kind, value) {
|
||||
var item = new Item(kind, value);
|
||||
this.head.prepend(item);
|
||||
return item;
|
||||
};
|
||||
|
||||
Queue.prototype.isEmpty = function isEmpty() {
|
||||
return this.head.prev === this.head;
|
||||
};
|
||||
|
||||
Queue.prototype.first = function first() {
|
||||
return this.head.next;
|
||||
};
|
||||
|
||||
function Item(kind, value) {
|
||||
this.prev = this;
|
||||
this.next = this;
|
||||
this.kind = kind;
|
||||
this.value = value;
|
||||
Queue.prototype.append = function append (kind, value) {
|
||||
var item = new Item(kind, value)
|
||||
this.head.prepend(item)
|
||||
return item
|
||||
}
|
||||
|
||||
Item.prototype.prepend = function prepend(other) {
|
||||
other.prev = this.prev;
|
||||
other.next = this;
|
||||
other.prev.next = other;
|
||||
other.next.prev = other;
|
||||
};
|
||||
Queue.prototype.isEmpty = function isEmpty () {
|
||||
return this.head.prev === this.head
|
||||
}
|
||||
|
||||
Item.prototype.dequeue = function dequeue() {
|
||||
var prev = this.prev;
|
||||
var next = this.next;
|
||||
Queue.prototype.first = function first () {
|
||||
return this.head.next
|
||||
}
|
||||
|
||||
prev.next = next;
|
||||
next.prev = prev;
|
||||
this.prev = this;
|
||||
this.next = this;
|
||||
function Item (kind, value) {
|
||||
this.prev = this
|
||||
this.next = this
|
||||
this.kind = kind
|
||||
this.value = value
|
||||
}
|
||||
|
||||
return this.value;
|
||||
};
|
||||
Item.prototype.prepend = function prepend (other) {
|
||||
other.prev = this.prev
|
||||
other.next = this
|
||||
other.prev.next = other
|
||||
other.next.prev = other
|
||||
}
|
||||
|
||||
Item.prototype.isEmpty = function isEmpty() {
|
||||
return this.prev === this;
|
||||
};
|
||||
Item.prototype.dequeue = function dequeue () {
|
||||
var prev = this.prev
|
||||
var next = this.next
|
||||
|
||||
prev.next = next
|
||||
next.prev = prev
|
||||
this.prev = this
|
||||
this.next = this
|
||||
|
||||
return this.value
|
||||
}
|
||||
|
||||
Item.prototype.isEmpty = function isEmpty () {
|
||||
return this.prev === this
|
||||
}
|
||||
|
||||
39
node_modules/handle-thing/package.json
generated
vendored
39
node_modules/handle-thing/package.json
generated
vendored
@@ -1,43 +1,46 @@
|
||||
{
|
||||
"_from": "handle-thing@^1.2.5",
|
||||
"_id": "handle-thing@1.2.5",
|
||||
"_from": "handle-thing@^2.0.0",
|
||||
"_id": "handle-thing@2.0.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-/Xqtcmvxpf0W38KbL3pmAdJxOcQ=",
|
||||
"_integrity": "sha512-d4sze1JNC454Wdo2fkuyzCr6aHcbL6PGGuFAz0Li/NcOm1tCHGnWDRmJP85dh9IhQErTc2svWFEX5xHIOo//kQ==",
|
||||
"_location": "/handle-thing",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "handle-thing@^1.2.5",
|
||||
"raw": "handle-thing@^2.0.0",
|
||||
"name": "handle-thing",
|
||||
"escapedName": "handle-thing",
|
||||
"rawSpec": "^1.2.5",
|
||||
"rawSpec": "^2.0.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.2.5"
|
||||
"fetchSpec": "^2.0.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/spdy"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-1.2.5.tgz",
|
||||
"_shasum": "fd7aad726bf1a5fd16dfc29b2f7a6601d27139c4",
|
||||
"_spec": "handle-thing@^1.2.5",
|
||||
"_resolved": "https://registry.npmjs.org/handle-thing/-/handle-thing-2.0.0.tgz",
|
||||
"_shasum": "0e039695ff50c93fc288557d696f3c1dc6776754",
|
||||
"_spec": "handle-thing@^2.0.0",
|
||||
"_where": "C:\\xampp\\htdocs\\w4rpservices\\node_modules\\spdy",
|
||||
"author": {
|
||||
"name": "Fedor Indutny",
|
||||
"email": "fedor@indutny.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/indutny/handle-thing/issues"
|
||||
"url": "https://github.com/spdy-http2/handle-thing/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Wrap Streams2 instance into a HandleWrap",
|
||||
"devDependencies": {
|
||||
"mocha": "^2.2.5",
|
||||
"readable-stream": "^2.0.1",
|
||||
"stream-pair": "^1.0.0"
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^5.2.0",
|
||||
"pre-commit": "^1.2.2",
|
||||
"readable-stream": "^3.0.6",
|
||||
"standard": "^12.0.1",
|
||||
"stream-pair": "^1.0.3"
|
||||
},
|
||||
"homepage": "https://github.com/indutny/handle-thing#readme",
|
||||
"homepage": "https://github.com/spdy-http2/handle-thing#readme",
|
||||
"keywords": [
|
||||
"handle",
|
||||
"net",
|
||||
@@ -46,12 +49,18 @@
|
||||
"license": "MIT",
|
||||
"main": "lib/handle.js",
|
||||
"name": "handle-thing",
|
||||
"pre-commit": [
|
||||
"lint",
|
||||
"test"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/indutny/handle-thing.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "istanbul cover node_modules/.bin/_mocha -- --reporter=spec test/**/*-test.js",
|
||||
"lint": "standard",
|
||||
"test": "mocha --reporter=spec test/*-test.js"
|
||||
},
|
||||
"version": "1.2.5"
|
||||
"version": "2.0.0"
|
||||
}
|
||||
|
||||
178
node_modules/handle-thing/test/api-test.js
generated
vendored
178
node_modules/handle-thing/test/api-test.js
generated
vendored
@@ -1,116 +1,110 @@
|
||||
var assert = require('assert');
|
||||
var net = require('net');
|
||||
var streamPair = require('stream-pair');
|
||||
/* eslint-env mocha */
|
||||
|
||||
var thing = require('../');
|
||||
var assert = require('assert')
|
||||
var net = require('net')
|
||||
var streamPair = require('stream-pair')
|
||||
|
||||
describe('Handle Thing', function() {
|
||||
var handle;
|
||||
var pair;
|
||||
var thing = require('../')
|
||||
|
||||
describe('Handle Thing', function () {
|
||||
var handle
|
||||
var pair
|
||||
var socket;
|
||||
|
||||
[ 'normal', 'lazy' ].forEach(function(mode) {
|
||||
describe(mode, function() {
|
||||
beforeEach(function() {
|
||||
pair = streamPair.create();
|
||||
handle = thing.create(mode === 'normal' ? pair.other : null);
|
||||
socket = new net.Socket({ handle: handle });
|
||||
[ 'normal', 'lazy' ].forEach(function (mode) {
|
||||
describe(mode, function () {
|
||||
beforeEach(function () {
|
||||
pair = streamPair.create()
|
||||
handle = thing.create(mode === 'normal' ? pair.other : null)
|
||||
socket = new net.Socket({
|
||||
handle: handle,
|
||||
readable: true,
|
||||
writable: true
|
||||
})
|
||||
|
||||
if (mode === 'lazy') {
|
||||
setTimeout(function() {
|
||||
handle.setStream(pair.other);
|
||||
}, 50);
|
||||
setTimeout(function () {
|
||||
handle.setStream(pair.other)
|
||||
}, 50)
|
||||
}
|
||||
})
|
||||
|
||||
// For v0.8
|
||||
socket.readable = true;
|
||||
socket.writable = true;
|
||||
});
|
||||
afterEach(function () {
|
||||
assert(handle._stream)
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
assert(handle._stream);
|
||||
});
|
||||
it('should write data to Socket', function (done) {
|
||||
pair.write('hello')
|
||||
pair.write(' world')
|
||||
pair.end('... ok')
|
||||
|
||||
it('should write data to Socket', function(done) {
|
||||
pair.write('hello');
|
||||
pair.write(' world');
|
||||
pair.end('... ok');
|
||||
|
||||
var chunks = '';
|
||||
socket.on('data', function(chunk) {
|
||||
chunks += chunk;
|
||||
});
|
||||
socket.on('end', function() {
|
||||
assert.equal(chunks, 'hello world... ok');
|
||||
var chunks = ''
|
||||
socket.on('data', function (chunk) {
|
||||
chunks += chunk
|
||||
})
|
||||
socket.on('end', function () {
|
||||
assert.strictEqual(chunks, 'hello world... ok')
|
||||
|
||||
// allowHalfOpen is `false`, so the `end` should be followed by `close`
|
||||
socket.once('close', function() {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
socket.once('close', function () {
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('should read data from Socket', function(done) {
|
||||
socket.write('hello');
|
||||
socket.write(' world');
|
||||
socket.end('... ok');
|
||||
it('should read data from Socket', function (done) {
|
||||
socket.write('hello')
|
||||
socket.write(' world')
|
||||
socket.end('... ok')
|
||||
|
||||
var chunks = '';
|
||||
pair.on('data', function(chunk) {
|
||||
chunks += chunk;
|
||||
});
|
||||
pair.on('end', function() {
|
||||
assert.equal(chunks, 'hello world... ok');
|
||||
var chunks = ''
|
||||
pair.on('data', function (chunk) {
|
||||
chunks += chunk
|
||||
})
|
||||
pair.on('end', function () {
|
||||
assert.strictEqual(chunks, 'hello world... ok')
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should invoke `close` callback', function(done) {
|
||||
handle._options.close = function(callback) {
|
||||
done();
|
||||
process.nextTick(callback);
|
||||
};
|
||||
it('should invoke `close` callback', function (done) {
|
||||
handle._options.close = function (callback) {
|
||||
done()
|
||||
process.nextTick(callback)
|
||||
}
|
||||
|
||||
pair.end('hello');
|
||||
socket.resume();
|
||||
});
|
||||
pair.end('hello')
|
||||
socket.resume()
|
||||
})
|
||||
|
||||
it('should kill pending requests', function(done) {
|
||||
handle._options.close = function() {
|
||||
setTimeout(done, 75);
|
||||
};
|
||||
it('should kill pending requests', function (done) {
|
||||
handle._options.close = function () {
|
||||
setTimeout(done, 75)
|
||||
}
|
||||
|
||||
socket.write('hello');
|
||||
socket.destroy();
|
||||
});
|
||||
socket.write('hello')
|
||||
socket.destroy()
|
||||
})
|
||||
|
||||
if (mode === 'normal') {
|
||||
it('should invoke `getPeerName` callback', function() {
|
||||
handle._options.getPeerName = function() {
|
||||
return { address: 'ohai' };
|
||||
};
|
||||
|
||||
assert.equal(socket.remoteAddress, 'ohai');
|
||||
});
|
||||
|
||||
it('should emit ECONNRESET at `close` event', function(done) {
|
||||
pair.other.emit('close');
|
||||
|
||||
// No error emitted in v0.8
|
||||
if (thing.mode === 'rusty') {
|
||||
socket.on('close', function() {
|
||||
done();
|
||||
});
|
||||
return;
|
||||
it('should invoke `getPeerName` callback', function () {
|
||||
handle._options.getPeerName = function () {
|
||||
return { address: 'ohai' }
|
||||
}
|
||||
|
||||
socket.on('error', function(err) {
|
||||
assert(/ECONNRESET/.test(err.message));
|
||||
done();
|
||||
});
|
||||
});
|
||||
assert.strictEqual(socket.remoteAddress, 'ohai')
|
||||
})
|
||||
|
||||
it('should emit ECONNRESET at `close` event', function (done) {
|
||||
pair.other.emit('close')
|
||||
|
||||
socket.on('error', function (err) {
|
||||
assert(/ECONNRESET/.test(err.message))
|
||||
done()
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user