-
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.
feat: adding lt, lte, gt, gte number ops
- Loading branch information
Showing
9 changed files
with
74 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,6 @@ | ||
import * as $ from './index.js' | ||
|
||
test('gt', () => { | ||
expect($.gt(1)(2)).toEqual($.ok(2)) | ||
expect($.gt(1)(1)).toEqual($.fail(1, 'expected greater than 1')) | ||
}) |
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,10 @@ | ||
import { ok, fail, type Refute } from './index.js' | ||
|
||
const gt = | ||
(than: number): Refute<number> => | ||
value => | ||
typeof value === 'number' && value > than ? | ||
ok(value) : | ||
fail(value, `expected greater than ${than}`) | ||
|
||
export default 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,7 @@ | ||
import * as $ from './index.js' | ||
|
||
test('gte', () => { | ||
expect($.gte(1)(2)).toEqual($.ok(2)) | ||
expect($.gte(1)(1)).toEqual($.ok(1)) | ||
expect($.gte(1)(0)).toEqual($.fail(0, 'expected greater than or equal to 1')) | ||
}) |
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,10 @@ | ||
import { ok, fail, type Refute } from './index.js' | ||
|
||
const gte = | ||
(than: number): Refute<number> => | ||
value => | ||
typeof value === 'number' && value >= than ? | ||
ok(value) : | ||
fail(value, `expected greater than or equal to ${than}`) | ||
|
||
export default 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,6 @@ | ||
import * as $ from './index.js' | ||
|
||
test('lt', () => { | ||
expect($.lt(1)(0)).toEqual($.ok(0)) | ||
expect($.lt(1)(1)).toEqual($.fail(1, 'expected lower than 1')) | ||
}) |
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,10 @@ | ||
import { ok, fail, type Refute } from './index.js' | ||
|
||
const lt = | ||
(than: number): Refute<number> => | ||
value => | ||
typeof value === 'number' && value < than ? | ||
ok(value) : | ||
fail(value, `expected lower than ${than}`) | ||
|
||
export default 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,7 @@ | ||
import * as $ from './index.js' | ||
|
||
test('lte', () => { | ||
expect($.lte(1)(0)).toEqual($.ok(0)) | ||
expect($.lte(1)(1)).toEqual($.ok(1)) | ||
expect($.lte(1)(2)).toEqual($.fail(2, 'expected lower than or equal to 1')) | ||
}) |
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,10 @@ | ||
import { ok, fail, type Refute } from './index.js' | ||
|
||
const lte = | ||
(than: number): Refute<number> => | ||
value => | ||
typeof value === 'number' && value <= than ? | ||
ok(value) : | ||
fail(value, `expected lower than or equal to ${than}`) | ||
|
||
export default lte |