We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f1faa36 commit a7c7027Copy full SHA for a7c7027
.gitignore
@@ -4,4 +4,5 @@ node_modules
4
.idea
5
datalib.js
6
datalib.min.js
7
-datalib.min.js.map
+datalib.min.js.map
8
+index.html
src/util/stats.js
@@ -15,7 +15,7 @@ stats.unique = function(data, f, results) {
15
return results;
16
};
17
18
-stats.uniq = function(data, f) {
+stats.distinct = function(data, f) {
19
if (!util.isArray(data) || data.length===0) return 0;
20
f = f || util.identity;
21
var u = {}, v, i, count = 0;;
test/stats.js
@@ -33,18 +33,18 @@ describe('stats', function() {
33
});
34
35
36
- describe('uniq', function() {
37
- it('should count unique values', function() {
38
- assert.equal(stats.uniq([3, 1, 2]), 3);
39
- assert.equal(stats.uniq([1, 1, 2, 1, 2, 3, 1, 2, 3, 3, 3]), 3);
+ describe('distinct', function() {
+ it('should count distinct values', function() {
+ assert.equal(stats.distinct([3, 1, 2]), 3);
+ assert.equal(stats.distinct([1, 1, 2, 1, 2, 3, 1, 2, 3, 3, 3]), 3);
40
41
42
it('should recognize null values', function() {
43
- assert.equal(stats.uniq([null, 1, 2]), 3);
+ assert.equal(stats.distinct([null, 1, 2]), 3);
44
45
46
it('should recognize undefined values', function() {
47
- assert.equal(stats.uniq([1, undefined, 2, undefined]), 3);
+ assert.equal(stats.distinct([1, undefined, 2, undefined]), 3);
48
49
50
0 commit comments