Skip to content

Commit

Permalink
add soem examples
Browse files Browse the repository at this point in the history
  • Loading branch information
volf52 committed Nov 15, 2024
1 parent 017af22 commit d304e29
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 56 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-tigers-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@carbonteq/fp": minor
---

Update tooling
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
# FP Utils

## Installation

```sh
npm i @carbonteq/fp
```

```sh
pnpm i @carbonteq/fp
```

```sh
yarn add @carbonteq/fp
```

## Usage

```typescript
import { Option, matchOpt } from "@carbonteq/fp";

const safeDiv = (num: number, denom: number): Option<number> => {
if (denom === 0) return Option.None;

return Option.Some(num / denom);
};

const getFormatted = (opt: Option<number>): string => {
return matchOpt(opt, {
Some: (n) => `Result: ${n}`,
None: () => "Cannot divide by zero",
});
};

console.log(getFormatted(safeDiv(10, 2))); // Result: 5
console.log(getFormatted(safeDiv(10, 0))); // Cannot divide by zero
```
66 changes: 33 additions & 33 deletions biome.jsonc
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "main"
},
"files": {
"ignoreUnknown": false,
"ignore": ["dist", "node_modules"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"semicolons": "always",
"indentStyle": "space",
"indentWidth": 2
}
}
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": true,
"defaultBranch": "main"
},
"files": {
"ignoreUnknown": false,
"ignore": ["dist", "node_modules"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"semicolons": "always",
"indentStyle": "space",
"indentWidth": 2
}
}
}
29 changes: 6 additions & 23 deletions mdsf.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
{
"$schema": "https://raw.githubusercontent.com/hougesen/mdsf/main/schemas/v0.2.1/mdsf.schema.json",
"$schema": "https://raw.githubusercontent.com/hougesen/mdsf/main/schemas/v0.3.1/mdsf.schema.json",
"format_finished_document": false,
"javascript_runtime": "node",
"languages": {
"c": "clang-format",
"cpp": "clang-format",
"csharp": [["csharpier", "clang-format"]],
"css": [["prettier", "stylelint"]],
"go": [
["gci", "goimports-reviser", "goimports"],
["gofumpt", "gofmt", "crlfmt"]
],
"haskell": [["fourmolu", "ormolu", "hindent", "stylish-haskell"]],
"html": [["prettier", "djlint"]],
"java": [["google-java-format", "clang-format"]],
"javascript": ["biome"],
"json": ["biome"],
"lua": [["stylua", "luaformatter"]],
"python": [
["usort", "isort"],
["ruff", "blue", "black", "yapf", "autopep8", "pyink"]
],
"rust": "rustfmt",
"javascript": ["biome:format"],
"json": ["biome:format"],
"shell": [["shfmt", "beautysh"]],
"sql": [["sqlfluff", "sql-formatter"]],
"toml": "taplo",
"typescript": ["biome"],
"sh": [["shfmt", "beautysh"]],
"typescript": ["biome:format"],
"yaml": [["prettier", "yamlfmt", "yamlfix"]]
},
"custom_file_extensions": {}
}
}

0 comments on commit d304e29

Please sign in to comment.