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

average-rating

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

average-rating - npm Package Compare versions

Comparing version 0.2.31 to 0.3.0

14

package.json
{
"version": "0.2.31",
"version": "0.3.0",
"name": "average-rating",

@@ -16,8 +16,12 @@ "description": "Calculate average score and rating based on Wilson Score Equation",

"scripts": {
"test": "mocha test"
"test": "./node_modules/.bin/tape test/start.js | tap-spec",
"coverage": "./node_modules/.bin/nyc tape test/start.js | tap-spec",
"report": "npm run coverage && ./node_modules/.bin/nyc report --reporter=lcov",
"coveralls": "npm run report && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls"
},
"devDependencies": {
"bellajs": "latest",
"mocha": "latest",
"chai": "latest"
"coveralls": "latest",
"nyc": "latest",
"tap-spec": "latest",
"tape": "latest"
},

@@ -24,0 +28,0 @@ "keywords": [

# average-rating
Calculate average and scoring based on Wilson Score Equation
[![NPM](https://badge.fury.io/js/average-rating.svg)](https://badge.fury.io/js/average-rating) ![Travis](https://travis-ci.org/ndaidong/average-rating.svg?branch=master)
[![NPM](https://badge.fury.io/js/average-rating.svg)](https://badge.fury.io/js/average-rating)
![Travis](https://travis-ci.org/ndaidong/average-rating.svg?branch=master)
[![Coverage Status](https://coveralls.io/repos/github/ndaidong/average-rating/badge.svg?branch=master)](https://coveralls.io/github/ndaidong/average-rating?branch=master)

@@ -28,5 +30,8 @@ ![Google app on Google Play](http://i.imgur.com/NgQX5OW.png)

npm install
mocha
npm test
```
_* Ensure that you have [mocha](https://mochajs.org/) installed_
# License
The MIT License (MIT)

@@ -5,3 +5,3 @@ /**

*/
/* global describe it */
/* eslint no-undefined: 0*/

@@ -14,7 +14,4 @@ /* eslint no-array-constructor: 0*/

var path = require('path');
var chai = require('chai');
var test = require('tape');
chai.should();
var expect = chai.expect;
var samples = require('../samples');

@@ -26,15 +23,13 @@

describe('.average()', () => {
test('Testing "average" method', (assert) => {
samples.forEach((sample) => {
let rating = sample.rating;
let expectation = sample.expect.average;
describe(rating.join(', '), () => {
let result = Number(AverageRating.average(rating));
it(' should be ' + expectation, (done) => {
expect(result).to.equal(expectation);
done();
});
});
let expect = sample.expect.average;
let actual = Number(AverageRating.average(rating));
let s = rating.join(', ');
assert.deepEqual(actual, expect, `.average([${s}]) should be ${actual}`);
});
assert.end();
});

@@ -5,3 +5,3 @@ /**

*/
/* global describe it */
/* eslint no-undefined: 0*/

@@ -14,7 +14,4 @@ /* eslint no-array-constructor: 0*/

var path = require('path');
var chai = require('chai');
var test = require('tape');
chai.should();
var expect = chai.expect;
var samples = require('../samples');

@@ -26,15 +23,13 @@

describe('.rate()', () => {
test('Testing "rate" method', (assert) => {
samples.forEach((sample) => {
let rating = sample.rating;
let expectation = sample.expect.score;
describe(rating.join(', '), () => {
let result = Number(AverageRating.rate(rating));
it(' should be ' + expectation, (done) => {
expect(result).to.equal(expectation);
done();
});
});
let expect = sample.expect.score;
let actual = Number(AverageRating.rate(rating));
let s = rating.join(', ');
assert.deepEqual(actual, expect, `.rage([${s}]) should be ${actual}`);
});
assert.end();
});
var samples = [
{
rating: [0, 0, 0, 0, 0],
rating: [ 0, 0, 0, 0, 0 ],
expect: {

@@ -8,5 +8,4 @@ average: 0,

}
},
{
rating: [1, 1, 1, 1, 1],
}, {
rating: [ 1, 1, 1, 1, 1 ],
expect: {

@@ -16,5 +15,4 @@ average: 3.0,

}
},
{
rating: [2, 2, 2, 2, 2],
}, {
rating: [ 2, 2, 2, 2, 2 ],
expect: {

@@ -24,5 +22,4 @@ average: 3.0,

}
},
{
rating: [3, 3, 3, 3, 3],
}, {
rating: [ 3, 3, 3, 3, 3 ],
expect: {

@@ -32,5 +29,4 @@ average: 3.0,

}
},
{
rating: [4, 4, 4, 4, 4],
}, {
rating: [ 4, 4, 4, 4, 4 ],
expect: {

@@ -40,5 +36,4 @@ average: 3.0,

}
},
{
rating: [5, 5, 5, 5, 5],
}, {
rating: [ 5, 5, 5, 5, 5 ],
expect: {

@@ -48,5 +43,4 @@ average: 3.0,

}
},
{
rating: [5, 4, 3, 2, 1],
}, {
rating: [ 5, 4, 3, 2, 1 ],
expect: {

@@ -56,5 +50,4 @@ average: 2.3,

}
},
{
rating: [5, 0, 0, 0, 5],
}, {
rating: [ 5, 0, 0, 0, 5 ],
expect: {

@@ -64,5 +57,4 @@ average: 3.0,

}
},
{
rating: [5, 0, 0, 4, 5],
}, {
rating: [ 5, 0, 0, 4, 5 ],
expect: {

@@ -72,5 +64,4 @@ average: 3.3,

}
},
{
rating: [5, 4, 0, 0, 5],
}, {
rating: [ 5, 4, 0, 0, 5 ],
expect: {

@@ -80,5 +71,4 @@ average: 2.7,

}
},
{
rating: [0, 0, 0, 0, 5],
}, {
rating: [ 0, 0, 0, 0, 5 ],
expect: {

@@ -88,5 +78,4 @@ average: 5,

}
},
{
rating: [0, 0, 0, 4, 5],
}, {
rating: [ 0, 0, 0, 4, 5 ],
expect: {

@@ -96,5 +85,4 @@ average: 4.6,

}
},
{
rating: [0, 0, 3, 4, 5],
}, {
rating: [ 0, 0, 3, 4, 5 ],
expect: {

@@ -104,5 +92,4 @@ average: 4.2,

}
},
{
rating: [0, 2, 3, 4, 5],
}, {
rating: [ 0, 2, 3, 4, 5 ],
expect: {

@@ -112,5 +99,4 @@ average: 3.9,

}
},
{
rating: [1, 2, 3, 4, 5],
}, {
rating: [ 1, 2, 3, 4, 5 ],
expect: {

@@ -120,5 +106,4 @@ average: 3.7,

}
},
{
rating: [9524, 4158, 10177, 25971, 68669],
}, {
rating: [ 9524, 4158, 10177, 25971, 68669 ],
expect: {

@@ -128,5 +113,4 @@ average: 4.2,

}
},
{
rating: [134055, 57472, 143135, 365957, 1448459],
}, {
rating: [ 134055, 57472, 143135, 365957, 1448459 ],
expect: {

@@ -133,0 +117,0 @@ average: 4.4,

@@ -5,3 +5,3 @@ /**

*/
/* global describe it */
/* eslint no-undefined: 0*/

@@ -14,7 +14,4 @@ /* eslint no-array-constructor: 0*/

var path = require('path');
var chai = require('chai');
var test = require('tape');
chai.should();
var expect = chai.expect;
var rootDir = '../../../src/';

@@ -25,32 +22,78 @@

let samples = [
{p: 0, n: 1, e: 0},
{p: 0, n: 5, e: 0},
{p: 0, n: 10, e: 0},
{p: 0, n: 20, e: 0},
{p: 0, n: 100, e: 0},
{p: 0, n: 1000, e: 0},
{n: 0, p: 1, e: 0.21},
{n: 0, p: 5, e: 0.57},
{n: 0, p: 10, e: 0.72},
{n: 0, p: 20, e: 0.84},
{n: 0, p: 100, e: 0.96},
{n: 0, p: 1000, e: 1},
{n: 1, p: 1, e: 0.09},
{n: 5, p: 5, e: 0.24},
{n: 500, p: 500, e: 0.47},
{n: 1000, p: 1000, e: 0.48}
{
p: 0,
n: 1,
e: 0
}, {
p: 0,
n: 5,
e: 0
}, {
p: 0,
n: 10,
e: 0
}, {
p: 0,
n: 20,
e: 0
}, {
p: 0,
n: 100,
e: 0
}, {
p: 0,
n: 1000,
e: 0
}, {
n: 0,
p: 1,
e: 0.21
}, {
n: 0,
p: 5,
e: 0.57
}, {
n: 0,
p: 10,
e: 0.72
}, {
n: 0,
p: 20,
e: 0.84
}, {
n: 0,
p: 100,
e: 0.96
}, {
n: 0,
p: 1000,
e: 1
}, {
n: 1,
p: 1,
e: 0.09
}, {
n: 5,
p: 5,
e: 0.24
}, {
n: 500,
p: 500,
e: 0.47
}, {
n: 1000,
p: 1000,
e: 0.48
}
];
describe('.score()', () => {
test('Testing "score" method', (assert) => {
samples.forEach((sample) => {
let expectation = sample.e;
describe(`Positive: ${sample.p}, Negative: ${sample.n}`, () => {
let result = Number(AverageRating.score(sample.p, sample.n));
it(' should be ' + expectation, (done) => {
expect(result).to.equal(expectation);
done();
});
});
let expect = sample.e;
let actual = Number(AverageRating.score(sample.p, sample.n));
assert.deepEqual(actual, expect, `.score(${sample.p}, ${sample.n}) should be ${actual}`);
});
assert.end();
});

@@ -10,3 +10,3 @@ 'use strict';

var dirs = ['average', 'rate', 'score'];
var dirs = [ 'average', 'rate', 'score' ];
dirs.forEach((dir) => {

@@ -13,0 +13,0 @@ let where = './test/specs/' + dir;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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