-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbrowser.js
More file actions
31 lines (27 loc) · 802 Bytes
/
Copy pathbrowser.js
File metadata and controls
31 lines (27 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*!
* is-natural-number.js | MIT (c) Shinnosuke Watanabe
* https://github.com/shinnn/is-natural-number.js
*/
window.isNaturalNumber = function isNaturalNumber(val, option) {
'use strict';
if (option) {
if (typeof option !== 'object') {
throw new TypeError(
String(option) +
' is not an object. Expected an object that has boolean `includeZero` property.'
);
}
if ('includeZero' in option) {
if (typeof option.includeZero !== 'boolean') {
throw new TypeError(
String(option.includeZero) +
' is neither true nor false. `includeZero` option must be a Boolean value.'
);
}
if (option.includeZero && val === 0) {
return true;
}
}
}
return Number.isSafeInteger(val) && val >= 1;
};