Skip to content

Commit

Permalink
fix: 🐛 do not convert number to stringx
Browse files Browse the repository at this point in the history
  • Loading branch information
touv committed Dec 14, 2019
1 parent 30c8551 commit aeb1947
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions packages/analytics/src/distance.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ export default function distance(data, feed) {
feed.close();
return;
}
const fractionalDigits = Number(this.getParam('digits', 4));
const idPath = this.getParam('id', 'id');
let id1;
let id2;
Expand Down Expand Up @@ -109,7 +108,7 @@ export default function distance(data, feed) {
const value = ((measurement * 200) / (value1.length + value2.length)) / 100;
const result = {
id: [id1, id2],
value: (1 - value).toFixed(fractionalDigits),
value: (1 - value),
};
feed.send(result);
return;
Expand All @@ -119,7 +118,7 @@ export default function distance(data, feed) {
const value = (((1 + measurement) * 200) / (value1 + value2 + 2)) / 100;
const result = {
id: [id1, id2],
value: value.toFixed(fractionalDigits),
value,
};
feed.send(result);
return;
Expand Down
4 changes: 2 additions & 2 deletions packages/analytics/test/distance.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('distance', () => {
})
.on('end', () => {
assert.equal(5, res.length);
assert.equal(0.5714, res[0].value);
assert.equal(0.5714285714285714, res[0].value);
assert.equal(1, res[4].value);
done();
});
Expand Down Expand Up @@ -91,7 +91,7 @@ describe('distance', () => {
})
.on('end', () => {
assert.equal(5, res.length);
assert.equal(0.1683, res[0].value);
assert.equal(0.16825613079019075, res[0].value);
assert.equal(1.000, res[3].value);
assert.equal(1.000, res[4].value);
done();
Expand Down

0 comments on commit aeb1947

Please sign in to comment.