File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
packages/optimizely-sdk/lib/utils/fns Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -40,5 +40,7 @@ module.exports = {
4040 return uuid . v4 ( ) ;
4141 } ,
4242 values : require ( 'lodash/values' ) ,
43- isNumber : require ( 'lodash/isNumber' ) ,
43+ isNumber : function ( value ) {
44+ return typeof value === 'number' ;
45+ } ,
4446} ;
Original file line number Diff line number Diff line change @@ -63,6 +63,24 @@ describe('lib/utils/fns', function() {
6363
6464 obj = fns . keyBy ( undefined , 'key1' ) ;
6565 assert . isEmpty ( obj ) ;
66+ } ) ;
67+ } ) ;
68+
69+ describe ( 'isNumber' , function ( ) {
70+ it ( 'should return true in case of number' , function ( ) {
71+ assert . isTrue ( fns . isNumber ( 3 ) ) ;
72+ } ) ;
73+ it ( 'should return true in case of value from Number object ' , function ( ) {
74+ assert . isTrue ( fns . isNumber ( Number . MIN_VALUE ) ) ;
75+ } ) ;
76+ it ( 'should return true in case of Infinity ' , function ( ) {
77+ assert . isTrue ( fns . isNumber ( Infinity ) ) ;
78+ } ) ;
79+ it ( 'should return false in case of string' , function ( ) {
80+ assert . isFalse ( fns . isNumber ( '3' ) ) ;
81+ } ) ;
82+ it ( 'should return false in case of null' , function ( ) {
83+ assert . isFalse ( fns . isNumber ( null ) ) ;
6684 } ) ;
6785 } ) ;
6886 } ) ;
You can’t perform that action at this time.
0 commit comments