summary
Advanced tools
Comparing version 0.3.0 to 0.3.1
{ | ||
"name": "summary", | ||
"description": "Takes an array of numbers and calculates some descriptive statistics", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"author": "Andreas Madsen <amwebdk@gmail.com>", | ||
@@ -33,2 +33,2 @@ "main": "./summary.js", | ||
} | ||
} | ||
} |
var array_types = [ | ||
Array, Int8Array, Uint8Array, Int16Array, Uint16Array, | ||
Int32Array, Uint32Array, Float32Array, Float64Array | ||
]; | ||
function Summary(data, sorted) { | ||
if (!(this instanceof Summary)) return new Summary(data, sorted); | ||
if (!Array.isArray(data)) { | ||
if (array_types.indexOf(data.constructor) === -1) { | ||
throw TypeError('data must be an array'); | ||
@@ -7,0 +12,0 @@ } |
@@ -125,1 +125,7 @@ | ||
}); | ||
test('typed array', function (t) { | ||
t.equal(summary(new Int8Array([2, 4])).mean(), 3); | ||
t.end(); | ||
}); |
10341
231