Skip to content

Commit

Permalink
feat: Object.isNaturalNumber an Object.isNaturalNumberValue
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Jan 16, 2018
1 parent 9965016 commit 66a40af
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions object/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ module.exports = {
isCopyDeep: require("./is-copy-deep"),
isEmpty: require("./is-empty"),
isFiniteNumber: require("./is-finite-number"),
isNaturalNumber: require("./is-natural-number"),
isNaturalNumberValue: require("./is-natural-number-value"),
isNumberValue: require("./is-number-value"),
isObject: require("./is-object"),
isPlainFunction: require("./is-plain-function"),
Expand Down
9 changes: 9 additions & 0 deletions object/is-natural-number-value.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use strict";

var isNaturalNumber = require("./is-natural-number")
, isValue = require("./is-value");

module.exports = function (arg) {
if (!isValue(arg)) return false;
return isNaturalNumber(arg);
};
7 changes: 7 additions & 0 deletions object/is-natural-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"use strict";

var isNatural = require("../number/is-natural");

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

module.exports = function (t, a) {
a(t(undefined), false, "Undefined");
a(t(null), false, "Null");
a(t(2), true, "Number");
a(t(-2), false, "Negative");
a(t(2.34), false, "Float");
a(t("23"), true, "Numeric string");
a(t(NaN), false, "NaN");
a(t(Infinity), false, "Infinity");
};
12 changes: 12 additions & 0 deletions test/object/is-natural-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use strict";

module.exports = function (t, a) {
a(t(undefined), false, "Undefined");
a(t(null), true, "Null");
a(t(2), true, "Number");
a(t(-2), false, "Negative");
a(t(2.34), false, "Float");
a(t("23"), true, "Numeric string");
a(t(NaN), false, "NaN");
a(t(Infinity), false, "Infinity");
};

0 comments on commit 66a40af

Please sign in to comment.