Updated the Survey.
This commit is contained in:
		
							parent
							
								
									f59686eae0
								
							
						
					
					
						commit
						6d3ba1a714
					
				
					 1203 changed files with 140782 additions and 5 deletions
				
			
		
							
								
								
									
										21
									
								
								node_modules/@szmarczak/http-timer/LICENSE
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								node_modules/@szmarczak/http-timer/LICENSE
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
MIT License
 | 
			
		||||
 | 
			
		||||
Copyright (c) 2018 Szymon Marczak
 | 
			
		||||
 | 
			
		||||
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.
 | 
			
		||||
							
								
								
									
										70
									
								
								node_modules/@szmarczak/http-timer/README.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								node_modules/@szmarczak/http-timer/README.md
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,70 @@
 | 
			
		|||
# http-timer
 | 
			
		||||
> Timings for HTTP requests
 | 
			
		||||
 | 
			
		||||
[](https://travis-ci.org/szmarczak/http-timer)
 | 
			
		||||
[](https://coveralls.io/github/szmarczak/http-timer?branch=master)
 | 
			
		||||
[](https://packagephobia.now.sh/result?p=@szmarczak/http-timer)
 | 
			
		||||
 | 
			
		||||
Inspired by the [`request` package](https://github.com/request/request).
 | 
			
		||||
 | 
			
		||||
## Usage
 | 
			
		||||
```js
 | 
			
		||||
'use strict';
 | 
			
		||||
const https = require('https');
 | 
			
		||||
const timer = require('@szmarczak/http-timer');
 | 
			
		||||
 | 
			
		||||
const request = https.get('https://httpbin.org/anything');
 | 
			
		||||
const timings = timer(request);
 | 
			
		||||
 | 
			
		||||
request.on('response', response => {
 | 
			
		||||
	response.on('data', () => {}); // Consume the data somehow
 | 
			
		||||
	response.on('end', () => {
 | 
			
		||||
		console.log(timings);
 | 
			
		||||
	});
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
// { start: 1535708511443,
 | 
			
		||||
//   socket: 1535708511444,
 | 
			
		||||
//   lookup: 1535708511444,
 | 
			
		||||
//   connect: 1535708511582,
 | 
			
		||||
//   upload: 1535708511887,
 | 
			
		||||
//   response: 1535708512037,
 | 
			
		||||
//   end: 1535708512040,
 | 
			
		||||
//   phases:
 | 
			
		||||
//    { wait: 1,
 | 
			
		||||
//      dns: 0,
 | 
			
		||||
//      tcp: 138,
 | 
			
		||||
//      request: 305,
 | 
			
		||||
//      firstByte: 150,
 | 
			
		||||
//      download: 3,
 | 
			
		||||
//      total: 597 } }
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## API
 | 
			
		||||
 | 
			
		||||
### timer(request)
 | 
			
		||||
 | 
			
		||||
Returns: `Object`
 | 
			
		||||
 | 
			
		||||
- `start` - Time when the request started.
 | 
			
		||||
- `socket` - Time when a socket was assigned to the request.
 | 
			
		||||
- `lookup` - Time when the DNS lookup finished.
 | 
			
		||||
- `connect` - Time when the socket successfully connected.
 | 
			
		||||
- `upload` - Time when the request finished uploading.
 | 
			
		||||
- `response` - Time when the request fired the `response` event.
 | 
			
		||||
- `end` - Time when the response fired the `end` event.
 | 
			
		||||
- `error` - Time when the request fired the `error` event.
 | 
			
		||||
- `phases`
 | 
			
		||||
	- `wait` - `timings.socket - timings.start`
 | 
			
		||||
	- `dns` - `timings.lookup - timings.socket`
 | 
			
		||||
	- `tcp` - `timings.connect - timings.lookup`
 | 
			
		||||
	- `request` - `timings.upload - timings.connect`
 | 
			
		||||
	- `firstByte` - `timings.response - timings.upload`
 | 
			
		||||
	- `download` - `timings.end - timings.response`
 | 
			
		||||
	- `total` - `timings.end - timings.start` or `timings.error - timings.start`
 | 
			
		||||
 | 
			
		||||
**Note**: The time is a `number` representing the milliseconds elapsed since the UNIX epoch.
 | 
			
		||||
 | 
			
		||||
## License
 | 
			
		||||
 | 
			
		||||
MIT
 | 
			
		||||
							
								
								
									
										75
									
								
								node_modules/@szmarczak/http-timer/package.json
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								node_modules/@szmarczak/http-timer/package.json
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,75 @@
 | 
			
		|||
{
 | 
			
		||||
  "_from": "@szmarczak/http-timer@^1.1.2",
 | 
			
		||||
  "_id": "@szmarczak/http-timer@1.1.2",
 | 
			
		||||
  "_inBundle": false,
 | 
			
		||||
  "_integrity": "sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA==",
 | 
			
		||||
  "_location": "/@szmarczak/http-timer",
 | 
			
		||||
  "_phantomChildren": {},
 | 
			
		||||
  "_requested": {
 | 
			
		||||
    "type": "range",
 | 
			
		||||
    "registry": true,
 | 
			
		||||
    "raw": "@szmarczak/http-timer@^1.1.2",
 | 
			
		||||
    "name": "@szmarczak/http-timer",
 | 
			
		||||
    "escapedName": "@szmarczak%2fhttp-timer",
 | 
			
		||||
    "scope": "@szmarczak",
 | 
			
		||||
    "rawSpec": "^1.1.2",
 | 
			
		||||
    "saveSpec": null,
 | 
			
		||||
    "fetchSpec": "^1.1.2"
 | 
			
		||||
  },
 | 
			
		||||
  "_requiredBy": [
 | 
			
		||||
    "/got"
 | 
			
		||||
  ],
 | 
			
		||||
  "_resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-1.1.2.tgz",
 | 
			
		||||
  "_shasum": "b1665e2c461a2cd92f4c1bbf50d5454de0d4b421",
 | 
			
		||||
  "_spec": "@szmarczak/http-timer@^1.1.2",
 | 
			
		||||
  "_where": "D:\\Documents\\UniWork\\Year 4\\Semester 2\\SEG3125\\Labs\\Lab 6\\Survey_Analysis\\node_modules\\got",
 | 
			
		||||
  "author": {
 | 
			
		||||
    "name": "Szymon Marczak"
 | 
			
		||||
  },
 | 
			
		||||
  "bugs": {
 | 
			
		||||
    "url": "https://github.com/szmarczak/http-timer/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "bundleDependencies": false,
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "defer-to-connect": "^1.0.1"
 | 
			
		||||
  },
 | 
			
		||||
  "deprecated": false,
 | 
			
		||||
  "description": "Timings for HTTP requests",
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "ava": "^0.25.0",
 | 
			
		||||
    "coveralls": "^3.0.2",
 | 
			
		||||
    "nyc": "^12.0.2",
 | 
			
		||||
    "p-event": "^2.1.0",
 | 
			
		||||
    "xo": "^0.22.0"
 | 
			
		||||
  },
 | 
			
		||||
  "engines": {
 | 
			
		||||
    "node": ">=6"
 | 
			
		||||
  },
 | 
			
		||||
  "files": [
 | 
			
		||||
    "source"
 | 
			
		||||
  ],
 | 
			
		||||
  "homepage": "https://github.com/szmarczak/http-timer#readme",
 | 
			
		||||
  "keywords": [
 | 
			
		||||
    "http",
 | 
			
		||||
    "https",
 | 
			
		||||
    "timer",
 | 
			
		||||
    "timings"
 | 
			
		||||
  ],
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "main": "source",
 | 
			
		||||
  "name": "@szmarczak/http-timer",
 | 
			
		||||
  "repository": {
 | 
			
		||||
    "type": "git",
 | 
			
		||||
    "url": "git+https://github.com/szmarczak/http-timer.git"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "coveralls": "nyc report --reporter=text-lcov | coveralls",
 | 
			
		||||
    "test": "xo && nyc ava"
 | 
			
		||||
  },
 | 
			
		||||
  "version": "1.1.2",
 | 
			
		||||
  "xo": {
 | 
			
		||||
    "rules": {
 | 
			
		||||
      "unicorn/filename-case": "camelCase"
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										99
									
								
								node_modules/@szmarczak/http-timer/source/index.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										99
									
								
								node_modules/@szmarczak/http-timer/source/index.js
									
										
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,99 @@
 | 
			
		|||
'use strict';
 | 
			
		||||
const deferToConnect = require('defer-to-connect');
 | 
			
		||||
 | 
			
		||||
module.exports = request => {
 | 
			
		||||
	const timings = {
 | 
			
		||||
		start: Date.now(),
 | 
			
		||||
		socket: null,
 | 
			
		||||
		lookup: null,
 | 
			
		||||
		connect: null,
 | 
			
		||||
		upload: null,
 | 
			
		||||
		response: null,
 | 
			
		||||
		end: null,
 | 
			
		||||
		error: null,
 | 
			
		||||
		phases: {
 | 
			
		||||
			wait: null,
 | 
			
		||||
			dns: null,
 | 
			
		||||
			tcp: null,
 | 
			
		||||
			request: null,
 | 
			
		||||
			firstByte: null,
 | 
			
		||||
			download: null,
 | 
			
		||||
			total: null
 | 
			
		||||
		}
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	const handleError = origin => {
 | 
			
		||||
		const emit = origin.emit.bind(origin);
 | 
			
		||||
		origin.emit = (event, ...args) => {
 | 
			
		||||
			// Catches the `error` event
 | 
			
		||||
			if (event === 'error') {
 | 
			
		||||
				timings.error = Date.now();
 | 
			
		||||
				timings.phases.total = timings.error - timings.start;
 | 
			
		||||
 | 
			
		||||
				origin.emit = emit;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			// Saves the original behavior
 | 
			
		||||
			return emit(event, ...args);
 | 
			
		||||
		};
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	let uploadFinished = false;
 | 
			
		||||
	const onUpload = () => {
 | 
			
		||||
		timings.upload = Date.now();
 | 
			
		||||
		timings.phases.request = timings.upload - timings.connect;
 | 
			
		||||
	};
 | 
			
		||||
 | 
			
		||||
	handleError(request);
 | 
			
		||||
 | 
			
		||||
	request.once('socket', socket => {
 | 
			
		||||
		timings.socket = Date.now();
 | 
			
		||||
		timings.phases.wait = timings.socket - timings.start;
 | 
			
		||||
 | 
			
		||||
		const lookupListener = () => {
 | 
			
		||||
			timings.lookup = Date.now();
 | 
			
		||||
			timings.phases.dns = timings.lookup - timings.socket;
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
		socket.once('lookup', lookupListener);
 | 
			
		||||
 | 
			
		||||
		deferToConnect(socket, () => {
 | 
			
		||||
			timings.connect = Date.now();
 | 
			
		||||
 | 
			
		||||
			if (timings.lookup === null) {
 | 
			
		||||
				socket.removeListener('lookup', lookupListener);
 | 
			
		||||
				timings.lookup = timings.connect;
 | 
			
		||||
				timings.phases.dns = timings.lookup - timings.socket;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			timings.phases.tcp = timings.connect - timings.lookup;
 | 
			
		||||
 | 
			
		||||
			if (uploadFinished && !timings.upload) {
 | 
			
		||||
				onUpload();
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	request.once('finish', () => {
 | 
			
		||||
		uploadFinished = true;
 | 
			
		||||
 | 
			
		||||
		if (timings.connect) {
 | 
			
		||||
			onUpload();
 | 
			
		||||
		}
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	request.once('response', response => {
 | 
			
		||||
		timings.response = Date.now();
 | 
			
		||||
		timings.phases.firstByte = timings.response - timings.upload;
 | 
			
		||||
 | 
			
		||||
		handleError(response);
 | 
			
		||||
 | 
			
		||||
		response.once('end', () => {
 | 
			
		||||
			timings.end = Date.now();
 | 
			
		||||
			timings.phases.download = timings.end - timings.response;
 | 
			
		||||
			timings.phases.total = timings.end - timings.start;
 | 
			
		||||
		});
 | 
			
		||||
	});
 | 
			
		||||
 | 
			
		||||
	return timings;
 | 
			
		||||
};
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue