-
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.
Merge pull request #34 from VKTRenokh/develop
minor
- Loading branch information
Showing
69 changed files
with
4,199 additions
and
252 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,5 @@ | ||
--- | ||
"@victorenokh/maybe.ts": minor | ||
--- | ||
|
||
Implemented Task, Task Either, Task Maybe monads, implemented prisms, multiple function, namespace autoimport |
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 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 |
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
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,30 @@ | ||
const esbuild = require('esbuild') | ||
const { replaceTscAliasPaths } = require('tsc-alias') | ||
/** | ||
* @type {esbuild.BuildOptions} | ||
*/ | ||
const baseOptions = { | ||
platform: 'node', | ||
outdir: 'dist', | ||
plugins: [], | ||
entryPoints: ['src/*.ts', 'src/**/*.ts'], | ||
} | ||
|
||
esbuild.build({ | ||
...baseOptions, | ||
outExtension: { '.js': '.mjs' }, | ||
format: 'esm', | ||
}) | ||
|
||
esbuild.build({ | ||
...baseOptions, | ||
format: 'cjs', | ||
}) | ||
|
||
replaceTscAliasPaths({ | ||
configFile: 'tsconfig.json', | ||
watch: false, | ||
outDir: 'dist', | ||
declarationDir: 'dist', | ||
fileExtensions: '.mjs', | ||
}) |
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,29 @@ | ||
# Task Either | ||
|
||
You can think of it like a function that return promise of either. | ||
|
||
## tryCatch() | ||
```ts | ||
import { toError } from "@victorenokh/maybe.ts/either" | ||
import { tryCatch } from "@victorenokh/maybe.ts/task-either" | ||
|
||
const parseOrThrow = (res: Response) => { | ||
if (!res.ok) { | ||
throw new Error(res.statusText) | ||
} | ||
|
||
return res.text() | ||
} | ||
|
||
const fetchString = (url: string) => | ||
tryCatch(() => fetch(url).then(parseOrThrow), toError) | ||
|
||
fetchString('https://example.com').fold( | ||
console.error, | ||
console.log, | ||
) // Output: html string of example.com site | ||
fetchString('https://example.com/non/existing/path').fold( | ||
console.error, | ||
console.log, | ||
) // Ouput: Error: internal server error | ||
``` |
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
Oops, something went wrong.