Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

average

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

average - npm Package Compare versions

Comparing version 0.1.0 to 1.0.0

.nyc_output/ae764f35-2e87-463e-a1e5-0d26abba5571.json

4

package.json
{
"name": "average",
"version": "0.1.0",
"version": "1.0.0",
"description": "Mathematical average. Sum of all values divided by the number of values provided.",

@@ -31,4 +31,4 @@ "main": "src/average.js",

"devDependencies": {
"tap": "~0.4.8"
"tap": "^14.11.0"
}
}
module.exports = function average(values) {
for (var i = 0, sum = 0, l = values.length; i < l; ++i) {
sum += values[i];
}
return sum / l;
return values.reduce(function (previousValue, currentValue) {
return previousValue + currentValue
}) / values.length
};

@@ -6,3 +6,3 @@ var average = require('../');

test('average', function (t) {
t.plan(2);
t.plan(3);

@@ -14,2 +14,5 @@ result = average([10, 10, 10, 10]);

t.ok(result === 5.3, 'average should be 5.3');
result = average(new Uint8Array([77, 77, 0, 42, 0, 12, 0, 8, 226, 137]));
t.ok(result === 57.9, 'average on Uint8Array array should be 57.9');
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc