Skip to content

Commit

Permalink
feat: add Object.isFiniteNumber util
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Aug 11, 2017
1 parent 299bbb9 commit fe5b55a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions object/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module.exports = {
isCopy: require("./is-copy"),
isCopyDeep: require("./is-copy-deep"),
isEmpty: require("./is-empty"),
isFiniteNumber: require("./is-finite-number"),
isNumberValue: require("./is-number-value"),
isObject: require("./is-object"),
isPlainObject: require("./is-plain-object"),
Expand Down
7 changes: 7 additions & 0 deletions object/is-finite-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

var isNumber = require("./is-number-value");

module.exports = function (value) {
return isNumber(value) && isFinite(value);
};
15 changes: 15 additions & 0 deletions test/object/is-finite-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"use strict";

module.exports = function (t, a) {
a(t(undefined), false, "Undefined");
a(t(null), false, "Null");
a(t(0), true, "Zero");
a(t(NaN), false, "NaN");
a(t(Infinity), false, "Infinity");
a(t(12), true, "Number");
a(t(false), true, "Boolean");
a(t(new Date()), true, "Date");
a(t(new Number(2)), true, "Number object");
a(t("asdfaf"), false, "String");
a(t(""), true, "Empty String");
};

0 comments on commit fe5b55a

Please sign in to comment.