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

Option #6

Merged
merged 40 commits into from
Jun 3, 2024
Merged

Option #6

merged 40 commits into from
Jun 3, 2024

Conversation

suddenlyGiovanni
Copy link
Owner

@suddenlyGiovanni suddenlyGiovanni commented Jun 2, 2024

  • Implemented a new method getOrElse in the Option module, allowing efficient handling of empty Option instances by providing a default value.
  • The return type of the match function has been extended, introducing more flexibility in dealing with Option instances.
  • Increased the visibility of None and Some subclasses within Option, facilitating their use across different modules.
  • Pattern matching capabilities have been introduced, allowing customization for Some and None cases of an Option.
  • Improved error messaging and link code accuracy in the Option documentation, enhancing readability and understandability.
  • Expanded functionality and usage examples of the fold method within Option for comprehensive comprehension.

The documentation for the Option module has been moved from option.ts
 to mod.ts for better organization and clarity. This is part of a
 larger effort to keep the codebase well-documented and
 easy-to-navigate.
The commit comprises changes that update and refine the project
documentation. This update aims at enhancing the understandability of
 the project for better user experience.
Added a 'get' method to the Option class. Now it's possible to
retrieve values from 'Some' instances and an error will be thrown
when trying to get a value from a 'None' instance. Corresponding
tests have also been added to ensure the functionality works as
expected.
In the Option class, a method isEmpty has been added to return `true`
 if the option is None, `false` otherwise. Also, unit tests have been
  added to ensure the correct functioning of this new method.
The docstrings for the examples in the 'option.ts' file have been
updated so that each 'example' keyword is followed by a new line.
This makes the different sections of the documentation more clear and
 easier to read.
The '@std/expect' library was added as a dependency in the deno.jsonc
 and deno.lock files. This new dependency was subsequently used to
 refactor the assertions in the test file 'option.test.ts'. This
 changes the assertion style to the 'expect' library style, altering
 the syntax and potentially enhancing readability.
A new file, function.ts, has been added which contains the definition
 for the Lazy interface. The Lazy interface allows for the deferral
 of expression evaluations. This includes usage examples for
 deferring the computation of an expression and for using the Lazy
 interface as a parameter type in a function.
Specific type has been defined for abstract class Option, rather than
 defaulting to unknown. Similarly, specific types have been added to
 None and Some subclasses. An isEmpty method was also inserted to
 enhance type checking by identifying None objects.
The fold method was added to the Option class in the option.ts file.
This method provides functionality to handle cases where the Option
is nonempty or empty, by applying a specified function to the
Option's value or evaluating a given expression, respectively.
The getter method for the value property has been removed from the
Option class. The method get() is now used to retrieve the value
instead, which is reflected in changes made to the test file and
predicateStrategy function in the option class.
The commit adds a lock property to deno.jsonc, which is beneficial
for ensuring integrity of the project's dependancies. In addition,
options in deno.xml have been updated to include implementation of
codeLens features such as 'implementations', 'references',
'referencesAllFunctions' and 'test'. Lastly, the commit removes
unused npm package '@biomejs/biome' from deno.lock.
Refactored tests in option.test.ts to use 'expect' for assertions,
making them more readable and consistent with common JavaScript
testing practices. Also added new dependencies related to the biome
project.
This commit introduces a new 'types.ts' file in the 'src/internal'
directory. This file contains TypeScript utility types such as
'Tags', 'Equals', and 'Simplify', each complete with examples and
documentation. These utilities are designed to help handling
TypeScript types much easier in the project.
The existing imports from '@std/assert', '@std/expect', and
'@std/testing' have been refactored to import from their Java
Specification Request (JSR) versions. In addition, the library
'@biomejs/biome' has been removed from the deno.lock and deno.jsonc
files, and the package 'expect-type@0.19.0' has been added.
Enhanced the tests for the `Option.fromNullable` function to include
type checks and added more detailed type explanations in the
documentation comments. This will provide better understanding of the
 function's behavior and clarify its expected return types based on
 the input.
The import statements have been updated to reflect the correct file
extensions and versioning in the assert statements. Type declarations
 for Option values have been clarified to provide more type safety.
Updated the signature for the fold function in the Option class to
take F.Lazy type for the 'ifEmpty' parameter. Also added a new test
suite for the fold function, which includes tests for handling 'None'
 and 'Some' cases.
The commit includes the addition of new dependency 'biomejs/biome'
version '1.7.3' in 'deno.lock' and the necessary dependencies with
their integrity information. Updates were made to 'option.ts' and
'option.test.ts' to include new methods and refine existing ones. In
'option.ts', a static method 'fold' was introduced to simplify option
 value handling, and method ordering was modified in 'Some' class.
 Corresponding test cases in 'option.test.ts' were also adjusted
 accordingly.
