Updated the files.

This commit is contained in:
Batuhan Berk Başoğlu 2024-02-08 19:38:41 -05:00
parent 1553e6b971
commit 753967d4f5
23418 changed files with 3784666 additions and 0 deletions

15
my-app/node_modules/handle-thing/.travis.yml generated vendored Executable file
View file

@ -0,0 +1,15 @@
sudo: false
language: node_js
node_js:
- "6"
- "8"
- "10"
- "11.1"
- "12"
script:
- npm run lint
- npm test
- npm run coverage

44
my-app/node_modules/handle-thing/README.md generated vendored Executable file
View file

@ -0,0 +1,44 @@
# Handle Thing
[![Build Status](https://travis-ci.org/spdy-http2/handle-thing.svg?branch=master)](http://travis-ci.org/spdy-http2/handle-thing)
[![NPM version](https://badge.fury.io/js/handle-thing.svg)](http://badge.fury.io/js/handle-thing)
[![dependencies Status](https://david-dm.org/spdy-http2/handle-thing/status.svg?style=flat-square)](https://david-dm.org/spdy-http2/handle-thing)
[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg?style=flat-square)](http://standardjs.com/)
[![Waffle](https://img.shields.io/badge/track-waffle-blue.svg?style=flat-square)](https://waffle.io/spdy-http2/node-spdy)
> Wrap Streams2 instance into a HandleWrap. The right thing when you need it
## Usage
### Examples
`soon™`
### API
`soon™`
## LICENSE
This software is licensed under the MIT License.
Copyright Fedor Indutny, 2015.
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.

263
my-app/node_modules/handle-thing/lib/handle.js generated vendored Executable file
View file

@ -0,0 +1,263 @@
var assert = require('assert')
var util = require('util')
var EventEmitter = require('events').EventEmitter
var Buffer = require('buffer').Buffer
var Queue = require('./queue')
// Node.js version
var match = /^v(\d+)\.(\d+)\./.exec(process.version)
var version = match ? Number(match[1]) + Number('0.' + match[2]) : 11
var onreadMode = version >= 11.1 ? 2 : 1
var mode = 'modern'
var setNRead
if (onreadMode === 2) {
var sw = process.binding('stream_wrap')
setNRead = function (nread) {
sw.streamBaseState[sw.kReadBytesOrError] = nread
}
}
function Handle (stream, options) {
EventEmitter.call(this)
this._stream = stream
this._flowing = false
this._reading = false
this._options = options || {}
this.onread = null
// Pending requests
this.pending = new Queue()
}
util.inherits(Handle, EventEmitter)
module.exports = Handle
Handle.mode = mode
Handle.create = function create (stream, options) {
return new Handle(stream, options)
}
Handle.prototype._onread = function _onread (nread, buffer) {
if (onreadMode === 1) {
this.onread(nread, buffer)
} else {
setNRead(nread)
this.onread(buffer)
}
}
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.setStream = function setStream (stream) {
assert(this._stream === null, 'Can\'t set stream two times')
this._stream = stream
this.emit('stream', stream)
}
Handle.prototype.readStart = function readStart () {
this._reading = true
if (!this._stream) {
this.once('stream', this.readStart)
return 0
}
if (!this._flowing) {
this._flowing = true
this._flow()
}
this._stream.resume()
return 0
}
Handle.prototype.readStop = function readStop () {
this._reading = false
if (!this._stream) {
this.once('stream', this.readStop)
return 0
}
this._stream.pause()
return 0
}
var uv = process.binding('uv')
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, Buffer.alloc(0))
})
this._stream.on('close', function () {
setImmediate(function () {
if (self._reading) {
self._onread(uv.UV_ECONNRESET, Buffer.alloc(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.readStop()
}
Handle.prototype.shutdown = function shutdown (req) {
var wrap = this._queueReq('shutdown', req)
if (!this._stream) {
this.once('stream', function () {
this._shutdown(wrap)
})
return 0
}
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
}
Handle.prototype.close = function close (callback) {
this._close()
if (!this._stream) {
this.once('stream', function () {
this.close(callback)
})
return 0
}
if (this._options.close) {
this._options.close(callback)
} else {
process.nextTick(callback)
}
return 0
}
Handle.prototype.writeEnc = function writeEnc (req, data, enc) {
var wrap = this._queueReq('write', req)
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
}
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
}

48
my-app/node_modules/handle-thing/lib/queue.js generated vendored Executable file
View file

@ -0,0 +1,48 @@
function Queue () {
this.head = new Item('head', null)
}
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
}
Item.prototype.prepend = function prepend (other) {
other.prev = this.prev
other.next = this
other.prev.next = other
other.next.prev = other
}
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
}

38
my-app/node_modules/handle-thing/package.json generated vendored Executable file
View file

@ -0,0 +1,38 @@
{
"name": "handle-thing",
"version": "2.0.1",
"description": "Wrap Streams2 instance into a HandleWrap",
"main": "lib/handle.js",
"scripts": {
"lint": "standard",
"test": "mocha --reporter=spec test/*-test.js",
"coverage": "istanbul cover node_modules/.bin/_mocha -- --reporter=spec test/**/*-test.js"
},
"pre-commit": [
"lint",
"test"
],
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/indutny/handle-thing.git"
},
"keywords": [
"handle",
"net",
"streams2"
],
"author": "Fedor Indutny <fedor@indutny.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/spdy-http2/handle-thing/issues"
},
"homepage": "https://github.com/spdy-http2/handle-thing#readme",
"devDependencies": {
"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"
}
}

110
my-app/node_modules/handle-thing/test/api-test.js generated vendored Executable file
View file

@ -0,0 +1,110 @@
/* eslint-env mocha */
var assert = require('assert')
var net = require('net')
var streamPair = require('stream-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,
readable: true,
writable: true
})
if (mode === 'lazy') {
setTimeout(function () {
handle.setStream(pair.other)
}, 50)
}
})
afterEach(function () {
assert(handle._stream)
})
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.strictEqual(chunks, 'hello world... ok')
// allowHalfOpen is `false`, so the `end` should be followed by `close`
socket.once('close', function () {
done()
})
})
})
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.strictEqual(chunks, 'hello world... ok')
done()
})
})
it('should invoke `close` callback', function (done) {
handle._options.close = function (callback) {
done()
process.nextTick(callback)
}
pair.end('hello')
socket.resume()
})
it('should kill pending requests', function (done) {
handle._options.close = function () {
setTimeout(done, 75)
}
socket.write('hello')
socket.destroy()
})
if (mode === 'normal') {
it('should invoke `getPeerName` callback', function () {
handle._options.getPeerName = function () {
return { address: 'ohai' }
}
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()
})
})
}
})
})
})