-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b16c95d
commit bb3e1b7
Showing
9 changed files
with
238 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Returns `true` if the first argument is greater than the second; otherwise `false` | ||
* | ||
* @param a - The first input value | ||
* @param b - The second input value | ||
* @returns The result of `a > b` | ||
* | ||
* @example | ||
* ```ts | ||
* // Number | ||
* gt(2, 1) // true | ||
* gt(2, 2) // false | ||
* ``` | ||
* | ||
* @example | ||
* ```ts | ||
* // Bigint | ||
* gt(2n, 1n) // true | ||
* gt(2n, 2n) // false | ||
* ``` | ||
* | ||
* @example | ||
* ```ts | ||
* // String | ||
* gt('z', 'a') // true | ||
* gt('a', 'z') // false | ||
* ``` | ||
* | ||
* @beta | ||
*/ | ||
const gt = <T extends string | number | bigint>(a: T, b: T): boolean => a > b | ||
|
||
export { gt } |
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,36 @@ | ||
/** | ||
* Returns `true` if the first argument is greater than or equal to the second; otherwise `false` | ||
* | ||
* @param a - The first input value | ||
* @param b - The second input value | ||
* @returns The result of `a >= b` | ||
* | ||
* @example | ||
* ```ts | ||
* // Number | ||
* gte(2, 1) // true | ||
* gte(2, 2) // true | ||
* gte(2, 3) // false | ||
* ``` | ||
* | ||
* @example | ||
* ```ts | ||
* // Bigint | ||
* gte(2n, 1n) // true | ||
* gte(2n, 2n) // true | ||
* gte(2n, 3n) // false | ||
* ``` | ||
* | ||
* @example | ||
* ```ts | ||
* // String | ||
* gte('z', 'a') // true | ||
* gte('a', 'a') // true | ||
* gte('a', 'z') // false | ||
* ``` | ||
* | ||
* @beta | ||
*/ | ||
const gte = <T extends string | number | bigint>(a: T, b: T): boolean => a >= b | ||
|
||
export { gte } |
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,33 @@ | ||
/** | ||
* Returns `true` if the first argument is less than the second; otherwise `false` | ||
* | ||
* @param a - The first input value | ||
* @param b - The second input value | ||
* @returns The result of `a < b` | ||
* | ||
* @example | ||
* ```ts | ||
* // Number | ||
* lt(1, 2) // true | ||
* lt(2, 2) // false | ||
* ``` | ||
* | ||
* @example | ||
* ```ts | ||
* // Bigint | ||
* lt(1n, 2n) // true | ||
* lt(2n, 2n) // false | ||
* ``` | ||
* | ||
* @example | ||
* ```ts | ||
* // String | ||
* lt('a', 'z') // true | ||
* lt('a', 'a') // false | ||
* ``` | ||
* | ||
* @beta | ||
*/ | ||
const lt = <T extends string | number | bigint>(a: T, b: T): boolean => a < b | ||
|
||
export { lt } |
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,36 @@ | ||
/** | ||
* Returns `true` if the first argument is less than or equal to the second; otherwise `false` | ||
* | ||
* @param a - The first input value | ||
* @param b - The second input value | ||
* @returns The result of `a <= b` | ||
* | ||
* @example | ||
* ```ts | ||
* // Number | ||
* lte(1, 2) // true | ||
* lte(2, 2) // true | ||
* lte(2, 1) // false | ||
* ``` | ||
* | ||
* @example | ||
* ```ts | ||
* // Bigint | ||
* lte(1n, 2n) // true | ||
* lte(2n, 2n) // true | ||
* lte(2n, 1n) // true | ||
* ``` | ||
* | ||
* @example | ||
* ```ts | ||
* // String | ||
* lte('a', 'z') // true | ||
* lte('a', 'a') // true | ||
* lte('z', 'a') // false | ||
* ``` | ||
* | ||
* @beta | ||
*/ | ||
const lte = <T extends string | number | bigint>(a: T, b: T): boolean => a <= b | ||
|
||
export { lte } |
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,24 @@ | ||
import { gt } from '@/gt' | ||
|
||
describe('gt', () => { | ||
const table: [ | ||
number | bigint | string, | ||
number | bigint | string, | ||
boolean | ||
][] = [ | ||
[0, 0, false], | ||
[0, 1, false], | ||
[1, 0, true], | ||
[0n, 0n, false], | ||
[0n, 1n, false], | ||
[1n, 0n, true], | ||
['a', 'a', false], | ||
['a', 'z', false], | ||
['z', 'a', true], | ||
['za', 'a', true] | ||
] | ||
|
||
it.each(table)('gt(%s, %s) -> %s', (a, b, expected) => { | ||
expect(gt(a, b)).toBe(expected) | ||
}) | ||
}) |
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,24 @@ | ||
import { gte } from '@/gte' | ||
|
||
describe('gte', () => { | ||
const table: [ | ||
number | bigint | string, | ||
number | bigint | string, | ||
boolean | ||
][] = [ | ||
[0, 1, false], | ||
[0, 0, true], | ||
[1, 0, true], | ||
[0n, 1n, false], | ||
[0n, 0n, true], | ||
[1n, 0n, true], | ||
['a', 'z', false], | ||
['a', 'a', true], | ||
['z', 'a', true], | ||
['za', 'a', true] | ||
] | ||
|
||
it.each(table)('gte(%s, %s) -> %s', (a, b, expected) => { | ||
expect(gte(a, b)).toBe(expected) | ||
}) | ||
}) |
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,24 @@ | ||
import { lt } from '@/lt' | ||
|
||
describe('lt', () => { | ||
const table: [ | ||
number | bigint | string, | ||
number | bigint | string, | ||
boolean | ||
][] = [ | ||
[0, 0, false], | ||
[1, 0, false], | ||
[0, 1, true], | ||
[0n, 0n, false], | ||
[1n, 0n, false], | ||
[0n, 1n, true], | ||
['a', 'a', false], | ||
['z', 'a', false], | ||
['za', 'a', false], | ||
['a', 'z', true] | ||
] | ||
|
||
it.each(table)('lt(%s, %s) -> %s', (a, b, expected) => { | ||
expect(lt(a, b)).toBe(expected) | ||
}) | ||
}) |
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,24 @@ | ||
import { lte } from '@/lte' | ||
|
||
describe('lte', () => { | ||
const table: [ | ||
number | bigint | string, | ||
number | bigint | string, | ||
boolean | ||
][] = [ | ||
[1, 0, false], | ||
[0, 0, true], | ||
[0, 1, true], | ||
[1n, 0n, false], | ||
[0n, 0n, true], | ||
[0n, 1n, true], | ||
['z', 'a', false], | ||
['za', 'a', false], | ||
['a', 'a', true], | ||
['a', 'z', true] | ||
] | ||
|
||
it.each(table)('lte(%s, %s) -> %s', (a, b, expected) => { | ||
expect(lte(a, b)).toBe(expected) | ||
}) | ||
}) |