Skip to content

Commit 74b3303

Browse files
Update documentations and fix trimCRLF
1 parent 9bd06fb commit 74b3303

26 files changed

+3058
-325
lines changed

.github/document.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export FL_TITLE="Functional IO"
2+
export FL_DESCRIPTION="IO methods as valid Task monads perfect to write great point-free software in JavaScript that is \
3+
compatible with most modern browsers and Deno."
4+
export FL_GITHUB_URL="https://github.com/sebastienfilion/functional-io"
5+
export FL_DENO_URL="https://deno.land/x/functional_io"
6+
export FL_VERSION="v1.1.0"
7+
8+
deno run --allow-all --unstable ../@functional:generate-documentation/cli.js document \
9+
"$FL_TITLE" \
10+
"$FL_DESCRIPTION" \
11+
$FL_GITHUB_URL \
12+
$FL_DENO_URL \
13+
$FL_VERSION \
14+
./.github/readme-fragment-usage.md \
15+
./library/*.js \
16+
./.github/readme-fragment-typescript.md \
17+
./.github/readme-fragment-license.md
File renamed without changes.

.github/readme-fragment-license.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## License
2+
3+
Copyright © 2020 - Sebastien Filion
4+
5+
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:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
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.

.github/readme-fragment-typescript.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
## TypeScript
2+
3+
You can import any types.
4+
5+
```ts
6+
import {
7+
Buffer,
8+
Directory,
9+
File,
10+
Request,
11+
Resource,
12+
Response,
13+
URL
14+
} from "https://deno.land/x/[email protected]/mod.ts";
15+
```
16+
17+
Or, you can import individual sub-module with the appropriate TypeScript hint in Deno.
18+
19+
```ts
20+
// @deno-types="https://deno.land/x/[email protected]/library/Request.d.ts"
21+
import Request from "https://deno.land/x/[email protected]/library/Request.js";
22+
```
23+

.github/readme-fragment-usage.md

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# Usage
2+
3+
This example uses the [Ramda library](https://ramdajs.com) - for simplification - but you should be able to use any
4+
library that implements the [Fantasy-land specifications](https://github.com/fantasyland/fantasy-land).
5+
6+
```js
7+
import { __, ap, chain, compose, lift, map, match, path, prop, useWith } from "https://deno.land/x/[email protected]/mod.ts";
8+
import Task from "https://deno.land/x/[email protected]/library/Task.js";
9+
import { safeExtract } from "https://deno.land/x/[email protected]/library/utilities.js";
10+
import Request from "https://deno.land/x/[email protected]/library/Request.js";
11+
import { factorizeFile } from "https://deno.land/x/[email protected]/library/File.js";
12+
import { fetch } from "https://deno.land/x/[email protected]/library/browser_safe.js";
13+
import { writeFile } from "https://deno.land/x/[email protected]/library/fs.js";
14+
15+
const fetchBacon = compose(
16+
chain(writeFile({})),
17+
ap(
18+
useWith(
19+
lift(factorizeFile(__, __, 0)),
20+
[
21+
compose(
22+
Task.of,
23+
name => `${Deno.cwd()}/${name}.html`,
24+
prop(1),
25+
match(/\?type=([A-Za-z\-]+)/),
26+
path([ "headers", "url" ])
27+
),
28+
map(prop("raw"))
29+
]
30+
),
31+
fetch
32+
)
33+
);
34+
35+
const container = fetchBacon(
36+
Request.get("https://baconipsum.com/api/?type=all-meat&paras=3&start-with-lorem=1&format=html")
37+
);
38+
39+
// Calling `fetchBacon` results in an instance of `Task` keeping the function pure.
40+
assert(Task.is(container));
41+
42+
const file = safeExtract("Failed to write file.", await container.run());
43+
44+
assert(File.is(file));
45+
```
46+
47+
### Using the bundle
48+
49+
As a convenience, when using Functional IO in the browser, you can use the **unminified** bundled copy (18KB gzipped).
50+
51+
```js
52+
import { Task, safeExtract } from "https://deno.land/x/[email protected]/functional.js";
53+
import { Request, Response, fetch } from "https://deno.land/x/[email protected]/functional-io.js";
54+
55+
const container = fetch(
56+
Request.get("https://baconipsum.com/api/?type=all-meat&paras=3&start-with-lorem=1&format=html")
57+
);
58+
59+
assert(Task.is(container));
60+
61+
const response = safeExtract("Failed to fetch resource.", await container.run());
62+
63+
assert(Response.is(response));
64+
```

.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.DS_Store
2+
.data/
3+
.docs/
4+
.dump/
5+
.idea/
6+
.nyc_output/
7+
.sass-cache/
8+
coverage/
9+
journal/
10+
node_modules/
11+
out/
12+
scratch/
13+
14+
*.db
15+
*.iml
16+
*.log
17+
*.rdb
18+
*.zip
19+
20+
.todo.md
21+
22+
dmfx
23+
.dmfx
24+
*.dmfx.js

0 commit comments

Comments
 (0)