Skip to content

Commit

Permalink
Merge branch 'master' into feature/remove-rule-count-validate-for-test
Browse files Browse the repository at this point in the history
  • Loading branch information
stevemao authored Aug 10, 2019
2 parents 4ed3b18 + 773fe23 commit 5d774bd
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 2 deletions.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
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 @@ -278,11 +279,11 @@ Similar to [without](#_without), but returns the values from array that are not

// Native
var arrays = [[1, 2, 3, 4, 5], [5, 2, 10]];
console.log(array.reduce(function(a, b) {
console.log(arrays.reduce(function(a, b) {
return a.filter(function(value) {
return !b.includes(value);
});
})));
}));
// output: [1, 3, 4]

// ES6
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
Original file line number Diff line number Diff line change
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
26 changes: 26 additions & 0 deletions tests/unit/all.js
Original file line number Diff line number Diff line change
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 5d774bd

Please sign in to comment.