Added example usage to the documentation of 'fold' methods in option
.ts file to provide clarity to how the methods should be used. Also,
simplified the body of the fold method by invoking the static fold
method.
The change was made to update the Option.fold method in the option.ts
 file, and also the tests that utilize this method in option.test.ts.
  Now, the method accepts the "ifEmpty" function and the
  transformation function "f" in a curried manner. This facilitates
  greater flexibility when using the Option.fold method, as the
  function can now be partially applied.
The match function was added to the Option module for pattern
matching on Option types. Corresponding unit tests were also included
 for validation. The match function takes an Option and returns a
 value either provided by an 'onNone' parameter or the result of
 function 'onSome' if Option contains a value.
The scripts for doc:lint and doc:test in deno.jsonc file have been
updated to target typescript files in all subdirectories of src. This
 adjustment ensures better documentation and testing coverage across
 all codebase.
The commit adds a new type utility, 'Value', to the Option module
which is used to extract the type of the value from an Option.
Appropriate tests have also been added to ensure the correct
functionality of the newly added utility.
The None method in the Option class was refactored, changing it to
allow for a type parameter. This resulted in a series of changes
across the class to accommodate the new function signature. Test
cases in the option.test.ts file were also updated to reflect this
change, leading to their passing statuses.
The fold method in the Option class and the corresponding test cases
have been updated to return a union type instead of a single type.
Now, it allows more flexibility as it can handle a wider range of
return types. Additionally, detailed remarks have been added for
better understanding and readability of the method's currying feature
 and comparison with the 'reduce' function in other languages.
Copy link

codecov bot commented Jun 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (0d795a0) to head (8cafd60).

Additional details and impacted files
@@            Coverage Diff            @@
##              main        #6   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          226       274   +48     
  Branches        32        35    +3     
=========================================
+ Hits           226       274   +48     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The `pipe` function has been used throughout `option.test.ts` for
better readability and cleaner code structure. This refactoring
includes changes in assertions and test structures. The use of `pipe`
 function enhances functional programming paradigm, making the test
 cases more understandable.
The pattern matching method for 'Option' instances has been
refactored to improve its effectiveness. Now, a function returning
the match result is provided instead of the actual result. Mainly,
changes were made in 'match' comment, function signature, and example
. Refactoring also included slight changes in boolean returns and the
 export type value.
Simplified the fold function within the option.ts file. Made the
function signature more concise and improved the function's return
statement for better readability and maintenance. The refactor should
 not change the function's original functionality.
This commit adds the @biomejs/biome package (version 1.7.3) as a
dependency in deno.lock file. This includes the respective integrity
and version details for different platforms, ensuring project
compatibility across various environments.
…bility

Changed the 'match' function in the Option module to return two
different types, allowing for more flexible functionality. Adjusted
related test cases to match the updated logic.
The commit introduces a new test file for the 'types.ts' utility
types. The file, 'types.test.ts' contains test cases for 'Tag',
'Equal', and 'Simplify' types. The documentation for the utility
types has also been improved with example use cases.
…port them

The Option subclasses, None and Some, used to be public but their
visibility was changed to internal. Also, they are now being exported
 which allows their use in different modules.
An implementation of the pattern matching utility was added to the
Option module. This utility allows callback actions to be specified
for 'Some' and 'None' cases of the 'Option' instance. Associated
tests were also added to verify the utility's functionality.
…and correct link codes

Updated the code in option.ts to provide clearer error messages and
corrected the link codes used for referencing classes/methods.
Specifically, the error message for the direct instantiation of
Option has been updated to instruct users to instantiate derived
classes instead. Also, the various reference link codes have been
revised for better accuracy and clarity. The function fold's return
value has been adjusted for more descriptive information.
Enhanced the function documentation in the 'option.ts' file by adding
 equivalent examples. These extra examples will provide more clarity
 on the function's usage and its behavior in different scenarios.
A new method, `getOrElse`, has been included to the Option module.
This lets you return the option's value if it's nonempty, or
otherwise, return the result of evaluating a supplied default value.
Unit tests for this new addition have also been created and appended
to option.test.ts.
Updated comments to provide more accurate and accessible
documentation for the Option object in option.ts. Changes include
adding code samples for usage demonstration, and linking method names
 in descriptions to their definitions for better navigation and
 understanding.
Improved and expanded code samples in the documentation comments of
option.ts. Detailed usage has been provided to improve understanding
for users. Added `no-eval no-assert` notation where required to avoid
 unwanted evaluations and assertions.
@suddenlyGiovanni suddenlyGiovanni marked this pull request as ready for review June 3, 2024 21:47
@suddenlyGiovanni suddenlyGiovanni merged commit 91c9eba into main Jun 3, 2024
5 checks passed
@suddenlyGiovanni suddenlyGiovanni deleted the option branch June 3, 2024 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant