Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Methods for option #49

Closed
wants to merge 28 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5280cff
feat(try): doc try monad
danielalvarezm Oct 4, 2024
fd16bdd
feat(option): doc option monad
danielalvarezm Oct 11, 2024
30f0f23
feat(io): doc io monad
danielalvarezm Oct 11, 2024
e9208b4
feat(either): doc either monad
danielalvarezm Oct 11, 2024
a77b7f8
feat(future): doc future monad
danielalvarezm Oct 11, 2024
14a6349
refactor: apply suggested changes
danielalvarezm Oct 18, 2024
5126ce2
feat(Option): :rotating_light: Option monad should create a Some
Oct 27, 2024
c19cf75
feat(Option): :white_check_mark: Option monad should create a Some
Oct 27, 2024
2f22faf
feat(Option): :rotating_light: Option monad should create a None
Oct 27, 2024
929b72a
feat(Option): :rotating_light: Option monad should create a None
Oct 27, 2024
37c5e25
feat(Option): :white_check_mark: Option monad should create a None
Oct 27, 2024
1f6461d
feat(Option): :recycle: Add NotNullable type
Oct 27, 2024
7d7dda6
feat(Option): :fire: Remove unnecessary test
Oct 28, 2024
2cd9034
feat(Option): :recycle: Rename options methods
Oct 29, 2024
e1b99b9
feat(Option): :recycle: Rename NotNullabe type to Present
Oct 31, 2024
0aa808a
fix(Try): fix Failure subclass generic typing and remove static variable
Marius9595 Nov 1, 2024
fcd2839
fix(monads): fix compilation to enable commonjs and esm entrypoint to…
Marius9595 Nov 1, 2024
f024f32
docs(monads): add tag
Marius9595 Nov 1, 2024
ffcd133
feat(Option): :rotating_light: Option monad should create a Some
Oct 27, 2024
83e23a1
feat(Option): :white_check_mark: Option monad should create a Some
Oct 27, 2024
bc32c8a
feat(Option): :rotating_light: Option monad should create a None
Oct 27, 2024
0953d2a
feat(Option): :rotating_light: Option monad should create a None
Oct 27, 2024
a41d200
feat(Option): :white_check_mark: Option monad should create a None
Oct 27, 2024
777a3a1
feat(Option): :recycle: Add NotNullable type
Oct 27, 2024
f9f5fa8
feat(Option): :fire: Remove unnecessary test
Oct 28, 2024
506e7f3
feat(Option): :recycle: Rename options methods
Oct 29, 2024
cbb5cc0
feat(Option): :recycle: Rename NotNullabe type to Present
Oct 31, 2024
0be8476
Merge remote-tracking branch 'origin/methods-for-option' into methods…
Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(Option): ♻️ Rename NotNullabe type to Present
  • Loading branch information
Aitor Santana authored and Aitor Santana committed Nov 5, 2024
commit cbb5cc0ea877715d104bb5264ec46316bc3ca1b4
6 changes: 3 additions & 3 deletions src/option/option.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NotNullable, Nullable } from '../types';
import { Present, Nullable } from '../types';
import { Monad } from '../monad';
import { Matchable } from '../match';

@@ -29,13 +29,13 @@ abstract class Option<T> implements Monad<T>, Matchable<T, undefined> {
/**
* Creates an `Option` instance from a value.
* @template T The type of the value.
* @param {NotNullable<T>} value The nullable value.
* @param {Present<T>} value The nullable value.
* @returns {Some<T>} A `Some` instance of the value
* @example
* const some = Option.some(5);
* some.match(console.log, () => console.log('none')); // 5
*/
static some<T>(value: NotNullable<T>): Option<T> {
static some<T>(value: Present<T>): Option<T> {
return new Some(value);
}

2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export type Nullable<T> = T | null | undefined;
export type NotNullable<T> = Exclude<T, null | undefined>;
export type Present<T> = Exclude<T, null | undefined>;