Socket
Socket
Sign inDemoInstall

summary

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.3.0

2

package.json
{
"name": "summary",
"description": "Takes an array of numbers and calculates some descriptive statistics",
"version": "0.2.0",
"version": "0.3.0",
"author": "Andreas Madsen <amwebdk@gmail.com>",

@@ -6,0 +6,0 @@ "main": "./summary.js",

@@ -29,4 +29,7 @@ #summary

// Data is sorted from small to big
var data = summary([-1, 0, 1], true);
var data = summary([-1, 0, 1], true);
// Data is sorted, but summary dosn't know. Works fine just a bit slower.
var data = summary([-1, 0, 1] /*, default false */);
// Data is sorted in reverse order

@@ -60,2 +63,5 @@ var data = summary([1, 0, -1] /*, default false */);

data.sd(); // Returns the standard deviation
data.max(); // Returns the maximum value
data.min(); // Returns the minimum value
```

@@ -62,0 +68,0 @@

@@ -14,3 +14,3 @@

this._cache_sum = null;
this._cache_mode = null;
this._cache_mode = null;
this._cache_mean = null;

@@ -20,2 +20,4 @@ this._cache_quartiles = {};

this._cache_sd = null;
this._cache_max = null;
this._cache_min = null;
}

@@ -26,3 +28,3 @@ module.exports = Summary;

// Not all values are in lazy calculated since that wouldn't do any good
//
//
Summary.prototype.sort = function() {

@@ -121,3 +123,3 @@ if (this._sorted === false) {

Summary.prototype.median = function () {
return this.quartile(0.5);
return this.quartile(0.5);
};

@@ -132,3 +134,3 @@

}
this._cache_variance = sqsum / (this._length - 1);

@@ -147,1 +149,17 @@ }

};
Summary.prototype.max = function () {
if (this._cache_max === null) {
this._cache_max = this.sort()[this._length - 1];
}
return this._cache_max;
};
Summary.prototype.min = function () {
if (this._cache_min === null) {
this._cache_min = this.sort()[0];
}
return this._cache_min;
};

@@ -29,3 +29,3 @@

);
t.end();

@@ -39,3 +39,3 @@ });

);
t.end();

@@ -115,1 +115,13 @@ });

});
test('testing max method', function (t) {
t.equal(summary([6, 10, 2, 5]).max(), 10);
t.end();
});
test('testing min method', function (t) {
t.equal(summary([6, 10, 2, 5]).min(), 2);
t.end();
});
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc