Skip to content

Commit

Permalink
Merge 8c7fdc0 into fea1698
Browse files Browse the repository at this point in the history
  • Loading branch information
cht8687 committed Aug 10, 2019
2 parents fea1698 + 8c7fdc0 commit adfad31
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
26 changes: 26 additions & 0 deletions README.md
Expand Up @@ -141,6 +141,7 @@ then Lodash/Underscore is the better option.*
1. [_.gte](#_gte)
1. [_.isEmpty](#_isempty)
1. [_.isFinite](#_isfinite)
1. [_.isInteger](#_isInteger)
1. [_.isNaN](#_isnan)
1. [_.isNil](#_isnil)
1. [_.isNull](#_isnull)
Expand Down Expand Up @@ -1719,6 +1720,31 @@ Converts value to a finite number.
**[⬆ back to top](#quick-links)**
### _.isInteger
Checks if value is an integer.
```js
// Lodash
console.log(_.isInteger(3))
// output: true
console.log(_.isInteger('3'))
// output: false

// Native
console.log(Number.isInteger(3))
// output: true
console.log(Number.isInteger('3'))
// output: false
```
#### Browser Support for `Number.isInteger()`
![Chrome][chrome-image] | ![Edge][edge-image] | ![Firefox][firefox-image] | ![IE][ie-image] | ![Opera][opera-image] | ![Safari][safari-image]
:-: | :-: | :-: | :-: | :-: | :-: |
✔ | 12 ✔ | 16.0 ✔ | ✖ | ✔ | ✔ |
**[⬆ back to top](#quick-links)**
### _.isNaN
Checks if a value is NaN.
Expand Down
6 changes: 6 additions & 0 deletions lib/rules/rules.json
Expand Up @@ -148,6 +148,12 @@
"compatible": true,
"alternative": "Number.isFinite()"
},
"isInteger": {
"ruleName": "is-integer",
"compatible": true,
"alternative": "Number.isInteger()",
"ES6": true
},
"isNaN": {
"ruleName": "is-nan",
"compatible": true,
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/all.js
Expand Up @@ -4,7 +4,7 @@ const assert = require('assert');
const rules = require('../../../lib/rules/all');
const allRules = require('../../../lib/rules/rules');

assert.equal(Object.keys(allRules).length, 57, 'Don\'t miss a rule 😄');
assert.equal(Object.keys(allRules).length, 58, 'Don\'t miss a rule 😄');

const ruleTester = new RuleTester({
parserOptions: { ecmaVersion: 2018, sourceType: "module" }
Expand Down
26 changes: 26 additions & 0 deletions tests/unit/all.js
Expand Up @@ -204,6 +204,32 @@ describe('code snippet example', () => {
)
})
})
describe('isInteger', () => {
it('_.isInteger(3)', () => {
assert.equal(
_.isInteger(3),
Number.isInteger(3)
)
})
it('_.isInteger("3")', () => {
assert.equal(
_.isInteger("3"),
Number.isInteger("3")
)
})
it('_.isInteger(2.9)', () => {
assert.equal(
_.isInteger(2.9),
Number.isInteger(2.9)
)
})
it('_.isInteger(NaN)', () => {
assert.equal(
_.isInteger(NaN),
Number.isInteger(NaN)
)
})
})
describe('get', () => {
const get = (obj, path, defaultValue) => {
const result = String.prototype.split.call(path, /[,[\].]+?/)
Expand Down

0 comments on commit adfad31

Please sign in to comment.