-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from TomokiMiyauci/beta
Beta
- Loading branch information
Showing
20 changed files
with
443 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license. | ||
// This module is browser compatible. | ||
|
||
import { isPositiveNumber } from "./is_positive_number.ts"; | ||
|
||
/** Whether the input is positive integer or not. | ||
* @param input - Any `number`. | ||
* @example | ||
* ```ts | ||
* import { isPositiveInteger } from "https://deno.land/x/isx@$VERSION/number/is_positive_integer.ts"; | ||
* import { assertEquals } from "https://deno.land/std/testing/asserts.ts"; | ||
* assertEquals(isPositiveInteger(1), true); | ||
* assertEquals(isPositiveInteger(0), false); | ||
* ``` | ||
*/ | ||
export function isPositiveInteger(input: number): boolean { | ||
return Number.isInteger(input) && isPositiveNumber(input); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { isPositiveInteger } from "./is_positive_integer.ts"; | ||
import { assert, assertFalse, describe, it } from "../_dev_deps.ts"; | ||
|
||
describe("isPositiveInteger", () => { | ||
it("should return true", () => { | ||
const table: number[] = [ | ||
1, | ||
Number.MAX_VALUE, | ||
Number.MAX_SAFE_INTEGER, | ||
]; | ||
|
||
table.forEach((input) => { | ||
assert(isPositiveInteger(input)); | ||
}); | ||
}); | ||
|
||
it("should return false", () => { | ||
const table: number[] = [ | ||
NaN, | ||
0, | ||
-0, | ||
-1, | ||
-1.1, | ||
-Infinity, | ||
Infinity, | ||
1.1, | ||
Number.NEGATIVE_INFINITY, | ||
Number.MIN_SAFE_INTEGER, | ||
]; | ||
|
||
table.forEach((input) => { | ||
assertFalse(isPositiveInteger(input)); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2023-latest Tomoki Miyauchi. All rights reserved. MIT license. | ||
// This module is browser compatible. | ||
|
||
/** Whether the input is negative number or not. | ||
* @param input - Any numeric. | ||
* @example | ||
* ```ts | ||
* import { isNegativeNumber } from "https://deno.land/x/isx@$VERSION/numeric/is_negative_number.ts" | ||
* import { assert, assertFalse } from "https://deno.land/std/testing/asserts.ts" | ||
* assert(isNegativeNumber(-1)) | ||
* assertFalse(isNegativeNumber(0)) | ||
* ``` | ||
*/ | ||
export function isNegativeNumber(input: number | bigint): boolean { | ||
return input < 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { isNegativeNumber } from "./is_negative_number.ts"; | ||
import { assert, assertFalse, describe, it } from "../_dev_deps.ts"; | ||
|
||
describe("isNegativeNumber", () => { | ||
it("should return true", () => { | ||
const table: (number | bigint)[] = [ | ||
-1, | ||
-0.1, | ||
-Infinity, | ||
Number.NEGATIVE_INFINITY, | ||
Number.MIN_SAFE_INTEGER, | ||
-1n, | ||
]; | ||
|
||
table.forEach((input) => { | ||
assert(isNegativeNumber(input)); | ||
}); | ||
}); | ||
|
||
it("should return false", () => { | ||
const table: (number | bigint)[] = [ | ||
NaN, | ||
0, | ||
-0, | ||
Infinity, | ||
0.1, | ||
1, | ||
Number.MAX_VALUE, | ||
Number.MAX_SAFE_INTEGER, | ||
0n, | ||
1n, | ||
]; | ||
|
||
table.forEach((input) => { | ||
assertFalse(isNegativeNumber(input)); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.