Comparing version 0.1.0 to 1.0.0
{ | ||
"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'); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5185
10
16
1