From 703e03aba33f234712206769f57717ba7d92d23d Mon Sep 17 00:00:00 2001 From: LinuxWizard42 Date: Wed, 12 Oct 2022 22:54:37 +0300 Subject: Added export_allowed file to make repository visible in cgit --- node_modules/speedometer/LICENSE | 20 ++++++++++++++++++ node_modules/speedometer/README.md | 38 +++++++++++++++++++++++++++++++++++ node_modules/speedometer/index.js | 35 ++++++++++++++++++++++++++++++++ node_modules/speedometer/package.json | 14 +++++++++++++ 4 files changed, 107 insertions(+) create mode 100644 node_modules/speedometer/LICENSE create mode 100644 node_modules/speedometer/README.md create mode 100644 node_modules/speedometer/index.js create mode 100644 node_modules/speedometer/package.json (limited to 'node_modules/speedometer') diff --git a/node_modules/speedometer/LICENSE b/node_modules/speedometer/LICENSE new file mode 100644 index 0000000..4b30ed5 --- /dev/null +++ b/node_modules/speedometer/LICENSE @@ -0,0 +1,20 @@ +Copyright 2013 Mathias Buus + +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. diff --git a/node_modules/speedometer/README.md b/node_modules/speedometer/README.md new file mode 100644 index 0000000..f4e5711 --- /dev/null +++ b/node_modules/speedometer/README.md @@ -0,0 +1,38 @@ +# speedometer + +Speed measurement in Javascript + +``` +npm install speedometer +``` + +## Usage + +``` js +var speedometer = require('speedometer') +var fs = require('fs') + +// Let's measure how fast we can read from /dev/urandom +var speed = speedometer() +var stream = fs.createReadStream('/dev/urandom') + +stream.on('data', function(data) { + // Simply call speed with the amount of bytes transferred + var bytesPerSecond = speed(data.length) + + console.log(bytesPerSecond+' bytes/second') +}) +``` + +You can always get the current speed by calling `speed()`. + +Per default `speedometer` uses a 5 second buffer. +To change this simply pass another value to the constructor + +``` js +var speed = speedometer(20) // uses a 20s buffer instead +``` + +## License + +MIT diff --git a/node_modules/speedometer/index.js b/node_modules/speedometer/index.js new file mode 100644 index 0000000..5570fe0 --- /dev/null +++ b/node_modules/speedometer/index.js @@ -0,0 +1,35 @@ +var tick = 1 +var maxTick = 65535 +var resolution = 4 +var inc = function() { + tick = (tick + 1) & maxTick +} + +var timer = setInterval(inc, (1000 / resolution) | 0) +if (timer.unref) timer.unref() + +module.exports = function(seconds) { + var size = resolution * (seconds || 5) + var buffer = [0] + var pointer = 1 + var last = (tick-1) & maxTick + + return function(delta) { + var dist = (tick - last) & maxTick + if (dist > size) dist = size + last = tick + + while (dist--) { + if (pointer === size) pointer = 0 + buffer[pointer] = buffer[pointer === 0 ? size-1 : pointer-1] + pointer++ + } + + if (delta) buffer[pointer-1] += delta + + var top = buffer[pointer-1] + var btm = buffer.length < size ? 0 : buffer[pointer === size ? 0 : pointer] + + return buffer.length < resolution ? top : (top - btm) * resolution / buffer.length + } +} \ No newline at end of file diff --git a/node_modules/speedometer/package.json b/node_modules/speedometer/package.json new file mode 100644 index 0000000..d52fc66 --- /dev/null +++ b/node_modules/speedometer/package.json @@ -0,0 +1,14 @@ +{ + "name": "speedometer", + "version": "0.1.4", + "repository": "git://github.com/mafintosh/speedometer", + "description": "simple speed measurement in javascript", + "keywords": [ + "speed", + "bytes", + "per", + "second", + "transfer" + ], + "author": "Mathias Buus Madsen " +} -- cgit v1.2.3-86-g962b