From 11294984aa0cc58f3571729a3d6aeb8ca084a7d7 Mon Sep 17 00:00:00 2001 From: Rea Sand Date: Thu, 18 Oct 2018 11:57:50 +0200 Subject: [PATCH 1/2] docs: consistently use Option instead of Optional --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 1a1e23b..943a8d5 100644 --- a/readme.md +++ b/readme.md @@ -950,7 +950,7 @@ times(-1)(console.log) // RangeError: Maximum call stack size exceeded ``` ### Avoiding partial functions -Partial functions are dangerous, you can sometimes get the expected result, sometimes the wrong result, and sometimes your function can't stop the calculations at all. The input of partial functions should be always checked, and it can be hard to track all edge cases through entire applications, the easiest way to deal with it it's just to convert all partial functions to the total. General advice can be the usage of `Optional` type, providing default values for edge cases and checking function conditions to make them always terminate: +Partial functions are dangerous, you can sometimes get the expected result, sometimes the wrong result, and sometimes your function can't stop the calculations at all. The input of partial functions should be always checked, and it can be hard to track all edge cases through entire applications, the easiest way to deal with it it's just to convert all partial functions to the total. General advice can be the usage of `Option` type, providing default values for edge cases and checking function conditions to make them always terminate: ```js // example 1: sum of the list // we can provide default value so it will always return result From 0ebee1d815bced1677d353b4b1ba7d6496ae6c9e Mon Sep 17 00:00:00 2001 From: Rea Sand Date: Thu, 18 Oct 2018 11:59:54 +0200 Subject: [PATCH 2/2] fix: drop trailing whitespace --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 943a8d5..6531c19 100644 --- a/readme.md +++ b/readme.md @@ -946,7 +946,7 @@ times(3)(console.log) // 3 // 2 // 1 -times(-1)(console.log) +times(-1)(console.log) // RangeError: Maximum call stack size exceeded ``` ### Avoiding partial functions @@ -980,7 +980,7 @@ times(3)(console.log) // 3 // 2 // 1 -times(-1)(console.log) +times(-1)(console.log) // won't execute anything ``` If you will change all your functions from partial to total, it can prevent you from having runtime exceptions, will make code easier to reason about and easier to maintain.