Skip to content

Commit

Permalink
added readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Inalegwu committed Sep 16, 2024
1 parent a61f6d1 commit 801f3d7
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## MakeSafeFunc
Finally be sure your functions don't throw


<i>
MakeSafeFunc was created to wrap functions I'm not sure
can throw and returning a simple Result type by utilizing
neverthrow under the hood
</i>



### Examples

```ts
import {makeSafeFunc} from "make-safe-func";

function unsafeDivide(a:number,b:number){
if(b===0) throw new Error("Divide by Zero Error");
return a/b
}

const safeDivide=makeSafeFunc(unsafeDivide);

safeDivide(1/2).match(console.log,console.error);
const result=safeDivide._unsafeUnwrap();

console.log(result);
```

0 comments on commit 801f3d7

Please sign in to comment.