8000 Removed dependency on lodash.isNumber by fayyazarshad · Pull Request #407 · optimizely/javascript-sdk · GitHub
[go: up one dir, main page]

Skip to content

Removed dependency on lodash.isNumber #407

New issue

Have a question about this project? Sign up 8000 for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/optimizely-sdk/lib/utils/fns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ module.exports = {
return uuid.v4();
},
values: require('lodash/values'),
isNumber: require('lodash/isNumber'),
isNumber: function(value) {
return typeof value === 'number';
},
};
17 changes: 17 additions & 0 deletions packages/optimizely-sdk/lib/utils/fns/index.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,22 @@ describe('lib/utils/fns', function() {
assert.isTrue(fns.isFinite(-Math.pow(2, 53)));
});
});
describe('isNumber', function() {
it('should return true in case of number', function() {
assert.isTrue(fns.isNumber(3));
});
it('should return true in case of value from Number object ', function() {
assert.isTrue(fns.isNumber(Number.MIN_VALUE));
});
it('should return true in case of Infinity ', function() {
assert.isTrue(fns.isNumber(Infinity));
});
it('should return false in case of string', function() {
assert.isFalse(fns.isNumber('3'));
});
it('should return false in case of null', function() {
assert.isFalse(fns.isNumber(null));
});
});
});
});
0