diff --git a/.changeset/slimy-tigers-matter.md b/.changeset/slimy-tigers-matter.md new file mode 100644 index 0000000..98ad1d5 --- /dev/null +++ b/.changeset/slimy-tigers-matter.md @@ -0,0 +1,5 @@ +--- +"@carbonteq/fp": minor +--- + +Update tooling diff --git a/README.md b/README.md index 0308516..55ab164 100644 --- a/README.md +++ b/README.md @@ -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 => { + if (denom === 0) return Option.None; + + return Option.Some(num / denom); +}; + +const getFormatted = (opt: Option): 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 +``` diff --git a/biome.jsonc b/biome.jsonc index 1a791b9..12d5851 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -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 + } + } } diff --git a/mdsf.json b/mdsf.json index 1ae3017..aefbfaf 100644 --- a/mdsf.json +++ b/mdsf.json @@ -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": {} + } }