-
Notifications
You must be signed in to change notification settings - Fork 7
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 #71 from Jozty/70-style-use-deno-lint-and-fmt-for-…
…formatting-purposes 70 style use deno lint and fmt for formatting purposes
- Loading branch information
Showing
274 changed files
with
5,942 additions
and
6,080 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 |
---|---|---|
@@ -1,36 +1,35 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.236.0/containers/deno | ||
{ | ||
"name": "Deno", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
// Update 'VARIANT' to pick an Debian OS version: bullseye, buster | ||
"args": { | ||
"VARIANT": "bullseye" | ||
} | ||
}, | ||
"name": "Deno", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
// Update 'VARIANT' to pick an Debian OS version: bullseye, buster | ||
"args": { | ||
"VARIANT": "bullseye" | ||
} | ||
}, | ||
|
||
// Configure tool-specific properties. | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
// Enables the project as a Deno project | ||
"deno.enable": true, | ||
// Enables Deno linting for the project | ||
"deno.lint": true, | ||
// Sets Deno as the default formatter for the project | ||
"editor.defaultFormatter": "denoland.vscode-deno" | ||
}, | ||
// Configure tool-specific properties. | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
// Enables the project as a Deno project | ||
"deno.enable": true, | ||
// Enables Deno linting for the project | ||
"deno.lint": true, | ||
// Sets Deno as the default formatter for the project | ||
"editor.defaultFormatter": "denoland.vscode-deno" | ||
}, | ||
|
||
|
||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"denoland.vscode-deno" | ||
] | ||
} | ||
}, | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"denoland.vscode-deno" | ||
] | ||
} | ||
}, | ||
|
||
"remoteUser": "vscode" | ||
"remoteUser": "vscode" | ||
} |
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
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 |
---|---|---|
|
@@ -15,4 +15,4 @@ | |
"request": "attach", | ||
"port": 9229 | ||
}] | ||
} | ||
} |
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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
{ | ||
"deno.enable": true, | ||
"editor.formatOnSave": true, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
}, | ||
"workbench.colorCustomizations": {}, | ||
"window.titleBarStyle": "custom", | ||
"deno.import_intellisense_origins": { | ||
"https://deno.land": true | ||
} | ||
"deno.lint": true, | ||
"editor.defaultFormatter": "denoland.vscode-deno", | ||
"deno.codeLens.implementations": true, | ||
"deno.codeLens.references": true, | ||
"deno.codeLens.test": true, | ||
"deno.codeLens.referencesAllFunctions": true | ||
} |
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
![](./assets/logo-160x160-2.png) | ||
|
||
|
||
# Fae | ||
|
||
[![CodeFactor](https://www.codefactor.io/repository/github/jozty/fae/badge)](https://www.codefactor.io/repository/github/jozty/fae) | ||
|
@@ -9,10 +8,16 @@ | |
![GitHub](https://img.shields.io/github/license/jozty/fae) | ||
[![codecov](https://codecov.io/gh/Jozty/Fae/branch/master/graph/badge.svg)](https://codecov.io/gh/Jozty/Fae) | ||
|
||
Fae is a fully-fledged library that supports the functional style of programming | ||
in Deno and is inspired from [Ramda](https://ramdajs.com). This style provides | ||
many benefits like it never mutates input data and is used to create function | ||
pipelines. Fae functions are automatically curried. The data to be operated on | ||
is generally supplied last. It results in easy to build functions as sequences | ||
of simpler or atomic functions (pipelines), each of which transforms the data | ||
and passes it along to the next. | ||
|
||
Fae is a fully-fledged library that supports the functional style of programming in Deno and is inspired from [Ramda](https://ramdajs.com). This style provides many benefits like it never mutates input data and is used to create function pipelines. Fae functions are automatically curried. The data to be operated on is generally supplied last. It results in easy to build functions as sequences of simpler or atomic functions (pipelines), each of which transforms the data and passes it along to the next. | ||
|
||
Fae provides over 110 functions that help programmers to write clean and concise code. | ||
Fae provides over 110 functions that help programmers to write clean and concise | ||
code. | ||
|
||
## Installing | ||
|
||
|
@@ -21,7 +26,7 @@ _Deno allows you to directly import modules from URLs!_ | |
To import and use the client in your file, add the following import statement: | ||
|
||
```typescript | ||
import * as Fae from 'https://deno.land/x/[email protected]/mod.ts' | ||
import * as Fae from 'https://deno.land/x/[email protected]/mod.ts'; | ||
``` | ||
|
||
Function usage and documentation can be found [here](https://fae.jozty.io/) | ||
|
@@ -37,51 +42,59 @@ deno test --coverage --unstable | |
### Usage | ||
|
||
```typescript | ||
import * as Fae from 'https://deno.land/x/[email protected]/mod.ts' | ||
import * as Fae from 'https://deno.land/x/[email protected]/mod.ts'; | ||
|
||
// arithmetic functions | ||
Fae.add(10, 20) // 30 | ||
Fae.add(10)(20) // 30 | ||
Fae.add(10, 20); // 30 | ||
Fae.add(10)(20); // 30 | ||
|
||
const add20 = Fae.add(20) | ||
add20(10) // 30 | ||
add20(125) // 145 | ||
const add20 = Fae.add(20); | ||
add20(10); // 30 | ||
add20(125); // 145 | ||
|
||
// Expression - (2*5+5-10)/2 | ||
const double = Fae.multiply(2) | ||
const half = Fae.divide(Fae._, 2) | ||
const add5 = Fae.add(5) | ||
const subtract10 = Fae.subtract(Fae._, 10) | ||
|
||
half(subtract10(add5(double(15)))) // 12.5 | ||
Fae.compose(half, subtract10, add5, double)(15) // 12.5 | ||
Fae.pipe(double, add5, subtract10, half)(15) // 12.5 | ||
const double = Fae.multiply(2); | ||
const half = Fae.divide(Fae._, 2); | ||
const add5 = Fae.add(5); | ||
const subtract10 = Fae.subtract(Fae._, 10); | ||
|
||
half(subtract10(add5(double(15)))); // 12.5 | ||
Fae.compose(half, subtract10, add5, double)(15); // 12.5 | ||
Fae.pipe(double, add5, subtract10, half)(15); // 12.5 | ||
``` | ||
|
||
**With lenses** | ||
|
||
```typescript | ||
import { lens, view, over, inc, set } from 'https://deno.land/x/[email protected]/mod.ts' | ||
import { | ||
inc, | ||
lens, | ||
over, | ||
set, | ||
view, | ||
} from 'https://deno.land/x/[email protected]/mod.ts'; | ||
|
||
const array = [1, 2, 3, 4, 5, 6, 7, 8] | ||
const array = [1, 2, 3, 4, 5, 6, 7, 8]; | ||
|
||
// gets element at index `0` | ||
function getter(a: number[]) { | ||
return a[0] | ||
return a[0]; | ||
} | ||
|
||
// returns a new array by setting passed value `val` at index `0` | ||
function setter(val: number, a: number[]) { | ||
const x = [...a] | ||
x[0] = val | ||
return x | ||
const x = [...a]; | ||
x[0] = val; | ||
return x; | ||
} | ||
|
||
const l = lens(getter, setter) | ||
const l = lens(getter, setter); | ||
|
||
const viewResult = view(l, array) | ||
const overResult = over(l, inc, array) | ||
const setResult = set(l, 12, array) | ||
const viewResult = view(l, array); | ||
const overResult = over(l, inc, array); | ||
const setResult = set(l, 12, array); | ||
|
||
console.log(viewResult) // 1 | ||
console.log(overResult) // [2, 2, 3, 4, 5, 6, 7, 8] | ||
console.log(setResult) // [12, 2, 3, 4, 5, 6, 7, 8] | ||
console.log(viewResult); // 1 | ||
console.log(overResult); // [2, 2, 3, 4, 5, 6, 7, 8] | ||
console.log(setResult); // [12, 2, 3, 4, 5, 6, 7, 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
Oops, something went wrong.