@hwycdfatm/is-odd 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +88 -0
- package/index.d.ts +10 -0
- package/index.js +27 -0
- package/package.json +32 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 hwycdfatm
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# @hwycdfatm/is-odd
|
|
2
|
+
|
|
3
|
+
> Returns true if a number is odd, false if even, null if not implemented yet.
|
|
4
|
+
|
|
5
|
+
⚠️ **Troll Version** - This is a "work in progress" package that implements odd number checking one number at a time. Currently only supports limited cases. More updates coming soon! 😄
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
Install with [npm](https://www.npmjs.com/):
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @hwycdfatm/is-odd
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
const isOdd = require('@hwycdfatm/is-odd');
|
|
19
|
+
|
|
20
|
+
console.log(isOdd(1)); // => true (implemented!)
|
|
21
|
+
console.log(isOdd(2)); // => null (not implemented yet)
|
|
22
|
+
console.log(isOdd(3)); // => null (not implemented yet)
|
|
23
|
+
console.log(isOdd(5)); // => null (not implemented yet)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Current Status
|
|
27
|
+
|
|
28
|
+
**Version 0.0.1** - Only the following cases are implemented:
|
|
29
|
+
|
|
30
|
+
✅ `isOdd(1)` → `true`
|
|
31
|
+
❌ All other numbers → `null` (not implemented yet)
|
|
32
|
+
|
|
33
|
+
This package will be updated regularly with more number support. Stay tuned!
|
|
34
|
+
|
|
35
|
+
## API
|
|
36
|
+
|
|
37
|
+
### isOdd(number)
|
|
38
|
+
|
|
39
|
+
Checks if the given number is odd.
|
|
40
|
+
|
|
41
|
+
**Params**
|
|
42
|
+
|
|
43
|
+
* `number` **{Number}**: The number to check
|
|
44
|
+
|
|
45
|
+
**Returns**
|
|
46
|
+
|
|
47
|
+
* **{Boolean|null}**:
|
|
48
|
+
- Returns `true` if the number is odd (when implemented)
|
|
49
|
+
- Returns `false` if the number is even (when implemented)
|
|
50
|
+
- Returns `null` if not implemented yet
|
|
51
|
+
- Throws `TypeError` if input is not a finite number
|
|
52
|
+
|
|
53
|
+
**Example**
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
const isOdd = require('@hwycdfatm/is-odd');
|
|
57
|
+
|
|
58
|
+
console.log(isOdd(1)); // => true
|
|
59
|
+
console.log(isOdd(3)); // => null
|
|
60
|
+
console.log(isOdd(NaN)); // => throws TypeError
|
|
61
|
+
console.log(isOdd(Infinity)); // => throws TypeError
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## TypeScript
|
|
65
|
+
|
|
66
|
+
This package includes TypeScript definitions.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
import isOdd = require('@hwycdfatm/is-odd');
|
|
70
|
+
|
|
71
|
+
const result = isOdd(1); // true
|
|
72
|
+
const result2 = isOdd(3); // null
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## About
|
|
76
|
+
|
|
77
|
+
### Contributing
|
|
78
|
+
|
|
79
|
+
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
|
80
|
+
|
|
81
|
+
### Author
|
|
82
|
+
|
|
83
|
+
**hwycdfatm**
|
|
84
|
+
|
|
85
|
+
### License
|
|
86
|
+
|
|
87
|
+
Copyright © 2026, [hwycdfatm].
|
|
88
|
+
Released under the [MIT License](LICENSE).
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the given number is odd, false if even, null if not implemented yet.
|
|
3
|
+
*
|
|
4
|
+
* @param number - The number to check
|
|
5
|
+
* @returns true if odd (when implemented), false if even (when implemented), null if not implemented yet
|
|
6
|
+
* @throws {TypeError} If the input is not a finite number
|
|
7
|
+
*/
|
|
8
|
+
declare function isOdd(number: number | string): boolean | null;
|
|
9
|
+
|
|
10
|
+
export = isOdd;
|
package/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* is-odd <https://github.com/hwycdfatm/is-odd>
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2026, HWYCDFATM.
|
|
5
|
+
* Released under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Returns true if the given number is odd, false otherwise.
|
|
12
|
+
*
|
|
13
|
+
* @param {Number} value
|
|
14
|
+
* @return {Boolean}
|
|
15
|
+
* @api public
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
module.exports = function isOdd(number) {
|
|
19
|
+
const num = Number(number)
|
|
20
|
+
if (!Number.isFinite(num)) {
|
|
21
|
+
throw new TypeError('Expected a finite number')
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (number === 1) return true
|
|
25
|
+
|
|
26
|
+
return null
|
|
27
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hwycdfatm/is-odd",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Returns true if a number is odd, false if even, null if not implemented yet (troll version - updates coming soon!)",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "node test.js"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"is-odd",
|
|
12
|
+
"odd",
|
|
13
|
+
"number",
|
|
14
|
+
"is",
|
|
15
|
+
"even",
|
|
16
|
+
"math",
|
|
17
|
+
"utility"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"author": "hwycdfatm <mai.tritoan7102@gmail.com>",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "https://github.com/hwycdfatm/is-odd.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/hwycdfatm/is-odd/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/hwycdfatm/is-odd#readme",
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=0.10.0"
|
|
31
|
+
}
|
|
32
|
+
}
|