aboutsummaryrefslogtreecommitdiff
path: root/node_modules/is-natural-number
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-08-24 14:41:48 +0200
committerMinteck <nekostarfan@gmail.com>2021-08-24 14:41:48 +0200
commitd25e11bee6ca5ca523884da132d18e1400e077b9 (patch)
tree8af39fde19f7ed640a60fb397c7edd647dff1c4c /node_modules/is-natural-number
downloadkartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.gz
kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.bz2
kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.zip
Initial commit
Diffstat (limited to 'node_modules/is-natural-number')
-rw-r--r--node_modules/is-natural-number/LICENSE20
-rw-r--r--node_modules/is-natural-number/README.md76
-rw-r--r--node_modules/is-natural-number/index.js31
-rw-r--r--node_modules/is-natural-number/index.jsnext.js29
-rw-r--r--node_modules/is-natural-number/package.json39
5 files changed, 195 insertions, 0 deletions
diff --git a/node_modules/is-natural-number/LICENSE b/node_modules/is-natural-number/LICENSE
new file mode 100644
index 0000000..3b7a190
--- /dev/null
+++ b/node_modules/is-natural-number/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 - 2016 Shinnosuke Watanabe
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/is-natural-number/README.md b/node_modules/is-natural-number/README.md
new file mode 100644
index 0000000..db13bde
--- /dev/null
+++ b/node_modules/is-natural-number/README.md
@@ -0,0 +1,76 @@
+# is-natural-number.js
+
+[![NPM version](https://img.shields.io/npm/v/is-natural-number.svg)](https://www.npmjs.com/package/is-natural-number)
+[![Bower version](https://img.shields.io/bower/v/is-natural-number.svg)](https://github.com/shinnn/is-natural-number.js/releases)
+[![Build Status](https://travis-ci.org/shinnn/is-natural-number.js.svg)](https://travis-ci.org/shinnn/is-natural-number.js)
+[![Coverage Status](https://img.shields.io/coveralls/shinnn/is-natural-number.js.svg)](https://coveralls.io/r/shinnn/is-natural-number.js?branch=master)
+[![devDependency Status](https://david-dm.org/shinnn/is-natural-number.js/dev-status.svg)](https://david-dm.org/shinnn/is-natural-number.js#info=devDependencies)
+
+Check if a value is a [natural number](https://wikipedia.org/wiki/Natural_number)
+
+## Installation
+
+### Package managers
+
+#### [npm](https://www.npmjs.com/)
+
+```
+npm install is-natural-number
+```
+
+#### [Bower](http://bower.io/)
+
+```
+bower install is-natural-number
+```
+
+#### [Duo](http://duojs.org/)
+
+```javascript
+var isNaturalNumber = require('shinnn/is-natural-number.js');
+```
+
+### Standalone
+
+[Download the script file directly.](https://raw.githubusercontent.com/shinnn/is-natural-number.js/master/is-natural-number.js)
+
+## API
+
+### isNaturalNumber(*number*, *option*)
+
+*number*: `Number`
+*option*: `Object`
+Return: `Boolean`
+
+It returns `true` if the first argument is one of the natural numbers. If not, or the argument is not a number, it returns `false`.
+
+```javascript
+isNaturalNumber(10); //=> true
+
+isNaturalNumber(-10); //=> false
+isNaturalNumber(10.5); //=> false
+isNaturalNumber(Infinity); //=> false
+isNaturalNumber('10'); //=> false
+```
+
+*Check [the test](./test.js) for more detailed specifications.*
+
+#### option.includeZero
+
+Type: `Boolean`
+Default: `false`
+
+By default the number `0` is not regarded as a natural number.
+
+Setting this option `true` makes `0` regarded as a natural number.
+
+```javascript
+isNaturalNumber(0); //=> false
+isNaturalNumber(0, {includeZero: true}); //=> true
+```
+
+## License
+
+Copyright (c) 2014 - 2016 [Shinnosuke Watanabe](https://github.com/shinnn)
+
+Licensed under [the MIT License](./LICENSE).
diff --git a/node_modules/is-natural-number/index.js b/node_modules/is-natural-number/index.js
new file mode 100644
index 0000000..6b1b3f2
--- /dev/null
+++ b/node_modules/is-natural-number/index.js
@@ -0,0 +1,31 @@
+/*!
+ * is-natural-number.js | MIT (c) Shinnosuke Watanabe
+ * https://github.com/shinnn/is-natural-number.js
+*/
+'use strict';
+
+module.exports = function isNaturalNumber(val, option) {
+ 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;
+};
diff --git a/node_modules/is-natural-number/index.jsnext.js b/node_modules/is-natural-number/index.jsnext.js
new file mode 100644
index 0000000..f018bd4
--- /dev/null
+++ b/node_modules/is-natural-number/index.jsnext.js
@@ -0,0 +1,29 @@
+/*!
+ * is-natural-number.js | MIT (c) Shinnosuke Watanabe
+ * https://github.com/shinnn/is-natural-number.js
+*/
+export default function isNaturalNumber(val, option) {
+ 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;
+}
diff --git a/node_modules/is-natural-number/package.json b/node_modules/is-natural-number/package.json
new file mode 100644
index 0000000..935f020
--- /dev/null
+++ b/node_modules/is-natural-number/package.json
@@ -0,0 +1,39 @@
+{
+ "name": "is-natural-number",
+ "version": "4.0.1",
+ "description": "Check if a value is a natural number",
+ "repository": "shinnn/is-natural-number.js",
+ "author": "Shinnosuke Watanabe (https://github.com/shinnn)",
+ "scripts": {
+ "pretest": "eslint --config @shinnn --ignore-path .gitignore .",
+ "test": "node --strong_mode --throw-deprecation --track-heap-objects test.js | tap-dot",
+ "coverage": "node --strong_mode node_modules/.bin/istanbul cover test.js"
+ },
+ "license": "MIT",
+ "jsnext:main": "index.jsnext.js",
+ "files": [
+ "index.js",
+ "index.jsnext.js"
+ ],
+ "keywords": [
+ "number",
+ "natural",
+ "check",
+ "int",
+ "integer",
+ "math",
+ "mathematics",
+ "range",
+ "browser",
+ "client-side"
+ ],
+ "devDependencies": {
+ "@shinnn/eslint-config": "^2.1.0",
+ "eslint": "^2.9.0",
+ "istanbul": "^0.4.3",
+ "require-from-string": "^1.2.0",
+ "rollup": "^0.26.3",
+ "tap-dot": "^1.0.5",
+ "tape": "^4.5.1"
+ }
+}