Skip to content

Commit 1b1b4f3

Browse files
committed
Fixed the lint issues
Fixed the lint issues
1 parent 8fb6142 commit 1b1b4f3

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

lib/isPositiveInteger.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11

22
exports.isPositiveInteger = (...params) => {
3-
for (const param of params) {
4-
// Checks the type to be Number
5-
if( params.some(param => typeof param !== 'number') ||
3+
for (const param of params) {
4+
// Checks the type to be Number
5+
if (Object.prototype.toString.call(param) !== '[object Number]' ||
66
// Is it an integer?
77
param % 1 !== 0 ||
88
// Is it positive?
99
param <= 0 ||
1010
// maximum safe integer check
11-
//// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
12-
param > Number.MAX_SAFE_INTEGER)
13-
{
14-
return false;
15-
}
16-
}
17-
return true;
18-
};
11+
/// / https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
12+
param > Number.MAX_SAFE_INTEGER) {
13+
return false;
14+
}
15+
}
16+
return true;
17+
};

spec/isPositiveIntegerSpec.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
11
const { isPositiveInteger } = require('../lib/isPositiveInteger');
2-
const MAX_SAFE_INTEGER = 9007199254740991;
2+
3+
const MAX_SAFE_INTEGER = 9007199254740991;
34
describe('IsPositiveInteger', () => {
45
it('should return true for positive integers', () => {
5-
6-
expect(isPositiveInteger(2, 4, 200)).toBe(true)
7-
expect(isPositiveInteger(MAX_SAFE_INTEGER, 4, 200)).toBe(true)
8-
expect(isPositiveInteger(34,98,225,56)).toBe(true)
6+
expect(isPositiveInteger(2, 4, 200)).toBe(true);
7+
expect(isPositiveInteger(MAX_SAFE_INTEGER, 4, 200)).toBe(true);
8+
expect(isPositiveInteger(34, 98, 225, 56)).toBe(true);
99
});
1010

1111
it('should return false for negative numbers or 0', () => {
12-
13-
expect(isPositiveInteger(0, 4, 200)).toBe(false)
14-
expect(isPositiveInteger(-3, -4, -200)).toBe(false)
15-
expect(isPositiveInteger(34,-98,225,56)).toBe(false)
12+
expect(isPositiveInteger(0, 4, 200)).toBe(false);
13+
expect(isPositiveInteger(-3, -4, -200)).toBe(false);
14+
expect(isPositiveInteger(34, -98, 225, 56)).toBe(false);
1615
});
1716

18-
it('should return false for floats', () => {
19-
expect(isPositiveInteger(2.6, 4.9, 23.67)).toBe(false)
20-
expect(isPositiveInteger(2, 4, 23.67)).toBe(false)
21-
expect(isPositiveInteger(-10.2, -4.6, -200.4)).toBe(false)
22-
expect(isPositiveInteger(-32.7,98,225,56)).toBe(false)
17+
it('should return false for floats', () => {
18+
expect(isPositiveInteger(2.6, 4.9, 23.67)).toBe(false);
19+
expect(isPositiveInteger(2, 4, 23.67)).toBe(false);
20+
expect(isPositiveInteger(-10.2, -4.6, -200.4)).toBe(false);
21+
expect(isPositiveInteger(-32.7, 98, 225, 56)).toBe(false);
2322
});
2423

25-
it('should return false for other values', () => {
26-
expect(isPositiveInteger({})).toBe(false)
27-
expect(isPositiveInteger(2,[])).toBe(false)
28-
expect(isPositiveInteger(1,'S')).toBe(false)
29-
expect(isPositiveInteger(MAX_SAFE_INTEGER + 1)).toBe(false)
30-
24+
it('should return false for other values', () => {
25+
expect(isPositiveInteger({})).toBe(false);
26+
expect(isPositiveInteger(2, [])).toBe(false);
27+
expect(isPositiveInteger(1, 'S')).toBe(false);
28+
expect(isPositiveInteger(MAX_SAFE_INTEGER + 1)).toBe(false);
3129
});
32-
});
30+
});

0 commit comments

Comments
 (0)