-
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.
Update documentations and fix
trimCRLF
- Loading branch information
1 parent
9bd06fb
commit 74b3303
Showing
26 changed files
with
3,058 additions
and
325 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,17 @@ | ||
export FL_TITLE="Functional IO" | ||
export FL_DESCRIPTION="IO methods as valid Task monads perfect to write great point-free software in JavaScript that is \ | ||
compatible with most modern browsers and Deno." | ||
export FL_GITHUB_URL="https://github.com/sebastienfilion/functional-io" | ||
export FL_DENO_URL="https://deno.land/x/functional_io" | ||
export FL_VERSION="v1.1.0" | ||
|
||
deno run --allow-all --unstable ../@functional:generate-documentation/cli.js document \ | ||
"$FL_TITLE" \ | ||
"$FL_DESCRIPTION" \ | ||
$FL_GITHUB_URL \ | ||
$FL_DENO_URL \ | ||
$FL_VERSION \ | ||
./.github/readme-fragment-usage.md \ | ||
./library/*.js \ | ||
./.github/readme-fragment-typescript.md \ | ||
./.github/readme-fragment-license.md |
File renamed without changes
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,9 @@ | ||
## License | ||
|
||
Copyright © 2020 - Sebastien Filion | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,23 @@ | ||
## TypeScript | ||
|
||
You can import any types. | ||
|
||
```ts | ||
import { | ||
Buffer, | ||
Directory, | ||
File, | ||
Request, | ||
Resource, | ||
Response, | ||
URL | ||
} from "https://deno.land/x/[email protected]/mod.ts"; | ||
``` | ||
|
||
Or, you can import individual sub-module with the appropriate TypeScript hint in Deno. | ||
|
||
```ts | ||
// @deno-types="https://deno.land/x/[email protected]/library/Request.d.ts" | ||
import Request from "https://deno.land/x/[email protected]/library/Request.js"; | ||
``` | ||
|
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,64 @@ | ||
# Usage | ||
|
||
This example uses the [Ramda library](https://ramdajs.com) - for simplification - but you should be able to use any | ||
library that implements the [Fantasy-land specifications](https://github.com/fantasyland/fantasy-land). | ||
|
||
```js | ||
import { __, ap, chain, compose, lift, map, match, path, prop, useWith } from "https://deno.land/x/[email protected]/mod.ts"; | ||
import Task from "https://deno.land/x/[email protected]/library/Task.js"; | ||
import { safeExtract } from "https://deno.land/x/[email protected]/library/utilities.js"; | ||
import Request from "https://deno.land/x/[email protected]/library/Request.js"; | ||
import { factorizeFile } from "https://deno.land/x/[email protected]/library/File.js"; | ||
import { fetch } from "https://deno.land/x/[email protected]/library/browser_safe.js"; | ||
import { writeFile } from "https://deno.land/x/[email protected]/library/fs.js"; | ||
|
||
const fetchBacon = compose( | ||
chain(writeFile({})), | ||
ap( | ||
useWith( | ||
lift(factorizeFile(__, __, 0)), | ||
[ | ||
compose( | ||
Task.of, | ||
name => `${Deno.cwd()}/${name}.html`, | ||
prop(1), | ||
match(/\?type=([A-Za-z\-]+)/), | ||
path([ "headers", "url" ]) | ||
), | ||
map(prop("raw")) | ||
] | ||
), | ||
fetch | ||
) | ||
); | ||
|
||
const container = fetchBacon( | ||
Request.get("https://baconipsum.com/api/?type=all-meat¶s=3&start-with-lorem=1&format=html") | ||
); | ||
|
||
// Calling `fetchBacon` results in an instance of `Task` keeping the function pure. | ||
assert(Task.is(container)); | ||
|
||
const file = safeExtract("Failed to write file.", await container.run()); | ||
|
||
assert(File.is(file)); | ||
``` | ||
|
||
### Using the bundle | ||
|
||
As a convenience, when using Functional IO in the browser, you can use the **unminified** bundled copy (18KB gzipped). | ||
|
||
```js | ||
import { Task, safeExtract } from "https://deno.land/x/[email protected]/functional.js"; | ||
import { Request, Response, fetch } from "https://deno.land/x/[email protected]/functional-io.js"; | ||
|
||
const container = fetch( | ||
Request.get("https://baconipsum.com/api/?type=all-meat¶s=3&start-with-lorem=1&format=html") | ||
); | ||
|
||
assert(Task.is(container)); | ||
|
||
const response = safeExtract("Failed to fetch resource.", await container.run()); | ||
|
||
assert(Response.is(response)); | ||
``` |
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,24 @@ | ||
.DS_Store | ||
.data/ | ||
.docs/ | ||
.dump/ | ||
.idea/ | ||
.nyc_output/ | ||
.sass-cache/ | ||
coverage/ | ||
journal/ | ||
node_modules/ | ||
out/ | ||
scratch/ | ||
|
||
*.db | ||
*.iml | ||
*.log | ||
*.rdb | ||
*.zip | ||
|
||
.todo.md | ||
|
||
dmfx | ||
.dmfx | ||
*.dmfx.js |
Oops, something went wrong.