From 7f52025cafcc6aa09976d4134f502f4cf97c2897 Mon Sep 17 00:00:00 2001 From: Lou Cyx Date: Fri, 19 Dec 2025 22:00:53 -0600 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=94=A7=20reinstate=20prettier=20now?= =?UTF-8?q?=20that=20we=20can=20ignore=20flags.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yml | 5 +- .vscode/extensions.json | 6 +- .vscode/settings.json | 4 +- .zed/settings.json | 34 +++-------- .zed/tasks.json | 4 +- TODO.md | 2 +- deno.json | 46 ++++++++------- prettier.config.ts | 103 ++++++++++++++++++++++++++++++++++ 8 files changed, 147 insertions(+), 57 deletions(-) create mode 100644 prettier.config.ts diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1733c9e..c3574ba 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -28,13 +28,14 @@ jobs: run: deno task lint-docs - name: Format - run: deno fmt --check + run: deno task format - name: Test run: deno task test-coverage - name: Generate Coverage - run: deno coverage --exclude='tests/' --lcov coverage/ > + run: + deno coverage --exclude='tests/' --lcov coverage/ > coverage.lcov - name: Publish Coverage diff --git a/.vscode/extensions.json b/.vscode/extensions.json index f544c83..c0da385 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1 @@ -{ - "recommendations": [ - "denoland.vscode-deno" - ] -} +{ "recommendations": ["denoland.vscode-deno", "esbenp.prettier-vscode"] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 90dff57..94716ba 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,12 @@ { "deno.enable": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, "[yaml]": { "editor.insertSpaces": true, "editor.tabSize": 4, "editor.autoIndent": "advanced", "diffEditor.ignoreTrimWhitespace": false - } + }, + "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" } } diff --git a/.zed/settings.json b/.zed/settings.json index 9120a8e..d800c25 100644 --- a/.zed/settings.json +++ b/.zed/settings.json @@ -1,47 +1,31 @@ { "format_on_save": "on", - "formatter": [ - { - "code_action": "source.organizeImports" - }, - "language_server" - ], + "formatter": [{ "code_action": "source.organizeImports" }, "prettier"], "languages": { "JavaScript": { - "formatter": "language_server", "language_servers": [ "deno", "!typescript-language-server", "!vtsls", - "!eslint" - ] + "!eslint", + ], }, "TSX": { - "formatter": "language_server", "language_servers": [ "deno", "!typescript-language-server", "!vtsls", - "!eslint" - ] + "!eslint", + ], }, "TypeScript": { - "formatter": "language_server", "language_servers": [ "deno", "!typescript-language-server", "!vtsls", - "!eslint" - ] - } + "!eslint", + ], + }, }, - "lsp": { - "deno": { - "settings": { - "deno": { - "enable": true - } - } - } - } + "lsp": { "deno": { "settings": { "deno": { "enable": true } } } }, } diff --git a/.zed/tasks.json b/.zed/tasks.json index 9a7bee5..5bc5aa1 100644 --- a/.zed/tasks.json +++ b/.zed/tasks.json @@ -2,8 +2,6 @@ { "command": "deno test -A --filter '/^$ZED_CUSTOM_DENO_TEST_NAME$/' $ZED_FILE", "label": "deno test", - "tags": [ - "js-test" - ] + "tags": ["js-test"] } ] diff --git a/TODO.md b/TODO.md index 78ec7a0..d2097e8 100644 --- a/TODO.md +++ b/TODO.md @@ -1 +1 @@ -[ ] `@simulcast/angular`. +- [ ] `@simulcast/angular`. diff --git a/deno.json b/deno.json index fe1abd3..a83b54f 100644 --- a/deno.json +++ b/deno.json @@ -9,9 +9,7 @@ "noUnusedParameters": true, "strict": true }, - "exclude": [ - "coverage" - ], + "exclude": ["coverage"], "fmt": { "bracePosition": "sameLine", "indentWidth": 4, @@ -32,18 +30,15 @@ "typeLiteral.separatorKind": "semiColon", "useBraces": "always", "useTabs": true, - "exclude": [ - "**/logo.svg" - ] + "exclude": ["**/logo.svg"] }, "imports": { "@std/assert": "jsr:@std/assert@^1.0.16", - "happy-dom": "npm:happy-dom@^20.0.11" + "happy-dom": "npm:happy-dom@^20.0.11", + "prettier": "npm:prettier@^3.7.4" }, "lint": { - "plugins": [ - "./lint/mod.ts" - ], + "plugins": ["./lint/mod.ts"], "rules": { "include": [ "ban-untagged-todo", @@ -72,20 +67,31 @@ "single-var-declarator", "triple-slash-reference" ], - "tags": [ - "jsr", - "jsx", - "react", - "recommended", - "workspace" - ] + "tags": ["jsr", "jsx", "react", "recommended", "workspace"] } }, "nodeModulesDir": "auto", "tasks": { - "lint-docs": "deno doc --lint ./@coven/**/*.ts ./@simulcast/**/*.ts", - "test": "deno test --ignore-env --import=./setupTests.ts --parallel", - "test-coverage": "deno test --ignore-env --coverage --doc --import=./setupTests.ts --parallel --quiet" + "format": { + "command": "deno run --allow-env=TMPDIR --ignore-env --allow-read=.,$TMPDIR/.prettier-cache --allow-write=.,$TMPDIR/.prettier-cache --allow-sys=cpus --no-prompt prettier --log-level=warn --write './**/*.{json,md,ts,tsx}'", + "description": "Format code using Prettier" + }, + "format-check": { + "command": "deno run --allow-env=TMPDIR --ignore-env --allow-read=.,$TMPDIR/.prettier-cache --allow-sys=cpus --no-prompt prettier --check './**/*.{json,md,ts,tsx}'", + "description": "Check formatting using Prettier" + }, + "lint-docs": { + "command": "deno doc --lint ./@coven/**/*.ts ./@simulcast/**/*.ts", + "description": "Run linter over all the code, including documentation" + }, + "test": { + "command": "deno test --ignore-env --import=./setupTests.ts --parallel", + "description": "Run tests in parallel with setup script" + }, + "test-coverage": { + "command": "deno test --ignore-env --coverage --doc --import=./setupTests.ts --parallel --quiet", + "description": "Run tests generating coverage (even for documentation)" + } }, "workspace": [ "./@coven/compare", diff --git a/prettier.config.ts b/prettier.config.ts new file mode 100644 index 0000000..e604c39 --- /dev/null +++ b/prettier.config.ts @@ -0,0 +1,103 @@ +import type { Options } from "prettier"; + +/** + * Prettier configuration. + * @see [Prettier options](https://prettier.io/docs/en/options.html) + */ +// deno-lint-ignore coven/no-default-export +export default { + /** + * Avoid parentheses around a sole arrow function parameter. + */ + arrowParens: "always", + + /** + * Put the `>` of a multi-line HTML like in a new line. + */ + bracketSameLine: false, + + /** + * Print spaces between brackets in object literals. + */ + bracketSpacing: true, + + /** + * Control whether Prettier formats quoted code embedded in the file. + */ + embeddedLanguageFormatting: "auto", + + /** + * Unix EOL. + */ + endOfLine: "lf", + + /** + * Use curious ternaries, with the question mark after the condition, instead of on the same line as the consequent. + */ + experimentalTernaries: true, + + /** + * Put operators at the start of lines + */ + experimentalOperatorPosition: "start", + + /** + * Strict whitespace in HTML. + */ + htmlWhitespaceSensitivity: "strict", + + /** + * JSX should use double quote. + */ + jsxSingleQuote: false, + + /** + * Print width is ideal at 80 characters. + */ + printWidth: 80, + + /** + * Wrap text to fit the print width. + */ + proseWrap: "always", + + /** + * Add quotes around properties of object if needed. + */ + quoteProps: "as-needed", + + /** + * Print semicolons at the ends of statements. + */ + semi: true, + + /** + * Shows multiple attributes per line in HTML, Vue and JSX. + */ + singleAttributePerLine: false, + + /** + * Use double quotes. + */ + singleQuote: false, + + /** + * Tab width at 4 is ideal. + */ + tabWidth: 4, + + /** + * Add trailing commas to make edition easier and diffing better. + */ + trailingComma: "all", + + /** + * Obviously use tabs. + */ + useTabs: true, + + /** + * Indent code in Vue files. + */ + vueIndentScriptAndStyle: true, +} as const satisfies Options; From 8b0195b160e83c3fd4039347dee5dc7a2054f0f2 Mon Sep 17 00:00:00 2001 From: Lou Cyx Date: Fri, 19 Dec 2025 22:21:38 -0600 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=8E=A8=20prettier=20formatting=20agai?= =?UTF-8?q?n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yml | 2 +- .zed/settings.json | 16 +- @coven/compare/FlatDifference.ts | 11 +- @coven/compare/compareIterables.ts | 67 ++++--- @coven/compare/compareObjects.ts | 31 ++- @coven/compare/compareProperties.ts | 21 +- @coven/compare/differentiate.ts | 14 +- @coven/compare/getKeys.ts | 16 +- @coven/compare/pathPrepend.ts | 2 +- @coven/compare/tests/compare.test.ts | 51 +++-- @coven/compare/tests/pathPrepend.test.ts | 6 +- .../compare/tests/valueToDifference.test.ts | 3 +- @coven/constants/tests/EMPTY_ARRAY.test.ts | 12 +- @coven/constants/tests/EMPTY_OBJECT.test.ts | 2 +- @coven/cron/compareField.ts | 6 +- @coven/cron/compareRangeOrValue.ts | 8 +- @coven/cron/cronRegExp.ts | 189 +++++++++--------- @coven/cron/fieldRegExp.ts | 13 +- @coven/cron/isAllToken.ts | 5 +- @coven/cron/nextISODates.ts | 2 +- @coven/cron/normalizeMap.ts | 48 +++-- @coven/cron/paddedRegExp.ts | 2 +- @coven/cron/parse.ts | 13 +- @coven/cron/parseField.ts | 2 +- @coven/cron/parseList.ts | 6 +- @coven/cron/parseNumber.ts | 6 +- @coven/cron/parseRange.ts | 22 +- @coven/cron/stringifyField.ts | 4 +- @coven/cron/stringifyList.ts | 6 +- @coven/cron/stringifyRange.ts | 6 +- @coven/cron/tests/compareField.test.ts | 18 +- @coven/cron/tests/compareRangeOrValue.test.ts | 12 +- @coven/cron/tests/fieldRegExp.test.ts | 3 +- @coven/cron/tests/isAllToken.test.ts | 3 +- @coven/cron/tests/isListField.test.ts | 9 +- @coven/cron/tests/isListString.test.ts | 9 +- @coven/cron/tests/isNumberString.test.ts | 3 +- @coven/cron/tests/isRangeField.test.ts | 9 +- @coven/cron/tests/isRangeString.test.ts | 9 +- @coven/cron/tests/isValidExpression.test.ts | 12 +- @coven/cron/tests/nextISODate.test.ts | 30 ++- @coven/cron/tests/nextISODates.test.ts | 24 ++- @coven/cron/tests/normalizeAliases.test.ts | 3 +- @coven/cron/tests/paddedRegExp.test.ts | 3 +- @coven/cron/tests/parse.test.ts | 33 ++- @coven/cron/tests/parseField.test.ts | 12 +- @coven/cron/tests/parseFieldTuplesMap.test.ts | 12 +- @coven/cron/tests/parseList.test.ts | 3 +- @coven/cron/tests/parseListMap.test.ts | 3 +- @coven/cron/tests/parseNumber.test.ts | 9 +- @coven/cron/tests/parseNumberMap.test.ts | 9 +- @coven/cron/tests/parseNumberTest.test.ts | 9 +- @coven/cron/tests/parseRange.test.ts | 9 +- @coven/cron/tests/rangeStringTest.test.ts | 3 +- @coven/cron/tests/stringify.test.ts | 12 +- @coven/cron/tests/stringifyField.test.ts | 6 +- @coven/cron/tests/stringifyList.test.ts | 6 +- @coven/cron/tests/stringifyRange.test.ts | 6 +- @coven/cron/tests/timestampInCron.test.ts | 8 +- @coven/cron/tests/valueOrRangeRegExp.test.ts | 3 +- .../cron/tests/valueRangeOrListRegExp.test.ts | 3 +- @coven/cron/tests/zipRangeNames.test.ts | 3 +- @coven/cron/timestampInCron.ts | 24 +-- @coven/cron/valueRangeOrListRegExp.ts | 9 +- @coven/cron/zipRangeNames.ts | 10 +- @coven/expression/build.ts | 24 ++- @coven/expression/captureNamed.ts | 2 +- @coven/expression/captureType.ts | 7 +- @coven/expression/hexadecimal.ts | 2 +- @coven/expression/modifier.ts | 2 +- @coven/expression/quantity.ts | 15 +- @coven/expression/range.ts | 2 +- @coven/expression/tests/allow.test.ts | 6 +- @coven/expression/tests/backreference.test.ts | 3 +- @coven/expression/tests/build.test.ts | 3 +- @coven/expression/tests/buildUnicode.test.ts | 3 +- @coven/expression/tests/capture.test.ts | 6 +- .../expression/tests/characterClass.test.ts | 6 +- .../expression/tests/complementClass.test.ts | 6 +- .../expression/tests/controlCharacter.test.ts | 3 +- @coven/expression/tests/disjunction.test.ts | 3 +- @coven/expression/tests/escape.test.ts | 3 +- @coven/expression/tests/exists.test.ts | 6 +- @coven/expression/tests/group.test.ts | 6 +- @coven/expression/tests/join.test.ts | 3 +- @coven/expression/tests/lookahead.test.ts | 3 +- @coven/expression/tests/lookbehind.test.ts | 6 +- @coven/expression/tests/modifier.test.ts | 18 +- .../tests/namedBackreference.test.ts | 3 +- .../tests/negativeLookahead.test.ts | 6 +- .../tests/negativeLookbehind.test.ts | 6 +- @coven/expression/tests/optional.test.ts | 6 +- @coven/expression/tests/range.test.ts | 3 +- @coven/expression/tests/unicode.test.ts | 3 +- .../tests/unicodeCharacterClassEscape.test.ts | 3 +- @coven/expression/unicode.ts | 2 +- @coven/iterables/EMPTY_ITERABLE_ITERATOR.ts | 5 +- @coven/iterables/append.ts | 25 +-- @coven/iterables/async/append.ts | 25 +-- @coven/iterables/async/drop.ts | 4 +- @coven/iterables/async/every.ts | 21 +- @coven/iterables/async/filter.ts | 31 +-- @coven/iterables/async/find.ts | 21 +- @coven/iterables/async/flat.ts | 32 +-- @coven/iterables/async/forEach.ts | 17 +- @coven/iterables/async/getIterator.ts | 24 ++- @coven/iterables/async/groupBy.ts | 8 +- @coven/iterables/async/head.ts | 13 +- @coven/iterables/async/initial.ts | 2 +- @coven/iterables/async/intersperse.ts | 4 +- ...iteratorFunctionToAsyncIterableIterator.ts | 12 +- @coven/iterables/async/join.ts | 29 +-- @coven/iterables/async/map.ts | 29 +-- @coven/iterables/async/prepend.ts | 14 +- @coven/iterables/async/reduce.ts | 41 ++-- @coven/iterables/async/some.ts | 21 +- @coven/iterables/async/take.ts | 39 ++-- @coven/iterables/async/tests/count.test.ts | 6 +- @coven/iterables/async/tests/every.test.ts | 12 +- @coven/iterables/async/tests/flat.test.ts | 3 +- @coven/iterables/async/tests/forEach.test.ts | 9 +- .../iterables/async/tests/getIterator.test.ts | 3 +- @coven/iterables/async/tests/groupBy.test.ts | 6 +- @coven/iterables/async/tests/head.test.ts | 12 +- @coven/iterables/async/tests/initial.test.ts | 12 +- .../iterables/async/tests/intersperse.test.ts | 12 +- .../async/tests/iterableToArray.test.ts | 6 +- @coven/iterables/async/tests/join.test.ts | 6 +- @coven/iterables/async/tests/length.test.ts | 12 +- @coven/iterables/async/tests/some.test.ts | 18 +- .../iterables/async/tests/toIterable.test.ts | 9 +- @coven/iterables/async/tests/unique.test.ts | 6 +- @coven/iterables/async/tests/zip.test.ts | 3 +- @coven/iterables/async/tests/zipIndex.test.ts | 3 +- @coven/iterables/async/toIterable.ts | 25 ++- @coven/iterables/async/zip.ts | 43 ++-- @coven/iterables/drop.ts | 15 +- @coven/iterables/every.ts | 16 +- @coven/iterables/filter.ts | 15 +- @coven/iterables/find.ts | 10 +- @coven/iterables/flat.ts | 24 ++- @coven/iterables/forEach.ts | 3 +- @coven/iterables/groupBy.ts | 11 +- @coven/iterables/head.ts | 7 +- @coven/iterables/initial.ts | 41 ++-- @coven/iterables/intersperse.ts | 2 +- .../iteratorFunctionToIterableIterator.ts | 12 +- @coven/iterables/join.ts | 29 +-- @coven/iterables/map.ts | 13 +- @coven/iterables/prepend.ts | 14 +- @coven/iterables/random.ts | 30 ++- @coven/iterables/range.ts | 4 +- @coven/iterables/reduce.ts | 31 +-- @coven/iterables/repeat.ts | 24 +-- @coven/iterables/some.ts | 10 +- @coven/iterables/take.ts | 15 +- @coven/iterables/tests/count.test.ts | 6 +- @coven/iterables/tests/every.test.ts | 12 +- @coven/iterables/tests/flat.test.ts | 6 +- @coven/iterables/tests/forEach.test.ts | 9 +- @coven/iterables/tests/getIterator.test.ts | 3 +- @coven/iterables/tests/head.test.ts | 12 +- @coven/iterables/tests/includes.test.ts | 3 +- @coven/iterables/tests/initial.test.ts | 12 +- @coven/iterables/tests/intersperse.test.ts | 18 +- .../iterables/tests/iterableToArray.test.ts | 9 +- ...iteratorFunctionToIterableIterator.test.ts | 2 +- @coven/iterables/tests/join.test.ts | 15 +- @coven/iterables/tests/length.test.ts | 9 +- .../iterables/tests/objectToentries.test.ts | 6 +- @coven/iterables/tests/random.test.ts | 40 ++-- @coven/iterables/tests/reduce.test.ts | 3 +- @coven/iterables/tests/some.test.ts | 18 +- @coven/iterables/tests/take.test.ts | 3 +- @coven/iterables/tests/toIterable.test.ts | 15 +- @coven/iterables/tests/unique.test.ts | 6 +- @coven/iterables/tests/zip.test.ts | 3 +- @coven/iterables/tests/zipIndex.test.ts | 3 +- @coven/iterables/toIterable.ts | 21 +- @coven/iterables/zip.ts | 37 ++-- @coven/math/add.ts | 5 +- @coven/math/divide.ts | 5 +- @coven/math/pipe.ts | 4 +- @coven/math/precise.ts | 6 +- @coven/math/preciseDivide.ts | 12 +- @coven/math/preciseMultiply.ts | 8 +- @coven/math/tests/add.test.ts | 18 +- @coven/math/tests/calculate.test.ts | 15 +- @coven/math/tests/divide.test.ts | 33 ++- @coven/math/tests/multiply.test.ts | 42 ++-- @coven/math/tests/numberToPrecise.test.ts | 12 +- @coven/math/tests/precise.test.ts | 12 +- @coven/math/tests/preciseAdd.test.ts | 57 ++++-- @coven/math/tests/preciseDivide.test.ts | 60 ++++-- @coven/math/tests/preciseMultiply.test.ts | 63 ++++-- @coven/math/tests/preciseSubtract.test.ts | 60 ++++-- @coven/math/tests/preciseToNumber.test.ts | 3 +- @coven/math/tests/subtract.test.ts | 36 ++-- @coven/memo/MemoCacheValueIntersection.ts | 3 +- @coven/memo/memo.ts | 31 ++- @coven/memo/memoizedCacheReducer.ts | 22 +- @coven/memo/tests/memo.test.ts | 46 +++-- @coven/pair/README.md | 10 +- @coven/pair/preact/tests/preact.test.tsx | 5 +- @coven/pair/react/tests/react.test.tsx | 5 +- @coven/parsers/attempt.ts | 23 ++- @coven/parsers/parseInteger.ts | 2 +- @coven/parsers/parseJSON.ts | 7 +- @coven/parsers/tests/attempt.test.ts | 6 +- @coven/parsers/tests/clone.test.ts | 21 +- @coven/parsers/tests/parseBinary.test.ts | 9 +- @coven/parsers/tests/parseDecimal.test.ts | 9 +- .../parsers/tests/parseFloatingPoint.test.ts | 9 +- @coven/parsers/tests/parseHexadecimal.test.ts | 9 +- @coven/parsers/tests/parseInteger.test.ts | 12 +- @coven/parsers/tests/parseJSON.test.ts | 29 ++- @coven/parsers/tests/parseOctal.test.ts | 9 +- @coven/parsers/tests/undefineNaN.test.ts | 6 +- @coven/predicates/between.ts | 14 +- @coven/predicates/is.ts | 10 +- @coven/predicates/isInstanceOf.ts | 10 +- @coven/predicates/isPromise.ts | 5 +- @coven/predicates/isPropertyOf.ts | 10 +- @coven/predicates/isPrototypeOfObject.ts | 5 +- @coven/predicates/isRegExp.ts | 5 +- @coven/predicates/isType.ts | 6 +- @coven/predicates/test.ts | 2 +- @coven/predicates/tests/between.test.ts | 42 ++-- @coven/predicates/tests/has.test.ts | 36 ++-- .../tests/hasAsyncIteratorSymbol.test.ts | 6 +- .../tests/hasIteratorSymbol.test.ts | 6 +- @coven/predicates/tests/hasPrototype.test.ts | 9 +- @coven/predicates/tests/is.test.ts | 3 +- @coven/predicates/tests/isArray.test.ts | 3 +- .../predicates/tests/isAsyncIterable.test.ts | 6 +- .../tests/isAwaitableIterable.test.ts | 6 +- @coven/predicates/tests/isBigInt.test.ts | 6 +- @coven/predicates/tests/isBoolean.test.ts | 6 +- @coven/predicates/tests/isDate.test.ts | 3 +- @coven/predicates/tests/isFalsy.test.ts | 6 +- @coven/predicates/tests/isFunction.test.ts | 6 +- @coven/predicates/tests/isIterable.test.ts | 6 +- @coven/predicates/tests/isNull.test.ts | 3 +- @coven/predicates/tests/isNullish.test.ts | 6 +- @coven/predicates/tests/isNumber.test.ts | 6 +- @coven/predicates/tests/isObject.test.ts | 6 +- @coven/predicates/tests/isPromise.test.ts | 3 +- @coven/predicates/tests/isPropertyKey.test.ts | 6 +- @coven/predicates/tests/isPropertyOf.test.ts | 21 +- @coven/predicates/tests/isPrototypeOf.test.ts | 3 +- @coven/predicates/tests/isRegExp.test.ts | 6 +- @coven/predicates/tests/isString.test.ts | 6 +- @coven/predicates/tests/isSymbol.test.ts | 6 +- @coven/predicates/tests/isTruthy.test.ts | 6 +- @coven/predicates/tests/isUndefined.test.ts | 3 +- @coven/predicates/tests/test.test.ts | 9 +- @coven/terminal/format.ts | 7 +- @coven/terminal/mix.ts | 29 +-- @coven/terminal/tests/format.test.ts | 12 +- @coven/terminal/tests/mix.test.ts | 6 +- @coven/terminal/tests/normalizeString.test.ts | 6 +- @coven/types/AwaitableEffect.ts | 2 +- @coven/types/Branded.ts | 3 +- @coven/types/EntryOf.ts | 24 +-- @coven/types/Enumerate.ts | 4 +- @coven/types/Fallback.ts | 8 +- @coven/types/Head.ts | 5 +- @coven/types/HeadAndTail.ts | 17 +- @coven/types/ISODate.ts | 4 +- @coven/types/IndexArray.ts | 5 +- @coven/types/Initial.ts | 5 +- @coven/types/InitialAndLast.ts | 34 ++-- @coven/types/IsomorphicIteratorItem.ts | 4 +- @coven/types/IterableItem.ts | 4 +- @coven/types/IteratorItem.ts | 4 +- @coven/types/JSONValue.ts | 10 +- @coven/types/KeyOf.ts | 6 +- @coven/types/LanguageCode.ts | 118 +++++------ @coven/types/Last.ts | 5 +- @coven/types/MinimumLengthNumberString.ts | 11 +- @coven/types/Range.ts | 4 +- @coven/types/ReadonlyArrayLike.ts | 15 +- @coven/types/StringJoin.ts | 13 +- @coven/types/StructuredData.ts | 10 +- @coven/types/Tail.ts | 5 +- @coven/types/ValueOf.ts | 5 +- @coven/utils/always.ts | 5 +- @coven/utils/applyTo.ts | 10 +- @coven/utils/createObject.ts | 6 +- @coven/utils/get.ts | 14 +- @coven/utils/mutate.ts | 10 +- @coven/utils/seededRandom.ts | 11 +- @coven/utils/set.ts | 24 +-- @coven/utils/tap.ts | 16 +- @coven/utils/tests/always.test.ts | 3 +- @coven/utils/tests/applyTo.test.ts | 3 +- @coven/utils/tests/createObject.test.ts | 9 +- @coven/utils/tests/identity.test.ts | 6 +- @coven/utils/tests/set.test.ts | 3 +- @coven/utils/tests/tap.test.ts | 3 +- @coven/utils/tests/thunk.test.ts | 3 +- @coven/utils/thunk.ts | 10 +- @simulcast/core/BroadcastObject.ts | 15 +- @simulcast/core/emit.ts | 9 +- @simulcast/core/on.ts | 10 +- @simulcast/core/tests/broadcast.test.ts | 6 +- @simulcast/core/tests/emit.test.ts | 6 +- @simulcast/preact/README.md | 5 +- @simulcast/preact/UseBroadcastObject.ts | 6 +- @simulcast/preact/tests/useBroadcast.test.tsx | 44 ++-- @simulcast/react/README.md | 5 +- @simulcast/react/tests/useBroadcast.test.tsx | 44 ++-- @simulcast/vue/README.md | 7 +- @simulcast/vue/UseBroadcastObject.ts | 6 +- @simulcast/vue/tests/useBroadcast.test.ts | 5 +- @simulcast/vue/useBroadcastProxyHandler.ts | 2 +- CODE_OF_CONDUCT.md | 76 +++---- README.md | 16 +- deno.json | 5 +- lint/no.ts | 13 +- 320 files changed, 2311 insertions(+), 1842 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c3574ba..c07f7f6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -28,7 +28,7 @@ jobs: run: deno task lint-docs - name: Format - run: deno task format + run: deno task format-check - name: Test run: deno task test-coverage diff --git a/.zed/settings.json b/.zed/settings.json index d800c25..0ecd841 100644 --- a/.zed/settings.json +++ b/.zed/settings.json @@ -7,25 +7,25 @@ "deno", "!typescript-language-server", "!vtsls", - "!eslint", - ], + "!eslint" + ] }, "TSX": { "language_servers": [ "deno", "!typescript-language-server", "!vtsls", - "!eslint", - ], + "!eslint" + ] }, "TypeScript": { "language_servers": [ "deno", "!typescript-language-server", "!vtsls", - "!eslint", - ], - }, + "!eslint" + ] + } }, - "lsp": { "deno": { "settings": { "deno": { "enable": true } } } }, + "lsp": { "deno": { "settings": { "deno": { "enable": true } } } } } diff --git a/@coven/compare/FlatDifference.ts b/@coven/compare/FlatDifference.ts index 16ecb86..e256323 100644 --- a/@coven/compare/FlatDifference.ts +++ b/@coven/compare/FlatDifference.ts @@ -34,10 +34,9 @@ import type { UpdateDifference } from "./UpdateDifference.ts"; * @see {@linkcode FlatPath} * @see {@linkcode UpdateDifference} */ -export type FlatDifference = - & ( - | Omit - | Omit - | Omit - ) +export type FlatDifference = ( + | Omit + | Omit + | Omit +) & FlatPath; diff --git a/@coven/compare/compareIterables.ts b/@coven/compare/compareIterables.ts index 45e575f..64c1dd6 100644 --- a/@coven/compare/compareIterables.ts +++ b/@coven/compare/compareIterables.ts @@ -26,37 +26,38 @@ import { pathPrepend } from "./pathPrepend.ts"; * @param left Original iterable. * @returns Curried generator with `left` in context. */ -export const compareIterables = ( - left: Iterable, -): CurriedComparison> => -/** - * Curried {@linkcode compareIterables} with `left` set in context. - * - * @param right New iterable. - * @returns Generator with differences. - */ -(right) => - iteratorFunctionToIterableIterator(function* (): Generator { - const leftIterator = getIterator(left); - const rightIterator = getIterator(right); +export const compareIterables = + ( + left: Iterable, + ): CurriedComparison> => + /** + * Curried {@linkcode compareIterables} with `left` set in context. + * + * @param right New iterable. + * @returns Generator with differences. + */ + (right) => + iteratorFunctionToIterableIterator(function* (): Generator { + const leftIterator = getIterator(left); + const rightIterator = getIterator(right); - for ( - let index = 0, - { done: leftDone = false, value: leftValue } = leftIterator - .next(), - { done: rightDone = false, value: rightValue } = rightIterator - .next(); - !(leftDone && rightDone); - index += 1, - { done: leftDone = false, value: leftValue } = leftIterator - .next(), - { done: rightDone = false, value: rightValue } = rightIterator - .next() - ) { - yield* map(pathPrepend(index))( - compare(leftDone ? MISSING_VALUE : leftValue)( - rightDone ? MISSING_VALUE : rightValue, - ), - ); - } - }); + for ( + let index = 0, + { done: leftDone = false, value: leftValue } = + leftIterator.next(), + { done: rightDone = false, value: rightValue } = + rightIterator.next(); + !(leftDone && rightDone); + index += 1, + { done: leftDone = false, value: leftValue } = + leftIterator.next(), + { done: rightDone = false, value: rightValue } = + rightIterator.next() + ) { + yield* map(pathPrepend(index))( + compare(leftDone ? MISSING_VALUE : leftValue)( + rightDone ? MISSING_VALUE : rightValue, + ), + ); + } + }); diff --git a/@coven/compare/compareObjects.ts b/@coven/compare/compareObjects.ts index 6e9262e..66bb47e 100644 --- a/@coven/compare/compareObjects.ts +++ b/@coven/compare/compareObjects.ts @@ -29,20 +29,19 @@ export const compareObjects = (left: object): CurriedComparison => { const differentiateLeft = differentiate(left); const isLeftConstructor = is(left.constructor); - return leftIsIterator - /** - * Curried {@linkcode compareObjects} with `left` set in context. - * - * @param right New object. - * @returns Generator with differences. - */ - ? (right) => - isLeft(right) - ? EMPTY_ITERABLE_ITERATOR - : (isObject(right) && isLeftConstructor(right.constructor) - ? isIterable(right) - ? compareIterableLeft - : comparePropertiesLeft - : differentiateLeft)(right as Iterable) - : comparePropertiesLeft; + return leftIsIterator ? + /** + * Curried {@linkcode compareObjects} with `left` set in context. + * + * @param right New object. + * @returns Generator with differences. + */ + (right) => + isLeft(right) ? + EMPTY_ITERABLE_ITERATOR + : (isObject(right) && isLeftConstructor(right.constructor) ? + isIterable(right) ? compareIterableLeft + : comparePropertiesLeft + : differentiateLeft)(right as Iterable) + : comparePropertiesLeft; }; diff --git a/@coven/compare/compareProperties.ts b/@coven/compare/compareProperties.ts index c090b05..fede618 100644 --- a/@coven/compare/compareProperties.ts +++ b/@coven/compare/compareProperties.ts @@ -41,21 +41,22 @@ export const compareProperties = (left: object): CurriedComparison => { * @yields Differences. */ return (right) => - isLeft(right) ? EMPTY_ITERABLE_ITERATOR : isObject(right) - ? flat( + isLeft(right) ? EMPTY_ITERABLE_ITERATOR + : isObject(right) ? + flat( map((key: string | symbol) => map(pathPrepend(key))( compare( - key in left - ? left[key as keyof typeof left] - : MISSING_VALUE, + key in left ? + left[key as keyof typeof left] + : MISSING_VALUE, )( - key in right - ? right[key as keyof typeof right] - : MISSING_VALUE, + key in right ? + right[key as keyof typeof right] + : MISSING_VALUE, ), - ) + ), )(unique(append(getKeys(right))(ownKeysLeft))), ) - : differentiateLeft(right); + : differentiateLeft(right); }; diff --git a/@coven/compare/differentiate.ts b/@coven/compare/differentiate.ts index c233afc..4dd48c1 100644 --- a/@coven/compare/differentiate.ts +++ b/@coven/compare/differentiate.ts @@ -51,12 +51,12 @@ export const differentiate = (left: unknown): CurriedComparison => { * @returns Difference object. */ return (right) => - isLeft(right) ? EMPTY_ITERABLE_ITERATOR : toIterable({ - ...(right === MISSING_VALUE - ? { left, kind: DELETE_KIND } - : left === MISSING_VALUE - ? { kind: CREATE_KIND, right } + isLeft(right) ? + EMPTY_ITERABLE_ITERATOR + : toIterable({ + ...(right === MISSING_VALUE ? { left, kind: DELETE_KIND } + : left === MISSING_VALUE ? { kind: CREATE_KIND, right } : { left, kind: UPDATE_KIND, right }), - path: EMPTY_ITERABLE_ITERATOR, - }); + path: EMPTY_ITERABLE_ITERATOR, + }); }; diff --git a/@coven/compare/getKeys.ts b/@coven/compare/getKeys.ts index 76d35e6..0671e74 100644 --- a/@coven/compare/getKeys.ts +++ b/@coven/compare/getKeys.ts @@ -22,17 +22,17 @@ export const getKeys = (object: object): IterableIterator => > { yield* Reflect.ownKeys(object); - hasPrototype(object) - ? yield* Reflect.ownKeys(object.prototype) - : undefined; + hasPrototype(object) ? + yield* Reflect.ownKeys(object.prototype) + : undefined; const constructor = object.constructor; ( - isObjectConstructor(constructor) - || isFunctionConstructor(constructor) - ) - ? undefined - : yield* getKeys(constructor); + isObjectConstructor(constructor) + || isFunctionConstructor(constructor) + ) ? + undefined + : yield* getKeys(constructor); }), ); diff --git a/@coven/compare/pathPrepend.ts b/@coven/compare/pathPrepend.ts index a8966f6..5da0121 100644 --- a/@coven/compare/pathPrepend.ts +++ b/@coven/compare/pathPrepend.ts @@ -18,7 +18,7 @@ import { setPath } from "./setPath.ts"; */ export const pathPrepend = ( property: PropertyKey, -): (difference: Difference) => Difference => { +): ((difference: Difference) => Difference) => { const prependProperty = prepend([property]); /** diff --git a/@coven/compare/tests/compare.test.ts b/@coven/compare/tests/compare.test.ts index ad28c86..a609a69 100644 --- a/@coven/compare/tests/compare.test.ts +++ b/@coven/compare/tests/compare.test.ts @@ -14,10 +14,12 @@ const property1 = "property1"; const property2 = "property2"; Deno.test("Comparing same string yields nothing", () => - assertEquals(flat(compare("magic")("magic")), EMPTY_ARRAY)); + assertEquals(flat(compare("magic")("magic")), EMPTY_ARRAY), +); Deno.test("Comparing same object yields nothing", () => - assertEquals(flat(compare(EMPTY_OBJECT)(EMPTY_OBJECT)), EMPTY_ARRAY)); + assertEquals(flat(compare(EMPTY_OBJECT)(EMPTY_OBJECT)), EMPTY_ARRAY), +); Deno.test("Comparing different string yields `UpdateDifference`", () => assertEquals(flat(compare("magic")("cat")), [ @@ -27,10 +29,12 @@ Deno.test("Comparing different string yields `UpdateDifference`", () => path: [], right: "cat", }, - ])); + ]), +); Deno.test("Comparing equal arrays yields nothing", () => - assertEquals(flat(compare(["magic"])(["magic"])), EMPTY_ARRAY)); + assertEquals(flat(compare(["magic"])(["magic"])), EMPTY_ARRAY), +); Deno.test("Comparing different arrays yields `UpdateDifference`", () => assertEquals(flat(compare(["magic"])(["cat"])), [ @@ -40,13 +44,15 @@ Deno.test("Comparing different arrays yields `UpdateDifference`", () => path: [0], right: "cat", }, - ])); + ]), +); Deno.test("Comparing equal objects yields nothing", () => assertEquals( flat(compare({ [property1]: "magic" })({ [property1]: "magic" })), EMPTY_ARRAY, - )); + ), +); Deno.test( "Comparing objects with different property values yields `UpdateDifference`", @@ -85,7 +91,8 @@ Deno.test("Comparing array with new items yields `CreateDifference`", () => ]), ), [{ kind: CREATE_KIND, path: [1], right: { [property2]: "cat" } }], - )); + ), +); Deno.test("Comparing array with less items yields `DeleteDifference`", () => assertEquals( @@ -101,13 +108,16 @@ Deno.test("Comparing array with less items yields `DeleteDifference`", () => path: [1], }, ], - )); + ), +); Deno.test("Comparing equal Date objects yields nothing", () => - assertEquals(flat(compare(new Date(0))(new Date(0))), EMPTY_ARRAY)); + assertEquals(flat(compare(new Date(0))(new Date(0))), EMPTY_ARRAY), +); Deno.test("Comparing equal RegExp objects yields nothing", () => - assertEquals(flat(compare(/coven/gu)(/coven/gu)), EMPTY_ARRAY)); + assertEquals(flat(compare(/coven/gu)(/coven/gu)), EMPTY_ARRAY), +); Deno.test("Comparing equal URL objects yields nothing", () => assertEquals( @@ -117,7 +127,8 @@ Deno.test("Comparing equal URL objects yields nothing", () => ), ), EMPTY_ARRAY, - )); + ), +); Deno.test("Comparing equal `Error` objects yields nothing", () => assertEquals( @@ -127,7 +138,8 @@ Deno.test("Comparing equal `Error` objects yields nothing", () => ), ), EMPTY_ARRAY, - )); + ), +); Deno.test("Comparing equal `Map` objects yields nothing", () => assertEquals( @@ -137,13 +149,15 @@ Deno.test("Comparing equal `Map` objects yields nothing", () => ), ), EMPTY_ARRAY, - )); + ), +); Deno.test("Comparing equal `Set` objects yields nothing", () => assertEquals( flat(compare(new Set(["magic"]))(new Set(["magic"]))), EMPTY_ARRAY, - )); + ), +); Deno.test( "Comparing left `null` and right object yields `UpdateDifference`", @@ -247,13 +261,15 @@ Deno.test("Comparing 0 with -0 should yield `UpdateDifference`", () => path: [], right: 0, }, - ])); + ]), +); Deno.test("Comparing iterator to itself", () => assertEquals( flat(compare(EMPTY_ITERABLE_ITERATOR)(EMPTY_ITERABLE_ITERATOR)), [], - )); + ), +); Deno.test("Comparing iterator to plain object", () => assertEquals(flat(compare(EMPTY_ITERABLE_ITERATOR)(EMPTY_OBJECT)), [ @@ -263,4 +279,5 @@ Deno.test("Comparing iterator to plain object", () => path: [], right: EMPTY_OBJECT, }, - ])); + ]), +); diff --git a/@coven/compare/tests/pathPrepend.test.ts b/@coven/compare/tests/pathPrepend.test.ts index b56474e..0f682ce 100644 --- a/@coven/compare/tests/pathPrepend.test.ts +++ b/@coven/compare/tests/pathPrepend.test.ts @@ -15,7 +15,8 @@ Deno.test("Prepend key to existing path", () => }), ]), [{ kind: DELETE_KIND, left: "✨", path: [13, 42] }], - )); + ), +); Deno.test("Prepend key to missing path yields prepended key", () => assertEquals( @@ -33,4 +34,5 @@ Deno.test("Prepend key to missing path yields prepended key", () => path: [13], }, ], - )); + ), +); diff --git a/@coven/compare/tests/valueToDifference.test.ts b/@coven/compare/tests/valueToDifference.test.ts index bb3c4f0..04f5a6a 100644 --- a/@coven/compare/tests/valueToDifference.test.ts +++ b/@coven/compare/tests/valueToDifference.test.ts @@ -6,4 +6,5 @@ Deno.test("When both values are missing returns an empty difference", () => assertEquals( flat(differentiate(MISSING_VALUE)(MISSING_VALUE)), EMPTY_ARRAY, - )); + ), +); diff --git a/@coven/constants/tests/EMPTY_ARRAY.test.ts b/@coven/constants/tests/EMPTY_ARRAY.test.ts index ffe2985..4699073 100644 --- a/@coven/constants/tests/EMPTY_ARRAY.test.ts +++ b/@coven/constants/tests/EMPTY_ARRAY.test.ts @@ -5,7 +5,7 @@ Deno.test( "`Array#pop` should throw", () => void assertThrows(() => - (EMPTY_ARRAY as unknown as Array).pop() + (EMPTY_ARRAY as unknown as Array).pop(), ), ); @@ -13,7 +13,7 @@ Deno.test( "`Array#push` should throw", () => void assertThrows(() => - (EMPTY_ARRAY as unknown as Array).push("💀") + (EMPTY_ARRAY as unknown as Array).push("💀"), ), ); @@ -21,7 +21,7 @@ Deno.test( "`Array#shift` should throw", () => void assertThrows(() => - (EMPTY_ARRAY as unknown as Array).shift() + (EMPTY_ARRAY as unknown as Array).shift(), ), ); @@ -29,7 +29,7 @@ Deno.test( "`Array#splice` should throw", () => void assertThrows(() => - (EMPTY_ARRAY as unknown as Array).splice(0) + (EMPTY_ARRAY as unknown as Array).splice(0), ), ); @@ -37,7 +37,7 @@ Deno.test( "`Array#unshift` should throw", () => void assertThrows(() => - (EMPTY_ARRAY as unknown as Array).unshift() + (EMPTY_ARRAY as unknown as Array).unshift(), ), ); @@ -53,6 +53,6 @@ Deno.test( "Using `Object.defineProperty` should throw", () => void assertThrows(() => - Object.defineProperty(EMPTY_ARRAY, "test", { value: "💀" }) + Object.defineProperty(EMPTY_ARRAY, "test", { value: "💀" }), ), ); diff --git a/@coven/constants/tests/EMPTY_OBJECT.test.ts b/@coven/constants/tests/EMPTY_OBJECT.test.ts index bcd99f4..a1a8711 100644 --- a/@coven/constants/tests/EMPTY_OBJECT.test.ts +++ b/@coven/constants/tests/EMPTY_OBJECT.test.ts @@ -13,6 +13,6 @@ Deno.test( "Using `defineProperty` should throw", () => void assertThrows(() => - Object.defineProperty(EMPTY_OBJECT, "test", { value: "💀" }) + Object.defineProperty(EMPTY_OBJECT, "test", { value: "💀" }), ), ); diff --git a/@coven/cron/compareField.ts b/@coven/cron/compareField.ts index 3443a11..70cafb7 100644 --- a/@coven/cron/compareField.ts +++ b/@coven/cron/compareField.ts @@ -26,7 +26,7 @@ export const compareField: ( value: number, field: Exclude, AllToken>, ) => boolean = memo((value: number, field: Exclude, AllToken>) => - isListField(field) - ? field.some(compareRangeOrValue(value)) - : compareRangeOrValue(value)(field) + isListField(field) ? + field.some(compareRangeOrValue(value)) + : compareRangeOrValue(value)(field), ); diff --git a/@coven/cron/compareRangeOrValue.ts b/@coven/cron/compareRangeOrValue.ts index 8cc814b..ce0ebbe 100644 --- a/@coven/cron/compareRangeOrValue.ts +++ b/@coven/cron/compareRangeOrValue.ts @@ -18,10 +18,10 @@ import { isRangeField } from "./isRangeField.ts"; export const compareRangeOrValue: ( value: number, ) => (valueOrRange: ValueOrRangeField) => boolean = memo( - (value: number): (valueOrRange: ValueOrRangeField) => boolean => + (value: number): ((valueOrRange: ValueOrRangeField) => boolean) => memo((valueOrRange) => - isRangeField(valueOrRange) - ? value >= valueOrRange.from && value <= valueOrRange.to - : value === valueOrRange + isRangeField(valueOrRange) ? + value >= valueOrRange.from && value <= valueOrRange.to + : value === valueOrRange, ), ); diff --git a/@coven/cron/cronRegExp.ts b/@coven/cron/cronRegExp.ts index 85c8795..2a31e30 100644 --- a/@coven/cron/cronRegExp.ts +++ b/@coven/cron/cronRegExp.ts @@ -46,117 +46,112 @@ import { valueRangeOrListRegExp } from "./valueRangeOrListRegExp.ts"; * new RegExp(cronRegExp).test("1 2 3 4 5"); // true * ``` */ -export const cronRegExp: - "^\\s*(?!(?:\\S+\\s+){2}(?:(?:(?:3[01](?:-3[01])?|(?:(?:3[01](?:-3[01])?,)+3[01](?:-3[01])?))\\s+(?:(?:0?2|feb)(?:-(?:0?2|feb))?|(?:(?:(?:0?2|feb)(?:-(?:0?2|feb))?,)+(?:0?2|feb)(?:-(?:0?2|feb))?)))|(?:(?:31(?:-31)?|(?:(?:31(?:-31)?,)+31(?:-31)?))\\s+(?:(?:0?[2469]|11|feb|apr|jun|sep|nov)|(?:(?:(?:0?[2469]|11|feb|apr|jun|sep|nov),)+(?:0?[2469]|11|feb|apr|jun|sep|nov)))))\\s+\\S+)(?\\*|(?:(?:0?\\d|[1-5]\\d)(?:-(?:0?\\d|[1-5]\\d))?|(?:(?:(?:0?\\d|[1-5]\\d)(?:-(?:0?\\d|[1-5]\\d))?,)+(?:0?\\d|[1-5]\\d)(?:-(?:0?\\d|[1-5]\\d))?)))\\s+(?\\*|(?:(?:0?\\d|1\\d|20-3)(?:-(?:0?\\d|1\\d|20-3))?|(?:(?:(?:0?\\d|1\\d|20-3)(?:-(?:0?\\d|1\\d|20-3))?,)+(?:0?\\d|1\\d|20-3)(?:-(?:0?\\d|1\\d|20-3))?)))\\s+(?\\*|(?:(?:0?[1-9]|[12]\\d|3[01])(?:-(?:0?[1-9]|[12]\\d|3[01]))?|(?:(?:(?:0?[1-9]|[12]\\d|3[01])(?:-(?:0?[1-9]|[12]\\d|3[01]))?,)+(?:0?[1-9]|[12]\\d|3[01])(?:-(?:0?[1-9]|[12]\\d|3[01]))?)))\\s+(?\\*|(?:(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|0?[1-9]|1[0-2])(?:-(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|0?[1-9]|1[0-2]))?|(?:(?:(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|0?[1-9]|1[0-2])(?:-(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|0?[1-9]|1[0-2]))?,)+(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|0?[1-9]|1[0-2])(?:-(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|0?[1-9]|1[0-2]))?)))\\s+(?\\*|(?:(?:sun|mon|tue|wed|thu|fri|sat|0?[0-6])(?:-(?:sun|mon|tue|wed|thu|fri|sat|0?[0-6]))?|(?:(?:(?:sun|mon|tue|wed|thu|fri|sat|0?[0-6])(?:-(?:sun|mon|tue|wed|thu|fri|sat|0?[0-6]))?,)+(?:sun|mon|tue|wed|thu|fri|sat|0?[0-6])(?:-(?:sun|mon|tue|wed|thu|fri|sat|0?[0-6]))?)))\\s*$" = - join( - START, - allow(WHITESPACE), - negativeLookahead( - quantity(2)(group(exists(NON_WHITESPACE), exists(WHITESPACE))), - group( - disjunction( - group( - valueRangeOrListRegExp( - join(3, characterClass(0, 1)), - ), - exists(WHITESPACE), - valueRangeOrListRegExp( - group(disjunction(paddedRegExp(2), "feb")), - ), +export const cronRegExp: "^\\s*(?!(?:\\S+\\s+){2}(?:(?:(?:3[01](?:-3[01])?|(?:(?:3[01](?:-3[01])?,)+3[01](?:-3[01])?))\\s+(?:(?:0?2|feb)(?:-(?:0?2|feb))?|(?:(?:(?:0?2|feb)(?:-(?:0?2|feb))?,)+(?:0?2|feb)(?:-(?:0?2|feb))?)))|(?:(?:31(?:-31)?|(?:(?:31(?:-31)?,)+31(?:-31)?))\\s+(?:(?:0?[2469]|11|feb|apr|jun|sep|nov)|(?:(?:(?:0?[2469]|11|feb|apr|jun|sep|nov),)+(?:0?[2469]|11|feb|apr|jun|sep|nov)))))\\s+\\S+)(?\\*|(?:(?:0?\\d|[1-5]\\d)(?:-(?:0?\\d|[1-5]\\d))?|(?:(?:(?:0?\\d|[1-5]\\d)(?:-(?:0?\\d|[1-5]\\d))?,)+(?:0?\\d|[1-5]\\d)(?:-(?:0?\\d|[1-5]\\d))?)))\\s+(?\\*|(?:(?:0?\\d|1\\d|20-3)(?:-(?:0?\\d|1\\d|20-3))?|(?:(?:(?:0?\\d|1\\d|20-3)(?:-(?:0?\\d|1\\d|20-3))?,)+(?:0?\\d|1\\d|20-3)(?:-(?:0?\\d|1\\d|20-3))?)))\\s+(?\\*|(?:(?:0?[1-9]|[12]\\d|3[01])(?:-(?:0?[1-9]|[12]\\d|3[01]))?|(?:(?:(?:0?[1-9]|[12]\\d|3[01])(?:-(?:0?[1-9]|[12]\\d|3[01]))?,)+(?:0?[1-9]|[12]\\d|3[01])(?:-(?:0?[1-9]|[12]\\d|3[01]))?)))\\s+(?\\*|(?:(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|0?[1-9]|1[0-2])(?:-(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|0?[1-9]|1[0-2]))?|(?:(?:(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|0?[1-9]|1[0-2])(?:-(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|0?[1-9]|1[0-2]))?,)+(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|0?[1-9]|1[0-2])(?:-(?:jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec|0?[1-9]|1[0-2]))?)))\\s+(?\\*|(?:(?:sun|mon|tue|wed|thu|fri|sat|0?[0-6])(?:-(?:sun|mon|tue|wed|thu|fri|sat|0?[0-6]))?|(?:(?:(?:sun|mon|tue|wed|thu|fri|sat|0?[0-6])(?:-(?:sun|mon|tue|wed|thu|fri|sat|0?[0-6]))?,)+(?:sun|mon|tue|wed|thu|fri|sat|0?[0-6])(?:-(?:sun|mon|tue|wed|thu|fri|sat|0?[0-6]))?)))\\s*$" = + join( + START, + allow(WHITESPACE), + negativeLookahead( + quantity(2)(group(exists(NON_WHITESPACE), exists(WHITESPACE))), + group( + disjunction( + group( + valueRangeOrListRegExp(join(3, characterClass(0, 1))), + exists(WHITESPACE), + valueRangeOrListRegExp( + group(disjunction(paddedRegExp(2), "feb")), ), - group( - valueRangeOrListRegExp(31), - exists(WHITESPACE), - valueOrListRegExp( - group( - disjunction( - paddedRegExp( - characterClass(2, 4, 6, 9), - ), - 11, - "feb", - "apr", - "jun", - "sep", - "nov", - ), + ), + group( + valueRangeOrListRegExp(31), + exists(WHITESPACE), + valueOrListRegExp( + group( + disjunction( + paddedRegExp(characterClass(2, 4, 6, 9)), + 11, + "feb", + "apr", + "jun", + "sep", + "nov", ), ), ), ), ), - exists(WHITESPACE), - exists(NON_WHITESPACE), ), - fieldRegExp( - "minute", - group( - disjunction( - paddedRegExp(DIGIT), - join(characterClass(range(1)(5)), DIGIT), - ), + exists(WHITESPACE), + exists(NON_WHITESPACE), + ), + fieldRegExp( + "minute", + group( + disjunction( + paddedRegExp(DIGIT), + join(characterClass(range(1)(5)), DIGIT), ), ), - exists(WHITESPACE), - fieldRegExp( - "hour", - group( - disjunction( - paddedRegExp(DIGIT), - join(1, DIGIT), - join(2, range(0)(3)), - ), + ), + exists(WHITESPACE), + fieldRegExp( + "hour", + group( + disjunction( + paddedRegExp(DIGIT), + join(1, DIGIT), + join(2, range(0)(3)), ), ), - exists(WHITESPACE), - fieldRegExp( - "dayOfMonth", - group( - disjunction( - paddedRegExp(characterClass(range(1)(9))), - join(characterClass(1, 2), DIGIT), - join(3, characterClass(0, 1)), - ), + ), + exists(WHITESPACE), + fieldRegExp( + "dayOfMonth", + group( + disjunction( + paddedRegExp(characterClass(range(1)(9))), + join(characterClass(1, 2), DIGIT), + join(3, characterClass(0, 1)), ), ), - exists(WHITESPACE), - fieldRegExp( - "month", - group( - disjunction( - "jan", - "feb", - "mar", - "apr", - "may", - "jun", - "jul", - "aug", - "sep", - "oct", - "nov", - "dec", - paddedRegExp(characterClass(range(1)(9))), - join(1, characterClass(range(0)(2))), - ), + ), + exists(WHITESPACE), + fieldRegExp( + "month", + group( + disjunction( + "jan", + "feb", + "mar", + "apr", + "may", + "jun", + "jul", + "aug", + "sep", + "oct", + "nov", + "dec", + paddedRegExp(characterClass(range(1)(9))), + join(1, characterClass(range(0)(2))), ), ), - exists(WHITESPACE), - fieldRegExp( - "dayOfWeek", - group( - disjunction( - "sun", - "mon", - "tue", - "wed", - "thu", - "fri", - "sat", - paddedRegExp(characterClass(range(0)(6))), - ), + ), + exists(WHITESPACE), + fieldRegExp( + "dayOfWeek", + group( + disjunction( + "sun", + "mon", + "tue", + "wed", + "thu", + "fri", + "sat", + paddedRegExp(characterClass(range(0)(6))), ), ), - allow(WHITESPACE), - END, - ); + ), + allow(WHITESPACE), + END, + ); diff --git a/@coven/cron/fieldRegExp.ts b/@coven/cron/fieldRegExp.ts index 93ed29b..2960f2e 100644 --- a/@coven/cron/fieldRegExp.ts +++ b/@coven/cron/fieldRegExp.ts @@ -17,13 +17,10 @@ import { valueRangeOrListRegExp } from "./valueRangeOrListRegExp.ts"; export const fieldRegExp: ( name: Name, value: Value, -) => - `(?<${Name}>\\*|(?:${Value}(?:-${Value})?|(?:(?:${Value}(?:-${Value})?,)+${Value}(?:-${Value})?)))` = - memo( - ( - name: Name, - value: Value, - ) => captureNamed(name)( +) => `(?<${Name}>\\*|(?:${Value}(?:-${Value})?|(?:(?:${Value}(?:-${Value})?,)+${Value}(?:-${Value})?)))` = + memo( + (name: Name, value: Value) => + captureNamed(name)( disjunction(escape(ALL_TOKEN), valueRangeOrListRegExp(value)), ), - ); + ); diff --git a/@coven/cron/isAllToken.ts b/@coven/cron/isAllToken.ts index c3c4066..35a4bcf 100644 --- a/@coven/cron/isAllToken.ts +++ b/@coven/cron/isAllToken.ts @@ -5,6 +5,5 @@ import { ALL_TOKEN } from "./tokens.ts"; /** * Predicate to check if the given value is `"*"`. */ -export const isAllToken: (actual: unknown) => actual is AllToken = is( - ALL_TOKEN, -); +export const isAllToken: (actual: unknown) => actual is AllToken = + is(ALL_TOKEN); diff --git a/@coven/cron/nextISODates.ts b/@coven/cron/nextISODates.ts index 41744bf..754f198 100644 --- a/@coven/cron/nextISODates.ts +++ b/@coven/cron/nextISODates.ts @@ -48,7 +48,7 @@ export const nextISODates: ( } else { const validDate = timestampInCron(cronObject); const mapValidDate = map((minute: number) => - validDate(initialTimestamp + minute) + validDate(initialTimestamp + minute), ); return filterIsISODate(mapValidDate(minuteRange)); diff --git a/@coven/cron/normalizeMap.ts b/@coven/cron/normalizeMap.ts index f9a61a5..ca588a2 100644 --- a/@coven/cron/normalizeMap.ts +++ b/@coven/cron/normalizeMap.ts @@ -28,29 +28,27 @@ export const normalizeMap: Memoized< /** November number representation */ nov: 11; /** December number representation */ dec: 12; }> -> = memo( - { - /* Days of the week */ - /** Sunday number representation */ sun: 0, - /** Monday number representation */ mon: 1, - /** Tuesday number representation */ tue: 2, - /** Wednesday number representation */ wed: 3, - /** Thursday number representation */ thu: 4, - /** Friday number representation */ fri: 5, - /** Saturday number representation */ sat: 6, +> = memo({ + /* Days of the week */ + /** Sunday number representation */ sun: 0, + /** Monday number representation */ mon: 1, + /** Tuesday number representation */ tue: 2, + /** Wednesday number representation */ wed: 3, + /** Thursday number representation */ thu: 4, + /** Friday number representation */ fri: 5, + /** Saturday number representation */ sat: 6, - /* Months */ - /** January number representation */ jan: 1, - /** February number representation */ feb: 2, - /** March number representation */ mar: 3, - /** April number representation */ apr: 4, - /** May number representation */ may: 5, - /** June number representation */ jun: 6, - /** July number representation */ jul: 7, - /** August number representation */ aug: 8, - /** September number representation */ sep: 9, - /** October number representation */ oct: 10, - /** November number representation */ nov: 11, - /** December number representation */ dec: 12, - } as const, -); + /* Months */ + /** January number representation */ jan: 1, + /** February number representation */ feb: 2, + /** March number representation */ mar: 3, + /** April number representation */ apr: 4, + /** May number representation */ may: 5, + /** June number representation */ jun: 6, + /** July number representation */ jul: 7, + /** August number representation */ aug: 8, + /** September number representation */ sep: 9, + /** October number representation */ oct: 10, + /** November number representation */ nov: 11, + /** December number representation */ dec: 12, +} as const); diff --git a/@coven/cron/paddedRegExp.ts b/@coven/cron/paddedRegExp.ts index 1368cc3..84826f3 100644 --- a/@coven/cron/paddedRegExp.ts +++ b/@coven/cron/paddedRegExp.ts @@ -14,5 +14,5 @@ import { memo } from "@coven/memo"; export const paddedRegExp: ( value: Value, ) => `0?${Value}` = memo((value: Value) => - join(optional(0), value) + join(optional(0), value), ); diff --git a/@coven/cron/parse.ts b/@coven/cron/parse.ts index d594dc9..f5cb366 100644 --- a/@coven/cron/parse.ts +++ b/@coven/cron/parse.ts @@ -33,18 +33,17 @@ export const parse: (expression: CronString) => Maybe = memo( (expression: CronString) => { const entries = parseFieldTuplesMap( objectToEntries( - (buildIU(cronRegExp).exec(normalizeAliases(expression)) - ?.groups ?? EMPTY_OBJECT) as ReadonlyRecord< - KeyOf, - string - >, + (buildIU(cronRegExp).exec(normalizeAliases(expression))?.groups + ?? EMPTY_OBJECT) as ReadonlyRecord< + KeyOf, + string + >, ), ); return ( length(entries) === 0 ? undefined : ( entriesToObject(entries) - ) - ) as Maybe; + )) as Maybe; }, ); diff --git a/@coven/cron/parseField.ts b/@coven/cron/parseField.ts index 33e5d2d..0eeabe0 100644 --- a/@coven/cron/parseField.ts +++ b/@coven/cron/parseField.ts @@ -30,6 +30,6 @@ export const parseField: ( ) => AllToken | Maybe | RangeField | ListField = memo( (field: string) => isAllToken(field) ? field : ( - parseList(field) ?? parseRange(field) ?? parseDecimal(field) + (parseList(field) ?? parseRange(field) ?? parseDecimal(field)) ), ); diff --git a/@coven/cron/parseList.ts b/@coven/cron/parseList.ts index e68a8bb..e403b25 100644 --- a/@coven/cron/parseList.ts +++ b/@coven/cron/parseList.ts @@ -22,11 +22,11 @@ export const parseList: ( value: string, ) => Maybe> = memo( (value: string) => - (isListString(value) - ? iterableToArray( + (isListString(value) ? + iterableToArray( unique( parseListMap(value.split(LIST_EXPRESSION_SEPARATOR_TOKEN)), ), ) - : undefined) as Maybe>, + : undefined) as Maybe>, ); diff --git a/@coven/cron/parseNumber.ts b/@coven/cron/parseNumber.ts index f34d8c2..2dbb517 100644 --- a/@coven/cron/parseNumber.ts +++ b/@coven/cron/parseNumber.ts @@ -20,7 +20,7 @@ import { parseNumberTest } from "./parseNumberTest.ts"; */ export const parseNumber: (value: string) => Maybe = memo( (value: string) => - (parseNumberTest(value) ? parseDecimal(value) : undefined) as Maybe< - number - >, + (parseNumberTest(value) ? + parseDecimal(value) + : undefined) as Maybe, ); diff --git a/@coven/cron/parseRange.ts b/@coven/cron/parseRange.ts index e78b26f..bb3ebba 100644 --- a/@coven/cron/parseRange.ts +++ b/@coven/cron/parseRange.ts @@ -27,18 +27,20 @@ export const parseRange: ( value: string, ) => Maybe> = memo( (value: string) => { - const maybeRange = isRangeString(value) - ? entriesToObject( - zipRangeNames( - parseNumberMap( - value.split(RANGE_EXPRESSION_SEPARATOR_TOKEN), + const maybeRange = + isRangeString(value) ? + entriesToObject( + zipRangeNames( + parseNumberMap( + value.split(RANGE_EXPRESSION_SEPARATOR_TOKEN), + ), ), - ), - ) - : undefined; + ) + : undefined; return ( - maybeRange?.from === maybeRange?.to ? maybeRange?.from : maybeRange - ) as Maybe>; + maybeRange?.from === maybeRange?.to ? + maybeRange?.from + : maybeRange) as Maybe>; }, ); diff --git a/@coven/cron/stringifyField.ts b/@coven/cron/stringifyField.ts index 4ee9f87..889c502 100644 --- a/@coven/cron/stringifyField.ts +++ b/@coven/cron/stringifyField.ts @@ -25,8 +25,8 @@ import { stringifyRange } from "./stringifyRange.ts"; export const stringifyField: (field: Field) => FieldString = memo( (field: Field): FieldString => isAllToken(field) ? field : ( - (stringifyList(field) + ((stringifyList(field) ?? stringifyRange(field) - ?? `${field as number}`) as FieldString + ?? `${field as number}`) as FieldString) ), ); diff --git a/@coven/cron/stringifyList.ts b/@coven/cron/stringifyList.ts index 7003d09..13ae7c0 100644 --- a/@coven/cron/stringifyList.ts +++ b/@coven/cron/stringifyList.ts @@ -23,9 +23,9 @@ export const stringifyList: ( field: Readonly>, ) => Maybe = memo( (field: Readonly>) => - (isListField(field) - ? field + (isListField(field) ? + field .map((item) => stringifyRange(item) ?? `${item as number}`) .join(LIST_EXPRESSION_SEPARATOR_TOKEN) - : undefined) as Maybe, + : undefined) as Maybe, ); diff --git a/@coven/cron/stringifyRange.ts b/@coven/cron/stringifyRange.ts index bae8bfa..059cfad 100644 --- a/@coven/cron/stringifyRange.ts +++ b/@coven/cron/stringifyRange.ts @@ -21,7 +21,7 @@ export const stringifyRange: ( field: Readonly>, ) => Maybe = memo( (field: Readonly>) => - (isRangeField(field) - ? `${field.from}${RANGE_EXPRESSION_SEPARATOR_TOKEN}${field.to}` - : undefined) as Maybe, + (isRangeField(field) ? + `${field.from}${RANGE_EXPRESSION_SEPARATOR_TOKEN}${field.to}` + : undefined) as Maybe, ); diff --git a/@coven/cron/tests/compareField.test.ts b/@coven/cron/tests/compareField.test.ts index a1098a0..30150ee 100644 --- a/@coven/cron/tests/compareField.test.ts +++ b/@coven/cron/tests/compareField.test.ts @@ -4,22 +4,28 @@ import { assert, assertFalse } from "@std/assert"; Deno.test("Two equal values returns true", () => assert(compareField(13, 13))); Deno.test("Two different values returns false", () => - assertFalse(compareField(13, 99))); + assertFalse(compareField(13, 99)), +); Deno.test("Value and a range that contains it returns true", () => - assert(compareField(13, { from: 0, to: 99 }))); + assert(compareField(13, { from: 0, to: 99 })), +); Deno.test("Value and a range that doesn't contain it returns true", () => - assertFalse(compareField(13, { from: 0, to: 10 }))); + assertFalse(compareField(13, { from: 0, to: 10 })), +); Deno.test("Value and a list that contains it returns true", () => - assert(compareField(13, [10, 13]))); + assert(compareField(13, [10, 13])), +); Deno.test("Value and a list that doesn't contain it returns true", () => - assertFalse(compareField(13, [10, 12]))); + assertFalse(compareField(13, [10, 12])), +); Deno.test("Value and a list with a range that contains it returns true", () => - assert(compareField(13, [10, { from: 11, to: 99 }]))); + assert(compareField(13, [10, { from: 11, to: 99 }])), +); Deno.test( "Value and a list with a range that doesn't contain it returns true", diff --git a/@coven/cron/tests/compareRangeOrValue.test.ts b/@coven/cron/tests/compareRangeOrValue.test.ts index 3799d02..66f7493 100644 --- a/@coven/cron/tests/compareRangeOrValue.test.ts +++ b/@coven/cron/tests/compareRangeOrValue.test.ts @@ -2,13 +2,17 @@ import { compareRangeOrValue } from "@coven/cron"; import { assert, assertFalse } from "@std/assert"; Deno.test("Two equal values returns true", () => - assert(compareRangeOrValue(13)(13))); + assert(compareRangeOrValue(13)(13)), +); Deno.test("Two different values returns false", () => - assertFalse(compareRangeOrValue(13)(99))); + assertFalse(compareRangeOrValue(13)(99)), +); Deno.test("Value and a range that contains it returns true", () => - assert(compareRangeOrValue(13)({ from: 0, to: 99 }))); + assert(compareRangeOrValue(13)({ from: 0, to: 99 })), +); Deno.test("Value and a range that doesn't contain it returns false", () => - assertFalse(compareRangeOrValue(13)({ from: 0, to: 10 }))); + assertFalse(compareRangeOrValue(13)({ from: 0, to: 10 })), +); diff --git a/@coven/cron/tests/fieldRegExp.test.ts b/@coven/cron/tests/fieldRegExp.test.ts index f0fac4e..447be02 100644 --- a/@coven/cron/tests/fieldRegExp.test.ts +++ b/@coven/cron/tests/fieldRegExp.test.ts @@ -6,7 +6,6 @@ Deno.test( () => assertStrictEquals( fieldRegExp("test", "13"), - String - .raw`(?\*|(?:13(?:-13)?|(?:(?:13(?:-13)?,)+13(?:-13)?)))`, + String.raw`(?\*|(?:13(?:-13)?|(?:(?:13(?:-13)?,)+13(?:-13)?)))`, ), ); diff --git a/@coven/cron/tests/isAllToken.test.ts b/@coven/cron/tests/isAllToken.test.ts index 4376a0c..b4f0eed 100644 --- a/@coven/cron/tests/isAllToken.test.ts +++ b/@coven/cron/tests/isAllToken.test.ts @@ -4,4 +4,5 @@ import { assert, assertFalse } from "@std/assert"; Deno.test("String that is a * returns true", () => assert(isAllToken("*"))); Deno.test("String that isn't a * returns false", () => - assertFalse(isAllToken("nope"))); + assertFalse(isAllToken("nope")), +); diff --git a/@coven/cron/tests/isListField.test.ts b/@coven/cron/tests/isListField.test.ts index 32638fe..f979e69 100644 --- a/@coven/cron/tests/isListField.test.ts +++ b/@coven/cron/tests/isListField.test.ts @@ -2,10 +2,13 @@ import { isListField } from "@coven/cron"; import { assert, assertFalse } from "@std/assert"; Deno.test("String that is a * returns false", () => - assertFalse(isListField("*"))); + assertFalse(isListField("*")), +); Deno.test("Array of numbers returns true", () => - assert(isListField([1, 2, 3]))); + assert(isListField([1, 2, 3])), +); Deno.test("Array of numbers and ranges returns true", () => - assert(isListField([1, 2, { from: 3, to: 5 }]))); + assert(isListField([1, 2, { from: 3, to: 5 }])), +); diff --git a/@coven/cron/tests/isListString.test.ts b/@coven/cron/tests/isListString.test.ts index feee60f..6f5cf3f 100644 --- a/@coven/cron/tests/isListString.test.ts +++ b/@coven/cron/tests/isListString.test.ts @@ -2,10 +2,13 @@ import { isListString } from "@coven/cron"; import { assert, assertFalse } from "@std/assert"; Deno.test("a string that is a * returns false", () => - assertFalse(isListString("*"))); + assertFalse(isListString("*")), +); Deno.test("an array of numbers returns true", () => - assert(isListString("1,2,3"))); + assert(isListString("1,2,3")), +); Deno.test("an array of numbers and ranges returns true", () => - assert(isListString("1,2,3-5"))); + assert(isListString("1,2,3-5")), +); diff --git a/@coven/cron/tests/isNumberString.test.ts b/@coven/cron/tests/isNumberString.test.ts index a2f1dbd..5011a88 100644 --- a/@coven/cron/tests/isNumberString.test.ts +++ b/@coven/cron/tests/isNumberString.test.ts @@ -2,6 +2,7 @@ import { isNumberString } from "@coven/cron"; import { assert, assertFalse } from "@std/assert"; Deno.test("String that is a * returns false", () => - assertFalse(isNumberString("*"))); + assertFalse(isNumberString("*")), +); Deno.test("Valid number returns true", () => assert(isNumberString("13"))); diff --git a/@coven/cron/tests/isRangeField.test.ts b/@coven/cron/tests/isRangeField.test.ts index e1aae03..ff5a0ee 100644 --- a/@coven/cron/tests/isRangeField.test.ts +++ b/@coven/cron/tests/isRangeField.test.ts @@ -2,12 +2,15 @@ import { isRangeField } from "@coven/cron"; import { assert, assertFalse } from "@std/assert"; Deno.test("String that is a * returns false", () => - assertFalse(isRangeField("*"))); + assertFalse(isRangeField("*")), +); Deno.test("Array of numbers returns true", () => - assertFalse(isRangeField([1, 2, 3]))); + assertFalse(isRangeField([1, 2, 3])), +); Deno.test("Range returns true", () => assert(isRangeField({ from: 3, to: 5 }))); Deno.test("Range with inverted from and to returns false", () => - assertFalse(isRangeField({ from: 5, to: 3 }))); + assertFalse(isRangeField({ from: 5, to: 3 })), +); diff --git a/@coven/cron/tests/isRangeString.test.ts b/@coven/cron/tests/isRangeString.test.ts index 15c852a..b06d8ae 100644 --- a/@coven/cron/tests/isRangeString.test.ts +++ b/@coven/cron/tests/isRangeString.test.ts @@ -2,12 +2,15 @@ import { isRangeString } from "@coven/cron"; import { assert, assertFalse } from "@std/assert"; Deno.test("String that is a * returns false", () => - assertFalse(isRangeString("*"))); + assertFalse(isRangeString("*")), +); Deno.test("Array of numbers returns true", () => - assertFalse(isRangeString("1,2,3"))); + assertFalse(isRangeString("1,2,3")), +); Deno.test("Range returns true", () => assert(isRangeString("3-5"))); Deno.test("Range with inverted from and to returns false", () => - assertFalse(isRangeString("5-3"))); + assertFalse(isRangeString("5-3")), +); diff --git a/@coven/cron/tests/isValidExpression.test.ts b/@coven/cron/tests/isValidExpression.test.ts index 4559406..1f406a8 100644 --- a/@coven/cron/tests/isValidExpression.test.ts +++ b/@coven/cron/tests/isValidExpression.test.ts @@ -2,13 +2,17 @@ import { isValidExpression } from "@coven/cron"; import { assert, assertFalse } from "@std/assert"; Deno.test("String that is a * returns false", () => - assertFalse(isValidExpression("*"))); + assertFalse(isValidExpression("*")), +); Deno.test("Valid expression returns true", () => - assert(isValidExpression("* * * * *"))); + assert(isValidExpression("* * * * *")), +); Deno.test("Valid expression with irregular spacing returns true", () => - assert(isValidExpression(" * * * * * "))); + assert(isValidExpression(" * * * * * ")), +); Deno.test("Valid expression with all values set returns true", () => - assert(isValidExpression("1,2-5 1,2-5 1,2-5 1,2-5 1,2-5"))); + assert(isValidExpression("1,2-5 1,2-5 1,2-5 1,2-5 1,2-5")), +); diff --git a/@coven/cron/tests/nextISODate.test.ts b/@coven/cron/tests/nextISODate.test.ts index 94d726f..61d866d 100644 --- a/@coven/cron/tests/nextISODate.test.ts +++ b/@coven/cron/tests/nextISODate.test.ts @@ -4,25 +4,32 @@ import { assertEquals } from "@std/assert"; const testDate = nextISODate("1992-01-01T00:00:00.000Z"); Deno.test("* * * * * gets next minute", () => - assertEquals(testDate("* * * * *"), "1992-01-01T00:01:00.000Z")); + assertEquals(testDate("* * * * *"), "1992-01-01T00:01:00.000Z"), +); Deno.test("5 * * * * gets next hour's minute 5", () => - assertEquals(testDate("5 * * * *"), "1992-01-01T00:05:00.000Z")); + assertEquals(testDate("5 * * * *"), "1992-01-01T00:05:00.000Z"), +); Deno.test("5 10-13 * * * gets next hour's minute 5", () => - assertEquals(testDate("5 10-13 * * *"), "1992-01-01T10:05:00.000Z")); + assertEquals(testDate("5 10-13 * * *"), "1992-01-01T10:05:00.000Z"), +); Deno.test("* * 31 2 * returns nothing because it's an invalid date", () => - assertEquals(testDate("* * 31 2 *"), undefined)); + assertEquals(testDate("* * 31 2 *"), undefined), +); Deno.test("* * 30,31 2 * returns nothing because it's an invalid date", () => - assertEquals(testDate("* * 30,31 2 *"), undefined)); + assertEquals(testDate("* * 30,31 2 *"), undefined), +); Deno.test("* * 30,31 2 * returns nothing because it's an invalid date", () => - assertEquals(testDate("* * 30,31 2 *"), undefined)); + assertEquals(testDate("* * 30,31 2 *"), undefined), +); Deno.test("* * 29,30,31 2 * gets first minute of next february 29", () => - assertEquals(testDate("* * 29,30,31 2 *"), "1992-02-29T00:00:00.000Z")); + assertEquals(testDate("* * 29,30,31 2 *"), "1992-02-29T00:00:00.000Z"), +); Deno.test("* * * * * as an object gets next minute", () => assertEquals( @@ -34,16 +41,19 @@ Deno.test("* * * * * as an object gets next minute", () => month: "*", }), "1992-01-01T00:01:00.000Z", - )); + ), +); Deno.test("5 * * * * as an object gets next hour's minute 5", () => - assertEquals(testDate({ minute: 5 }), "1992-01-01T00:05:00.000Z")); + assertEquals(testDate({ minute: 5 }), "1992-01-01T00:05:00.000Z"), +); Deno.test("5 10-13 * * * as an object gets next hour's minute 5", () => assertEquals( testDate({ hour: { from: 10, to: 13 }, minute: 5 }), "1992-01-01T10:05:00.000Z", - )); + ), +); Deno.test( "* * 31 2 * as object returns nothing because it's an invalid date", diff --git a/@coven/cron/tests/nextISODates.test.ts b/@coven/cron/tests/nextISODates.test.ts index 9a82e1d..9c13b46 100644 --- a/@coven/cron/tests/nextISODates.test.ts +++ b/@coven/cron/tests/nextISODates.test.ts @@ -12,7 +12,8 @@ Deno.test("* * * * * gives a new date every minute", () => "1992-01-01T00:03:00.000Z", "1992-01-01T00:04:00.000Z", "1992-01-01T00:05:00.000Z", - ])); + ]), +); Deno.test("5 * * * * gives a new date on minute 5 of each hour", () => assertEquals(iterableToArray(take(5)(testDate("5 * * * *"))), [ @@ -21,7 +22,8 @@ Deno.test("5 * * * * gives a new date on minute 5 of each hour", () => "1992-01-01T02:05:00.000Z", "1992-01-01T03:05:00.000Z", "1992-01-01T04:05:00.000Z", - ])); + ]), +); Deno.test( "5 10-13 * * * gives a new date on minute 5 of hours 10 to 13 of each day", @@ -36,22 +38,22 @@ Deno.test( ); Deno.test("* * 31 2 * returns nothing because it's an invalid date", () => - assertEquals( - iterableToArray(take(5)(testDate("* * 31 2 *"))), - EMPTY_ARRAY, - )); + assertEquals(iterableToArray(take(5)(testDate("* * 31 2 *"))), EMPTY_ARRAY), +); Deno.test("* * 30,31 2 * returns nothing because it's an invalid date", () => assertEquals( iterableToArray(take(5)(testDate("* * 30,31 2 *"))), EMPTY_ARRAY, - )); + ), +); Deno.test("* * 30,31 2 * returns nothing because it's an invalid date", () => assertEquals( iterableToArray(take(5)(testDate("* * 30,31 2 *"))), EMPTY_ARRAY, - )); + ), +); Deno.test( "* * 29,30,31 2 * returns only 29 of february dates skip the invalid ones", @@ -72,7 +74,8 @@ Deno.test("* * * * * as object gives a new date every minute", () => "1992-01-01T00:03:00.000Z", "1992-01-01T00:04:00.000Z", "1992-01-01T00:05:00.000Z", - ])); + ]), +); Deno.test("5 * * * * as object gives a new date on minute 5 of each hour", () => assertEquals(iterableToArray(take(5)(testDate({ minute: 5 }))), [ @@ -81,7 +84,8 @@ Deno.test("5 * * * * as object gives a new date on minute 5 of each hour", () => "1992-01-01T02:05:00.000Z", "1992-01-01T03:05:00.000Z", "1992-01-01T04:05:00.000Z", - ])); + ]), +); Deno.test( "5 10-13 * * * as object gives a new date on minute 5 of hours 10 to 13 of each day", diff --git a/@coven/cron/tests/normalizeAliases.test.ts b/@coven/cron/tests/normalizeAliases.test.ts index 3aa1176..9618289 100644 --- a/@coven/cron/tests/normalizeAliases.test.ts +++ b/@coven/cron/tests/normalizeAliases.test.ts @@ -2,7 +2,8 @@ import { normalizeAliases } from "@coven/cron"; import { assertStrictEquals } from "@std/assert"; Deno.test("Valid expression with no aliases returns same expression", () => - assertStrictEquals(normalizeAliases("* * * * *"), "* * * * *")); + assertStrictEquals(normalizeAliases("* * * * *"), "* * * * *"), +); Deno.test( "Valid expression with month and day of week aliased returns expression with aliases normalized", diff --git a/@coven/cron/tests/paddedRegExp.test.ts b/@coven/cron/tests/paddedRegExp.test.ts index 7750e26..d68de29 100644 --- a/@coven/cron/tests/paddedRegExp.test.ts +++ b/@coven/cron/tests/paddedRegExp.test.ts @@ -2,4 +2,5 @@ import { paddedRegExp } from "@coven/cron"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 5 returns number with padded 0?", () => - assertStrictEquals(paddedRegExp(5), "0?5")); + assertStrictEquals(paddedRegExp(5), "0?5"), +); diff --git a/@coven/cron/tests/parse.test.ts b/@coven/cron/tests/parse.test.ts index a1b0be9..6f1c807 100644 --- a/@coven/cron/tests/parse.test.ts +++ b/@coven/cron/tests/parse.test.ts @@ -1,3 +1,5 @@ +// This file is huge, but is because we have to cover quite a lot +// deno-lint-ignore coven/max-lines import type { CronString } from "@coven/cron"; import { parse } from "@coven/cron"; import { assertEquals, assertStrictEquals } from "@std/assert"; @@ -113,7 +115,8 @@ Deno.test("all fields set return object with all properties set", () => hour: 13, minute: 13, month: 10, - })); + }), +); Deno.test( "all fields set with ranges return object with all properties set", @@ -182,7 +185,8 @@ Deno.test("* * * Mar-oct MON-FRI handle month and day aliases", () => hour: "*", minute: "*", month: { from: 3, to: 10 }, - })); + }), +); Deno.test( "all fields set with lists with ranges, but a mistake in hour return undefined", @@ -194,19 +198,24 @@ Deno.test( ); Deno.test("an invalid string return undefined", () => - assertEquals(parse("INVALID" as CronString), undefined)); + assertEquals(parse("INVALID" as CronString), undefined), +); Deno.test("an invalid date return undefined", () => - assertEquals(parse("* * 31 2 *"), undefined)); + assertEquals(parse("* * 31 2 *"), undefined), +); Deno.test("an invalid date return undefined", () => - assertEquals(parse("* * 30 02 *"), undefined)); + assertEquals(parse("* * 30 02 *"), undefined), +); Deno.test("an invalid date return undefined", () => - assertEquals(parse("* * 31 feb *" as CronString), undefined)); + assertEquals(parse("* * 31 feb *" as CronString), undefined), +); Deno.test("an invalid date return undefined", () => - assertEquals(parse("* * 31 4 *"), undefined)); + assertEquals(parse("* * 31 4 *"), undefined), +); Deno.test( "a valid date containing an invalid one return it because there's a valid date", @@ -227,7 +236,8 @@ Deno.test("a list with duplicated values return flattened values", () => hour: "*", minute: [1, 2, 3], month: "*", - })); + }), +); Deno.test( "a list of ranges with duplicated values return flattened values", @@ -246,7 +256,8 @@ februaryBadDaysOfMonth.forEach((februaryBadDayOfMonth) => assertStrictEquals( parse(`* * ${februaryBadDayOfMonth} 2 *`), undefined, - )) + ), + ), ); februaryBadDaysOfMonth.forEach((februaryBadDayOfMonth) => @@ -267,7 +278,7 @@ februaryBadDaysOfMonth.forEach((februaryBadDayOfMonth) => month: [2, 3], } as const, ), - ) + ), ); februaryBadDaysOfMonth.forEach((februaryBadDayOfMonth) => @@ -287,5 +298,5 @@ februaryBadDaysOfMonth.forEach((februaryBadDayOfMonth) => month: { from: 2, to: 4 }, } as const, ), - ) + ), ); diff --git a/@coven/cron/tests/parseField.test.ts b/@coven/cron/tests/parseField.test.ts index 79104db..d13413a 100644 --- a/@coven/cron/tests/parseField.test.ts +++ b/@coven/cron/tests/parseField.test.ts @@ -4,13 +4,17 @@ import { assertEquals, assertStrictEquals } from "@std/assert"; Deno.test("* gets *", () => assertStrictEquals(parseField("*"), "*")); Deno.test("Number gets that parsed number", () => - assertStrictEquals(parseField("13"), 13)); + assertStrictEquals(parseField("13"), 13), +); Deno.test("List gets that list number", () => - assertEquals(parseField("10,11,12,13"), [10, 11, 12, 13])); + assertEquals(parseField("10,11,12,13"), [10, 11, 12, 13]), +); Deno.test("Range gets that list range", () => - assertEquals(parseField("10-13"), { from: 10, to: 13 })); + assertEquals(parseField("10-13"), { from: 10, to: 13 }), +); Deno.test("Invalid string gets undefined", () => - assertStrictEquals(parseField("invalid"), undefined)); + assertStrictEquals(parseField("invalid"), undefined), +); diff --git a/@coven/cron/tests/parseFieldTuplesMap.test.ts b/@coven/cron/tests/parseFieldTuplesMap.test.ts index 776b81c..e17a94c 100644 --- a/@coven/cron/tests/parseFieldTuplesMap.test.ts +++ b/@coven/cron/tests/parseFieldTuplesMap.test.ts @@ -5,20 +5,24 @@ import { assertEquals } from "@std/assert"; Deno.test("Tuple of minute and * returns parsed tuple", () => assertEquals(iterableToArray(parseFieldTuplesMap([["minute", "*"]])), [ ["minute", "*"], - ])); + ]), +); Deno.test("Tuple of minute and 13 returns parsed tuple", () => assertEquals(iterableToArray(parseFieldTuplesMap([["minute", "13"]])), [ ["minute", 13], - ])); + ]), +); Deno.test("Tuple of minute and 10,11,13 returns parsed tuple", () => assertEquals( iterableToArray(parseFieldTuplesMap([["minute", "10,11,13"]])), [["minute", [10, 11, 13]]], - )); + ), +); Deno.test("Tuple of minute and 13 returns parsed tuple", () => assertEquals(iterableToArray(parseFieldTuplesMap([["minute", "1-10"]])), [ ["minute", { from: 1, to: 10 }], - ])); + ]), +); diff --git a/@coven/cron/tests/parseList.test.ts b/@coven/cron/tests/parseList.test.ts index 26d9c1e..ea4171e 100644 --- a/@coven/cron/tests/parseList.test.ts +++ b/@coven/cron/tests/parseList.test.ts @@ -2,4 +2,5 @@ import { parseList } from "@coven/cron"; import { assertEquals } from "@std/assert"; Deno.test("List with 10, 11 and 13 returns parsed list", () => - assertEquals(parseList("10,11,13"), [10, 11, 13])); + assertEquals(parseList("10,11,13"), [10, 11, 13]), +); diff --git a/@coven/cron/tests/parseListMap.test.ts b/@coven/cron/tests/parseListMap.test.ts index 8f3a0e8..3262118 100644 --- a/@coven/cron/tests/parseListMap.test.ts +++ b/@coven/cron/tests/parseListMap.test.ts @@ -8,4 +8,5 @@ Deno.test("List of valid and invalid values returns parsed list", () => parseListMap(["1", "05", "13", "5-13", "13-13", "13-5", "99"]), ), [1, 5, 13, { from: 5, to: 13 }, 13, undefined, undefined], - )); + ), +); diff --git a/@coven/cron/tests/parseNumber.test.ts b/@coven/cron/tests/parseNumber.test.ts index c66d866..d8170a9 100644 --- a/@coven/cron/tests/parseNumber.test.ts +++ b/@coven/cron/tests/parseNumber.test.ts @@ -2,10 +2,13 @@ import { parseNumber } from "@coven/cron"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 10 and a 13 returns parsed values", () => - assertStrictEquals(parseNumber("13"), 13)); + assertStrictEquals(parseNumber("13"), 13), +); Deno.test("Ranges with padding zeroes returns parsed values", () => - assertStrictEquals(parseNumber("05"), 5)); + assertStrictEquals(parseNumber("05"), 5), +); Deno.test("Numbers beyond 59 returns undefined", () => - assertStrictEquals(parseNumber("60"), undefined)); + assertStrictEquals(parseNumber("60"), undefined), +); diff --git a/@coven/cron/tests/parseNumberMap.test.ts b/@coven/cron/tests/parseNumberMap.test.ts index dda2c11..8b913cf 100644 --- a/@coven/cron/tests/parseNumberMap.test.ts +++ b/@coven/cron/tests/parseNumberMap.test.ts @@ -3,13 +3,16 @@ import { iterableToArray } from "@coven/iterables"; import { assertEquals } from "@std/assert"; Deno.test("Number 10 and a 13 returns parsed values", () => - assertEquals(iterableToArray(parseNumberMap(["10", "13"])), [10, 13])); + assertEquals(iterableToArray(parseNumberMap(["10", "13"])), [10, 13]), +); Deno.test("Ranges with padding zeroes returnsparsed values", () => - assertEquals(iterableToArray(parseNumberMap(["01", "02"])), [1, 2])); + assertEquals(iterableToArray(parseNumberMap(["01", "02"])), [1, 2]), +); Deno.test("Numbers beyond 59 returns undefined", () => assertEquals(iterableToArray(parseNumberMap(["99", "60"])), [ undefined, undefined, - ])); + ]), +); diff --git a/@coven/cron/tests/parseNumberTest.test.ts b/@coven/cron/tests/parseNumberTest.test.ts index 2f4d7f3..1707e2e 100644 --- a/@coven/cron/tests/parseNumberTest.test.ts +++ b/@coven/cron/tests/parseNumberTest.test.ts @@ -2,10 +2,13 @@ import { parseNumberTest } from "@coven/cron"; import { assert, assertFalse } from "@std/assert"; Deno.test("Number 10 and a 13 returns true", () => - assert(parseNumberTest("13"))); + assert(parseNumberTest("13")), +); Deno.test("Ranges with padding zeroes returns true", () => - assert(parseNumberTest("05"))); + assert(parseNumberTest("05")), +); Deno.test("Numbers beyond 59 returns false", () => - assertFalse(parseNumberTest("60"))); + assertFalse(parseNumberTest("60")), +); diff --git a/@coven/cron/tests/parseRange.test.ts b/@coven/cron/tests/parseRange.test.ts index d151af6..8df3e57 100644 --- a/@coven/cron/tests/parseRange.test.ts +++ b/@coven/cron/tests/parseRange.test.ts @@ -2,10 +2,13 @@ import { parseRange } from "@coven/cron"; import { assertEquals, assertStrictEquals } from "@std/assert"; Deno.test("Number 1 and a 13 returns parsed values", () => - assertEquals(parseRange("1-13"), { from: 1, to: 13 })); + assertEquals(parseRange("1-13"), { from: 1, to: 13 }), +); Deno.test("Number 13 and a 13 returns normalized 13", () => - assertStrictEquals(parseRange("13-13"), 13)); + assertStrictEquals(parseRange("13-13"), 13), +); Deno.test("Number 13 and a 1 returns parsed undefined", () => - assertStrictEquals(parseRange("13-1"), undefined)); + assertStrictEquals(parseRange("13-1"), undefined), +); diff --git a/@coven/cron/tests/rangeStringTest.test.ts b/@coven/cron/tests/rangeStringTest.test.ts index 223d138..9de7e35 100644 --- a/@coven/cron/tests/rangeStringTest.test.ts +++ b/@coven/cron/tests/rangeStringTest.test.ts @@ -4,4 +4,5 @@ import { assert, assertFalse } from "@std/assert"; Deno.test("Range string returns true", () => assert(rangeStringTest("10-13"))); Deno.test("Invalid range string returns false", () => - assertFalse(rangeStringTest("nope"))); + assertFalse(rangeStringTest("nope")), +); diff --git a/@coven/cron/tests/stringify.test.ts b/@coven/cron/tests/stringify.test.ts index aaf61f9..8caac4b 100644 --- a/@coven/cron/tests/stringify.test.ts +++ b/@coven/cron/tests/stringify.test.ts @@ -102,7 +102,8 @@ Deno.test("All fields set returns object with all properties set", () => month: 10, }), "13 13 13 10 5", - )); + ), +); Deno.test( "All fields set with ranges returns object with all properties set", @@ -150,10 +151,13 @@ Deno.test( ); Deno.test("Empty object returns all set to *", () => - assertStrictEquals(stringify(EMPTY_OBJECT), "* * * * *")); + assertStrictEquals(stringify(EMPTY_OBJECT), "* * * * *"), +); Deno.test("Only hour set returns all set to *", () => - assertStrictEquals(stringify({ hour: 13 }), "* 13 * * *")); + assertStrictEquals(stringify({ hour: 13 }), "* 13 * * *"), +); Deno.test("Invalid value returns undefined", () => - assertStrictEquals(stringify({ hour: 99 as 13 }), undefined)); + assertStrictEquals(stringify({ hour: 99 as 13 }), undefined), +); diff --git a/@coven/cron/tests/stringifyField.test.ts b/@coven/cron/tests/stringifyField.test.ts index ec26192..f11947f 100644 --- a/@coven/cron/tests/stringifyField.test.ts +++ b/@coven/cron/tests/stringifyField.test.ts @@ -2,7 +2,9 @@ import { stringifyField } from "@coven/cron"; import { assertStrictEquals } from "@std/assert"; Deno.test("Array of numbers returns stringified list", () => - assertStrictEquals(stringifyField([10, 13]), "10,13")); + assertStrictEquals(stringifyField([10, 13]), "10,13"), +); Deno.test("Range returns stringified range", () => - assertStrictEquals(stringifyField({ from: 10, to: 13 }), "10-13")); + assertStrictEquals(stringifyField({ from: 10, to: 13 }), "10-13"), +); diff --git a/@coven/cron/tests/stringifyList.test.ts b/@coven/cron/tests/stringifyList.test.ts index 919b625..c3b159c 100644 --- a/@coven/cron/tests/stringifyList.test.ts +++ b/@coven/cron/tests/stringifyList.test.ts @@ -2,7 +2,9 @@ import { stringifyList } from "@coven/cron"; import { assertStrictEquals } from "@std/assert"; Deno.test("Array of numbers returns stringified list", () => - assertStrictEquals(stringifyList([10, 13]), "10,13")); + assertStrictEquals(stringifyList([10, 13]), "10,13"), +); Deno.test("Invalid value returns undefined", () => - assertStrictEquals(stringifyList("nope" as "*"), undefined)); + assertStrictEquals(stringifyList("nope" as "*"), undefined), +); diff --git a/@coven/cron/tests/stringifyRange.test.ts b/@coven/cron/tests/stringifyRange.test.ts index ec443ca..4682ac6 100644 --- a/@coven/cron/tests/stringifyRange.test.ts +++ b/@coven/cron/tests/stringifyRange.test.ts @@ -2,7 +2,9 @@ import { stringifyRange } from "@coven/cron"; import { assertStrictEquals } from "@std/assert"; Deno.test("Range returns stringified range", () => - assertStrictEquals(stringifyRange({ from: 10, to: 13 }), "10-13")); + assertStrictEquals(stringifyRange({ from: 10, to: 13 }), "10-13"), +); Deno.test("Invalid value returns undefined", () => - assertStrictEquals(stringifyRange("nope" as "*"), undefined)); + assertStrictEquals(stringifyRange("nope" as "*"), undefined), +); diff --git a/@coven/cron/tests/timestampInCron.test.ts b/@coven/cron/tests/timestampInCron.test.ts index 40ba9d0..1aa7529 100644 --- a/@coven/cron/tests/timestampInCron.test.ts +++ b/@coven/cron/tests/timestampInCron.test.ts @@ -10,9 +10,9 @@ const dateInCronTest = timestampInCron({ }); Deno.test("Date inside the cron expression returns true", () => - assert(dateInCronTest(new Date("1989-05-05T05:05:00.000Z").getTime()))); + assert(dateInCronTest(new Date("1989-05-05T05:05:00.000Z").getTime())), +); Deno.test("Date outside the cron expression returns false", () => - assertFalse( - dateInCronTest(new Date("2024-05-05T05:05:00.000Z").getTime()), - )); + assertFalse(dateInCronTest(new Date("2024-05-05T05:05:00.000Z").getTime())), +); diff --git a/@coven/cron/tests/valueOrRangeRegExp.test.ts b/@coven/cron/tests/valueOrRangeRegExp.test.ts index d4d5589..da96050 100644 --- a/@coven/cron/tests/valueOrRangeRegExp.test.ts +++ b/@coven/cron/tests/valueOrRangeRegExp.test.ts @@ -2,4 +2,5 @@ import { valueOrRangeRegExp } from "@coven/cron"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 13 returns value or range regular expression", () => - assertStrictEquals(valueOrRangeRegExp(13), "13(?:-13)?")); + assertStrictEquals(valueOrRangeRegExp(13), "13(?:-13)?"), +); diff --git a/@coven/cron/tests/valueRangeOrListRegExp.test.ts b/@coven/cron/tests/valueRangeOrListRegExp.test.ts index 5e2a0c6..b6a3673 100644 --- a/@coven/cron/tests/valueRangeOrListRegExp.test.ts +++ b/@coven/cron/tests/valueRangeOrListRegExp.test.ts @@ -5,4 +5,5 @@ Deno.test("Number 13 returns string expression", () => assertStrictEquals( valueRangeOrListRegExp(13), "(?:13(?:-13)?|(?:(?:13(?:-13)?,)+13(?:-13)?))", - )); + ), +); diff --git a/@coven/cron/tests/zipRangeNames.test.ts b/@coven/cron/tests/zipRangeNames.test.ts index 070adf0..d5a9718 100644 --- a/@coven/cron/tests/zipRangeNames.test.ts +++ b/@coven/cron/tests/zipRangeNames.test.ts @@ -6,4 +6,5 @@ Deno.test("Number 10 and a 13 returns zipped array with from and to", () => assertEquals(iterableToArray(zipRangeNames(["10", "13"])), [ ["from", "10"], ["to", "13"], - ])); + ]), +); diff --git a/@coven/cron/timestampInCron.ts b/@coven/cron/timestampInCron.ts index 3e9508b..d46be14 100644 --- a/@coven/cron/timestampInCron.ts +++ b/@coven/cron/timestampInCron.ts @@ -13,7 +13,7 @@ import { isAllToken } from "./isAllToken.ts"; export const timestampInCron: ( cron: CronObject, ) => (timestamp: number) => Maybe = memo( - (cron: CronObject): (timestamp: number) => Maybe => { + (cron: CronObject): ((timestamp: number) => Maybe) => { const minuteIsAll = isAllToken(cron.minute); const hourIsAll = isAllToken(cron.hour); const dayOfMonthIsAll = isAllToken(cron.dayOfMonth); @@ -27,17 +27,17 @@ export const timestampInCron: ( return ( (minuteIsAll || compareField(date.getUTCMinutes(), cron.minute)) - && (hourIsAll - || compareField(date.getUTCHours(), cron.hour)) - && (dayOfMonthIsAll - || compareField(date.getUTCDate(), cron.dayOfMonth)) - && (monthIsAll - || compareField(date.getUTCMonth() + 1, cron.month)) - && (dayOfWeekIsAll - || compareField(date.getUTCDay(), cron.dayOfWeek)) - ) - ? (date.toISOString() as ISODate) - : undefined; + && (hourIsAll + || compareField(date.getUTCHours(), cron.hour)) + && (dayOfMonthIsAll + || compareField(date.getUTCDate(), cron.dayOfMonth)) + && (monthIsAll + || compareField(date.getUTCMonth() + 1, cron.month)) + && (dayOfWeekIsAll + || compareField(date.getUTCDay(), cron.dayOfWeek)) + ) ? + (date.toISOString() as ISODate) + : undefined; }; }, ); diff --git a/@coven/cron/valueRangeOrListRegExp.ts b/@coven/cron/valueRangeOrListRegExp.ts index 992b44d..a80b23c 100644 --- a/@coven/cron/valueRangeOrListRegExp.ts +++ b/@coven/cron/valueRangeOrListRegExp.ts @@ -14,8 +14,7 @@ import { valueOrRangeRegExp } from "./valueOrRangeRegExp.ts"; */ export const valueRangeOrListRegExp: ( value: Value, -) => - `(?:${Value}(?:-${Value})?|(?:(?:${Value}(?:-${Value})?,)+${Value}(?:-${Value})?))` = - memo((value: Value) => - valueOrListRegExp(valueOrRangeRegExp(value)) - ); +) => `(?:${Value}(?:-${Value})?|(?:(?:${Value}(?:-${Value})?,)+${Value}(?:-${Value})?))` = + memo((value: Value) => + valueOrListRegExp(valueOrRangeRegExp(value)), + ); diff --git a/@coven/cron/zipRangeNames.ts b/@coven/cron/zipRangeNames.ts index 260e6ff..e5e2e90 100644 --- a/@coven/cron/zipRangeNames.ts +++ b/@coven/cron/zipRangeNames.ts @@ -7,9 +7,7 @@ import type { RangeField } from "./RangeField.ts"; */ export const zipRangeNames: ( rangeNames: Iterable, -) => IterableIterator>, RangeNames]>> = zip( - [ - "from", - "to", - ] as const, -); +) => IterableIterator>, RangeNames]>> = zip([ + "from", + "to", +] as const); diff --git a/@coven/expression/build.ts b/@coven/expression/build.ts index 2593de6..ed8cf7f 100644 --- a/@coven/expression/build.ts +++ b/@coven/expression/build.ts @@ -30,15 +30,17 @@ export const build: ( memo( ( flags: Flags | "u" = "u", - ) => memo( - >( - ...atoms: Atoms - ) => new RegExp(join(...atoms), flags) as Replace< - RegExp, - Readonly<{ - flags: Flags; - source: StringJoin; - }> - >, - ), + ) => + memo( + >( + ...atoms: Atoms + ) => + new RegExp(join(...atoms), flags) as Replace< + RegExp, + Readonly<{ + flags: Flags; + source: StringJoin; + }> + >, + ), ); diff --git a/@coven/expression/captureNamed.ts b/@coven/expression/captureNamed.ts index b010a9e..bd5cf92 100644 --- a/@coven/expression/captureNamed.ts +++ b/@coven/expression/captureNamed.ts @@ -25,5 +25,5 @@ export const captureNamed: ( >( ...pattern: Pattern ) => `(?<${GroupName}>${StringJoin})` = memo((name) => - captureType(`<${name}>`) + captureType(`<${name}>`), ); diff --git a/@coven/expression/captureType.ts b/@coven/expression/captureType.ts index 2d29900..5e2cdad 100644 --- a/@coven/expression/captureType.ts +++ b/@coven/expression/captureType.ts @@ -22,8 +22,9 @@ export const captureType: ( memo( >( ...pattern: Pattern - ) => capture( - `?${type}${join(...pattern)}`, - ) as `(?${Type}${StringJoin})`, + ) => + capture( + `?${type}${join(...pattern)}`, + ) as `(?${Type}${StringJoin})`, ), ); diff --git a/@coven/expression/hexadecimal.ts b/@coven/expression/hexadecimal.ts index a5796a1..473847a 100644 --- a/@coven/expression/hexadecimal.ts +++ b/@coven/expression/hexadecimal.ts @@ -17,5 +17,5 @@ export const hexadecimal: < >( hexadecimalValue: HexadecimalValue, ) => `\\x${HexadecimalValue}` = memo((hexadecimalValue) => - escape(`x${hexadecimalValue}`) + escape(`x${hexadecimalValue}`), ); diff --git a/@coven/expression/modifier.ts b/@coven/expression/modifier.ts index 49eb684..97fbc89 100644 --- a/@coven/expression/modifier.ts +++ b/@coven/expression/modifier.ts @@ -31,5 +31,5 @@ export const modifier: < */ >( ...pattern: Pattern ) => `(?${Flags}:${StringJoin})` = memo((flags) => - captureType(`${flags}:`) + captureType(`${flags}:`), ); diff --git a/@coven/expression/quantity.ts b/@coven/expression/quantity.ts index 5cad4b8..8c5de50 100644 --- a/@coven/expression/quantity.ts +++ b/@coven/expression/quantity.ts @@ -24,11 +24,12 @@ export const quantity: ( ) => `${StringJoin}{${Quantities}}` = memo( ( quantities: Quantities, - ) => memo( - >(...items: Items) => - join( - ...items, - `{${quantities}}`, - ) as `${StringJoin}{${Quantities}}`, - ), + ) => + memo( + >(...items: Items) => + join( + ...items, + `{${quantities}}`, + ) as `${StringJoin}{${Quantities}}`, + ), ); diff --git a/@coven/expression/range.ts b/@coven/expression/range.ts index 023fe43..2d8fbba 100644 --- a/@coven/expression/range.ts +++ b/@coven/expression/range.ts @@ -19,5 +19,5 @@ export const range: ( * @param to Final value of the range (inclusive). * @returns Range from `from` to `to`. */ (to: To) => `${From}-${To}` = memo((from) => - memo((to) => `${from}-${to}`) + memo((to) => `${from}-${to}`), ); diff --git a/@coven/expression/tests/allow.test.ts b/@coven/expression/tests/allow.test.ts index 866e14d..18e1c2c 100644 --- a/@coven/expression/tests/allow.test.ts +++ b/@coven/expression/tests/allow.test.ts @@ -2,7 +2,9 @@ import { allow } from "@coven/expression"; import { assertStringIncludes } from "@std/assert"; Deno.test("Number 13 adds a star to the right", () => - assertStringIncludes(allow(13), "13*")); + assertStringIncludes(allow(13), "13*"), +); Deno.test("Number 1 and number 3 adds a star to the right", () => - assertStringIncludes(allow(1, 3), "13*")); + assertStringIncludes(allow(1, 3), "13*"), +); diff --git a/@coven/expression/tests/backreference.test.ts b/@coven/expression/tests/backreference.test.ts index 8005dce..8859b41 100644 --- a/@coven/expression/tests/backreference.test.ts +++ b/@coven/expression/tests/backreference.test.ts @@ -2,4 +2,5 @@ import { backreference } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 13 adds an escape sequence to the left", () => - assertStrictEquals(backreference(13), String.raw`\13`)); + assertStrictEquals(backreference(13), String.raw`\13`), +); diff --git a/@coven/expression/tests/build.test.ts b/@coven/expression/tests/build.test.ts index 85d1084..3b05b3a 100644 --- a/@coven/expression/tests/build.test.ts +++ b/@coven/expression/tests/build.test.ts @@ -8,4 +8,5 @@ Deno.test('Grouping 13 and the string "coven" returns expected RegExp', () => assertEquals( { flags: createdRegExp.flags, source: createdRegExp.source }, { flags: regExp.flags, source: regExp.source }, - )); + ), +); diff --git a/@coven/expression/tests/buildUnicode.test.ts b/@coven/expression/tests/buildUnicode.test.ts index 540f2d6..100641f 100644 --- a/@coven/expression/tests/buildUnicode.test.ts +++ b/@coven/expression/tests/buildUnicode.test.ts @@ -8,4 +8,5 @@ Deno.test('Grouping 13 and the string "coven" returns expected RegExp', () => assertEquals( { flags: createdRegExp.flags, source: createdRegExp.source }, { flags: regExp.flags, source: regExp.source }, - )); + ), +); diff --git a/@coven/expression/tests/capture.test.ts b/@coven/expression/tests/capture.test.ts index 7112046..f4bc150 100644 --- a/@coven/expression/tests/capture.test.ts +++ b/@coven/expression/tests/capture.test.ts @@ -2,7 +2,9 @@ import { capture } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 13 adds a parenthesis around it", () => - assertStrictEquals(capture(13), "(13)")); + assertStrictEquals(capture(13), "(13)"), +); Deno.test("Number 1, and number 3 adds a parenthesis around it", () => - assertStrictEquals(capture(1, 3), "(13)")); + assertStrictEquals(capture(1, 3), "(13)"), +); diff --git a/@coven/expression/tests/characterClass.test.ts b/@coven/expression/tests/characterClass.test.ts index f4a605d..7eb00cb 100644 --- a/@coven/expression/tests/characterClass.test.ts +++ b/@coven/expression/tests/characterClass.test.ts @@ -2,7 +2,9 @@ import { characterClass } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 13 adds a [] around it", () => - assertStrictEquals(characterClass(13), "[13]")); + assertStrictEquals(characterClass(13), "[13]"), +); Deno.test("10 and a 13 adds a [] around them", () => - assertStrictEquals(characterClass(10, 13), "[1013]")); + assertStrictEquals(characterClass(10, 13), "[1013]"), +); diff --git a/@coven/expression/tests/complementClass.test.ts b/@coven/expression/tests/complementClass.test.ts index 4503d03..f7d227c 100644 --- a/@coven/expression/tests/complementClass.test.ts +++ b/@coven/expression/tests/complementClass.test.ts @@ -2,7 +2,9 @@ import { complementClass } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 13 is wrapped it with a negated set", () => - assertStrictEquals(complementClass(13), "[^13]")); + assertStrictEquals(complementClass(13), "[^13]"), +); Deno.test("Number 1, and a 3 are wrapped them with a negated set", () => - assertStrictEquals(complementClass(1, 3), "[^13]")); + assertStrictEquals(complementClass(1, 3), "[^13]"), +); diff --git a/@coven/expression/tests/controlCharacter.test.ts b/@coven/expression/tests/controlCharacter.test.ts index e26a6b6..9a18f4b 100644 --- a/@coven/expression/tests/controlCharacter.test.ts +++ b/@coven/expression/tests/controlCharacter.test.ts @@ -2,4 +2,5 @@ import { controlCharacter } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Letter J is escaped with the c character", () => - assertStrictEquals(controlCharacter("J"), String.raw`\cJ`)); + assertStrictEquals(controlCharacter("J"), String.raw`\cJ`), +); diff --git a/@coven/expression/tests/disjunction.test.ts b/@coven/expression/tests/disjunction.test.ts index ba833fb..fbba3d6 100644 --- a/@coven/expression/tests/disjunction.test.ts +++ b/@coven/expression/tests/disjunction.test.ts @@ -7,4 +7,5 @@ Deno.test( ); Deno.test("Number 1, and a 3 are joined with a | in between", () => - assertStrictEquals(disjunction(1, 3), "1|3")); + assertStrictEquals(disjunction(1, 3), "1|3"), +); diff --git a/@coven/expression/tests/escape.test.ts b/@coven/expression/tests/escape.test.ts index 38f83dc..91b5060 100644 --- a/@coven/expression/tests/escape.test.ts +++ b/@coven/expression/tests/escape.test.ts @@ -2,4 +2,5 @@ import { escape } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Letter L is escaped", () => - assertStrictEquals(escape("L"), String.raw`\L`)); + assertStrictEquals(escape("L"), String.raw`\L`), +); diff --git a/@coven/expression/tests/exists.test.ts b/@coven/expression/tests/exists.test.ts index 1212cf3..da2587b 100644 --- a/@coven/expression/tests/exists.test.ts +++ b/@coven/expression/tests/exists.test.ts @@ -2,7 +2,9 @@ import { exists } from "@coven/expression"; import { assertEquals } from "@std/assert"; Deno.test("Number 13 adds a + to the right", () => - assertEquals(exists(13), "13+")); + assertEquals(exists(13), "13+"), +); Deno.test("Number 1 and number 3 adds a + to the right", () => - assertEquals(exists(1, 3), "13+")); + assertEquals(exists(1, 3), "13+"), +); diff --git a/@coven/expression/tests/group.test.ts b/@coven/expression/tests/group.test.ts index ba74add..fe32f4d 100644 --- a/@coven/expression/tests/group.test.ts +++ b/@coven/expression/tests/group.test.ts @@ -2,7 +2,9 @@ import { group } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 13 adds a non-capturing group around it", () => - assertStrictEquals(group(13), "(?:13)")); + assertStrictEquals(group(13), "(?:13)"), +); Deno.test("Number 1, and a 3 add a non-capturing next group around 13", () => - assertStrictEquals(group(1, 3), "(?:13)")); + assertStrictEquals(group(1, 3), "(?:13)"), +); diff --git a/@coven/expression/tests/join.test.ts b/@coven/expression/tests/join.test.ts index a721def..da79ef0 100644 --- a/@coven/expression/tests/join.test.ts +++ b/@coven/expression/tests/join.test.ts @@ -2,4 +2,5 @@ import { join } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("1 and a 3 join strings as 13", () => - assertStrictEquals(join(1, 3), "13")); + assertStrictEquals(join(1, 3), "13"), +); diff --git a/@coven/expression/tests/lookahead.test.ts b/@coven/expression/tests/lookahead.test.ts index 0e8739d..1152a9d 100644 --- a/@coven/expression/tests/lookahead.test.ts +++ b/@coven/expression/tests/lookahead.test.ts @@ -2,4 +2,5 @@ import { lookahead } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 13 adds capture next group around it", () => - assertStrictEquals(lookahead(13), "(?=13)")); + assertStrictEquals(lookahead(13), "(?=13)"), +); diff --git a/@coven/expression/tests/lookbehind.test.ts b/@coven/expression/tests/lookbehind.test.ts index 25a019e..ebf18fa 100644 --- a/@coven/expression/tests/lookbehind.test.ts +++ b/@coven/expression/tests/lookbehind.test.ts @@ -2,7 +2,9 @@ import { lookbehind } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 13 add capture previous group around it", () => - assertStrictEquals(lookbehind(13), "(?<=13)")); + assertStrictEquals(lookbehind(13), "(?<=13)"), +); Deno.test("Number 1, and a 3 add capture previous group around it", () => - assertStrictEquals(lookbehind(1, 3), "(?<=13)")); + assertStrictEquals(lookbehind(1, 3), "(?<=13)"), +); diff --git a/@coven/expression/tests/modifier.test.ts b/@coven/expression/tests/modifier.test.ts index c880ef2..8719f66 100644 --- a/@coven/expression/tests/modifier.test.ts +++ b/@coven/expression/tests/modifier.test.ts @@ -2,19 +2,25 @@ import { modifier } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test('Modifier "ims" applied to number 13', () => - assertStrictEquals(modifier("ims")(13), "(?ims:13)")); + assertStrictEquals(modifier("ims")(13), "(?ims:13)"), +); Deno.test('Modifier "i-ms" applied to number 13', () => - assertStrictEquals(modifier("i-ms")(13), "(?i-ms:13)")); + assertStrictEquals(modifier("i-ms")(13), "(?i-ms:13)"), +); Deno.test('Modifier "-i" applied to number 13', () => - assertStrictEquals(modifier("-i")(13), "(?-i:13)")); + assertStrictEquals(modifier("-i")(13), "(?-i:13)"), +); Deno.test('Modifier "ims" applied to number 1, and number 3', () => - assertStrictEquals(modifier("ims")(1, 3), "(?ims:13)")); + assertStrictEquals(modifier("ims")(1, 3), "(?ims:13)"), +); Deno.test('Modifier "i-ms" applied to number 1, and number 3', () => - assertStrictEquals(modifier("i-ms")(1, 3), "(?i-ms:13)")); + assertStrictEquals(modifier("i-ms")(1, 3), "(?i-ms:13)"), +); Deno.test('Modifier "-i" applied to number 1, and number 3', () => - assertStrictEquals(modifier("-i")(1, 3), "(?-i:13)")); + assertStrictEquals(modifier("-i")(1, 3), "(?-i:13)"), +); diff --git a/@coven/expression/tests/namedBackreference.test.ts b/@coven/expression/tests/namedBackreference.test.ts index a468039..81a41ce 100644 --- a/@coven/expression/tests/namedBackreference.test.ts +++ b/@coven/expression/tests/namedBackreference.test.ts @@ -2,4 +2,5 @@ import { namedBackreference } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Named backreference to group ✨", () => - assertStrictEquals(namedBackreference("✨"), String.raw`\k<✨>`)); + assertStrictEquals(namedBackreference("✨"), String.raw`\k<✨>`), +); diff --git a/@coven/expression/tests/negativeLookahead.test.ts b/@coven/expression/tests/negativeLookahead.test.ts index cfc6726..fe16f9c 100644 --- a/@coven/expression/tests/negativeLookahead.test.ts +++ b/@coven/expression/tests/negativeLookahead.test.ts @@ -2,7 +2,9 @@ import { negativeLookahead } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 13 is not captured next group around 13", () => - assertStrictEquals(negativeLookahead(13), "(?!13)")); + assertStrictEquals(negativeLookahead(13), "(?!13)"), +); Deno.test("Number 1, and a 3 are not captured next group around 13", () => - assertStrictEquals(negativeLookahead(1, 3), "(?!13)")); + assertStrictEquals(negativeLookahead(1, 3), "(?!13)"), +); diff --git a/@coven/expression/tests/negativeLookbehind.test.ts b/@coven/expression/tests/negativeLookbehind.test.ts index 619033f..0eda6f5 100644 --- a/@coven/expression/tests/negativeLookbehind.test.ts +++ b/@coven/expression/tests/negativeLookbehind.test.ts @@ -2,7 +2,9 @@ import { negativeLookbehind } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 13 is not capture previous group around 13", () => - assertStrictEquals(negativeLookbehind(13), "(? - assertStrictEquals(negativeLookbehind(1, 3), "(? - assertStrictEquals(optional(13), "13?")); + assertStrictEquals(optional(13), "13?"), +); Deno.test("Number 1, and number 3 adds a ? to the right", () => - assertStrictEquals(optional(1, 3), "13?")); + assertStrictEquals(optional(1, 3), "13?"), +); diff --git a/@coven/expression/tests/range.test.ts b/@coven/expression/tests/range.test.ts index 3ad2725..3aabce6 100644 --- a/@coven/expression/tests/range.test.ts +++ b/@coven/expression/tests/range.test.ts @@ -2,4 +2,5 @@ import { range } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("10 and a 13 adds a - between them", () => - assertStrictEquals(range(10)(13), "10-13")); + assertStrictEquals(range(10)(13), "10-13"), +); diff --git a/@coven/expression/tests/unicode.test.ts b/@coven/expression/tests/unicode.test.ts index 5d18d52..f5d4b62 100644 --- a/@coven/expression/tests/unicode.test.ts +++ b/@coven/expression/tests/unicode.test.ts @@ -2,4 +2,5 @@ import { unicode } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 13 adds a the unicode escape around it", () => - assertStrictEquals(unicode(13), String.raw`\u{13}`)); + assertStrictEquals(unicode(13), String.raw`\u{13}`), +); diff --git a/@coven/expression/tests/unicodeCharacterClassEscape.test.ts b/@coven/expression/tests/unicodeCharacterClassEscape.test.ts index f3f92e2..a073971 100644 --- a/@coven/expression/tests/unicodeCharacterClassEscape.test.ts +++ b/@coven/expression/tests/unicodeCharacterClassEscape.test.ts @@ -2,4 +2,5 @@ import { unicodeCharacterClass } from "@coven/expression"; import { assertStrictEquals } from "@std/assert"; Deno.test("Number 13 adds a the unicode character class escape around it", () => - assertStrictEquals(unicodeCharacterClass(13), String.raw`\p{13}`)); + assertStrictEquals(unicodeCharacterClass(13), String.raw`\p{13}`), +); diff --git a/@coven/expression/unicode.ts b/@coven/expression/unicode.ts index 3fc5dd7..0ef5741 100644 --- a/@coven/expression/unicode.ts +++ b/@coven/expression/unicode.ts @@ -20,5 +20,5 @@ import { escape } from "./escape.ts"; export const unicode: ( hexadecimalValue: HexadecimalValue, ) => `\\u{${HexadecimalValue}}` = memo((hexadecimalValue) => - escape(`u{${hexadecimalValue}}`) + escape(`u{${hexadecimalValue}}`), ); diff --git a/@coven/iterables/EMPTY_ITERABLE_ITERATOR.ts b/@coven/iterables/EMPTY_ITERABLE_ITERATOR.ts index ce1e049..4d0bb18 100644 --- a/@coven/iterables/EMPTY_ITERABLE_ITERATOR.ts +++ b/@coven/iterables/EMPTY_ITERABLE_ITERATOR.ts @@ -4,6 +4,5 @@ import { toIterable } from "./toIterable.ts"; /** * IterableIterator that yields nothing. Useful for fallbacks */ -export const EMPTY_ITERABLE_ITERATOR: IterableIterator = toIterable( - EMPTY_ARRAY, -); +export const EMPTY_ITERABLE_ITERATOR: IterableIterator = + toIterable(EMPTY_ARRAY); diff --git a/@coven/iterables/append.ts b/@coven/iterables/append.ts index ec2a54c..e1b31e7 100644 --- a/@coven/iterables/append.ts +++ b/@coven/iterables/append.ts @@ -13,15 +13,16 @@ import { iteratorFunctionToIterableIterator } from "./iteratorFunctionToIterable * @param tailIterable Iterable to be appended. * @returns Curried generator function with `tailIterable` set in context. */ -export const append = ( - tailIterable: Iterable, -): ( - initialIterable: Iterable, -) => IterableIterator => -(initialIterable: Iterable) => - iteratorFunctionToIterableIterator(function* (): Generator< - TailItem | InitialItem - > { - yield* initialIterable; - yield* tailIterable; - }); +export const append = + ( + tailIterable: Iterable, + ): (( + initialIterable: Iterable, + ) => IterableIterator) => + (initialIterable: Iterable) => + iteratorFunctionToIterableIterator(function* (): Generator< + TailItem | InitialItem + > { + yield* initialIterable; + yield* tailIterable; + }); diff --git a/@coven/iterables/async/append.ts b/@coven/iterables/async/append.ts index b1cc282..34b5e4f 100644 --- a/@coven/iterables/async/append.ts +++ b/@coven/iterables/async/append.ts @@ -14,15 +14,16 @@ import { iteratorFunctionToAsyncIterableIterator } from "./iteratorFunctionToAsy * @param tailIterable Iterable or asynchronous to be appended. * @returns Curried generator function with `tailIterable` set in context. */ -export const append = ( - tailIterable: AwaitableIterable, -): ( - initialIterable: AwaitableIterable, -) => AsyncIterableIterator => -(initialIterable: AwaitableIterable) => - iteratorFunctionToAsyncIterableIterator( - async function* (): AsyncGenerator { - yield* initialIterable; - yield* tailIterable; - }, - ); +export const append = + ( + tailIterable: AwaitableIterable, + ): (( + initialIterable: AwaitableIterable, + ) => AsyncIterableIterator) => + (initialIterable: AwaitableIterable) => + iteratorFunctionToAsyncIterableIterator( + async function* (): AsyncGenerator { + yield* initialIterable; + yield* tailIterable; + }, + ); diff --git a/@coven/iterables/async/drop.ts b/@coven/iterables/async/drop.ts index e1ce64d..e3faa15 100644 --- a/@coven/iterables/async/drop.ts +++ b/@coven/iterables/async/drop.ts @@ -16,9 +16,9 @@ import { iteratorFunctionToAsyncIterableIterator } from "./iteratorFunctionToAsy */ export const drop = ( amount: number, -): ( +): (( iterable: AwaitableIterable, -) => Readonly>> => { +) => Readonly>>) => { const amountFilter = (iterable: AwaitableIterable) => { let count = -1; diff --git a/@coven/iterables/async/every.ts b/@coven/iterables/async/every.ts index d039fb4..1d73990 100644 --- a/@coven/iterables/async/every.ts +++ b/@coven/iterables/async/every.ts @@ -26,15 +26,16 @@ export const every: { ( predicate: Filter<[item: Item]>, ): AsyncFilter<[iterable: AwaitableIterable]>; -} = ( - predicate: Filter<[item: Item]>, -): AsyncFilter<[iterable: AwaitableIterable]> => -async (iterable) => { - for await (const item of iterable) { - if (!predicate(item)) { - return false; +} = + ( + predicate: Filter<[item: Item]>, + ): AsyncFilter<[iterable: AwaitableIterable]> => + async (iterable) => { + for await (const item of iterable) { + if (!predicate(item)) { + return false; + } } - } - return true; -}; + return true; + }; diff --git a/@coven/iterables/async/filter.ts b/@coven/iterables/async/filter.ts index 5a793cf..a8e668d 100644 --- a/@coven/iterables/async/filter.ts +++ b/@coven/iterables/async/filter.ts @@ -27,19 +27,20 @@ export const filter: { ( predicate: Filter<[item: Item]>, ): Unary<[iterable: AwaitableIterable], AsyncIterableIterator>; -} = ( - predicate: Filter<[item: Item]>, -): Unary< - [iterable: AwaitableIterable], - AsyncIterableIterator -> => -(iterable) => - iteratorFunctionToAsyncIterableIterator( - async function* (): AsyncGenerator { - for await (const item of iterable) { - if (predicate(item)) { - yield item; +} = + ( + predicate: Filter<[item: Item]>, + ): Unary< + [iterable: AwaitableIterable], + AsyncIterableIterator + > => + (iterable) => + iteratorFunctionToAsyncIterableIterator( + async function* (): AsyncGenerator { + for await (const item of iterable) { + if (predicate(item)) { + yield item; + } } - } - }, - ); + }, + ); diff --git a/@coven/iterables/async/find.ts b/@coven/iterables/async/find.ts index 9f457f1..3d5ec96 100644 --- a/@coven/iterables/async/find.ts +++ b/@coven/iterables/async/find.ts @@ -26,15 +26,16 @@ export const find: { ( predicate: Filter<[item: Item]>, ): AsyncUnary<[iterable: AwaitableIterable], Maybe>; -} = ( - predicate: Filter<[item: Item]>, -): AsyncUnary<[iterable: AwaitableIterable], Maybe> => -async (iterable): Promise> => { - for await (const item of iterable) { - if (predicate(item)) { - return item as Maybe; +} = + ( + predicate: Filter<[item: Item]>, + ): AsyncUnary<[iterable: AwaitableIterable], Maybe> => + async (iterable): Promise> => { + for await (const item of iterable) { + if (predicate(item)) { + return item as Maybe; + } } - } - return undefined; -}; + return undefined; + }; diff --git a/@coven/iterables/async/flat.ts b/@coven/iterables/async/flat.ts index 8de25b3..cc7fd77 100644 --- a/@coven/iterables/async/flat.ts +++ b/@coven/iterables/async/flat.ts @@ -14,25 +14,25 @@ import { iteratorFunctionToAsyncIterableIterator } from "./iteratorFunctionToAsy */ export const flat = ( iterable: Iterable, -): Iterable extends AwaitableIterable ? Readonly< - Item extends AwaitableIterable - ? AsyncIterableIterator - : AsyncIterableIterator +): Iterable extends AwaitableIterable ? + Readonly< + Item extends AwaitableIterable ? + AsyncIterableIterator + : AsyncIterableIterator > - : never => +: never => iteratorFunctionToAsyncIterableIterator( async function* (): AsyncGenerator { - for await ( - const iterableOrItem of iterable as AsyncIterable - ) { - isAwaitableIterable(iterableOrItem) - ? yield* iterableOrItem - : yield iterableOrItem; + for await (const iterableOrItem of iterable as AsyncIterable) { + isAwaitableIterable(iterableOrItem) ? + yield* iterableOrItem + : yield iterableOrItem; } }, - ) as Iterable extends AwaitableIterable ? Readonly< - Item extends AwaitableIterable - ? AsyncIterableIterator - : AsyncIterableIterator + ) as Iterable extends AwaitableIterable ? + Readonly< + Item extends AwaitableIterable ? + AsyncIterableIterator + : AsyncIterableIterator > - : never; + : never; diff --git a/@coven/iterables/async/forEach.ts b/@coven/iterables/async/forEach.ts index 0ea9a56..4aef864 100644 --- a/@coven/iterables/async/forEach.ts +++ b/@coven/iterables/async/forEach.ts @@ -12,11 +12,12 @@ import type { AwaitableEffect, AwaitableIterable } from "@coven/types"; * @param awaitableEffect Function to be called for every item of the iterable. * @returns Curried function that expects an iterable to loop over and has `callback` set in context. */ -export const forEach = ( - awaitableEffect: AwaitableEffect<[item: Item]>, -): AwaitableEffect<[iterable: AwaitableIterable]> => -async (iterable: AwaitableIterable) => { - for await (const item of iterable) { - await awaitableEffect(item); - } -}; +export const forEach = + ( + awaitableEffect: AwaitableEffect<[item: Item]>, + ): AwaitableEffect<[iterable: AwaitableIterable]> => + async (iterable: AwaitableIterable) => { + for await (const item of iterable) { + await awaitableEffect(item); + } + }; diff --git a/@coven/iterables/async/getIterator.ts b/@coven/iterables/async/getIterator.ts index 9397313..12d857f 100644 --- a/@coven/iterables/async/getIterator.ts +++ b/@coven/iterables/async/getIterator.ts @@ -18,15 +18,17 @@ import type { AwaitableIterable } from "@coven/types"; */ export const getIterator = ( iterable: Iterable, -): Iterable extends AwaitableIterable - ? Iterable extends AsyncIterable ? AsyncIterator - : Iterator - : never => +): Iterable extends AwaitableIterable ? + Iterable extends AsyncIterable ? + AsyncIterator + : Iterator +: never => (iterable as AsyncIterable)[ - (isIterable(iterable) - ? Symbol.iterator - : Symbol.asyncIterator) as keyof AsyncIterable - ]() as Iterable extends AwaitableIterable - ? Iterable extends AsyncIterable ? AsyncIterator - : Iterator - : never; + (isIterable(iterable) ? + Symbol.iterator + : Symbol.asyncIterator) as keyof AsyncIterable + ]() as Iterable extends AwaitableIterable ? + Iterable extends AsyncIterable ? + AsyncIterator + : Iterator + : never; diff --git a/@coven/iterables/async/groupBy.ts b/@coven/iterables/async/groupBy.ts index a9d5335..0e813e5 100644 --- a/@coven/iterables/async/groupBy.ts +++ b/@coven/iterables/async/groupBy.ts @@ -22,14 +22,14 @@ import { reduce } from "./reduce.ts"; */ export const groupBy = ( grouper: Unary<[item: Item], Key>, -): >( +): (>( iterable: Iterable, -) => Promise>>> => +) => Promise>>>) => reduce((item: Item) => { const group = grouper(item); return ((groups: ReadonlyRecord>>) => set(group)([...(groups[group] ?? EMPTY_ARRAY), item])(groups)) as ( - groups: ReadonlyRecord>>, - ) => ReadonlyRecord>; + groups: ReadonlyRecord>>, + ) => ReadonlyRecord>; })(EMPTY_OBJECT as ReadonlyRecord>); diff --git a/@coven/iterables/async/head.ts b/@coven/iterables/async/head.ts index 4b298dc..9051f35 100644 --- a/@coven/iterables/async/head.ts +++ b/@coven/iterables/async/head.ts @@ -21,9 +21,10 @@ export const head = ( iterable: Iterable, ): Promise< Iterable extends ReadonlyArray ? Head - : Maybe> -> => Promise.resolve(getIterator(iterable).next()).then( - ({ value }) => - value as Iterable extends ReadonlyArray ? Head - : Maybe>, -); + : Maybe> +> => + Promise.resolve(getIterator(iterable).next()).then( + ({ value }) => + value as Iterable extends ReadonlyArray ? Head + : Maybe>, + ); diff --git a/@coven/iterables/async/initial.ts b/@coven/iterables/async/initial.ts index 92f1f2d..6900ed2 100644 --- a/@coven/iterables/async/initial.ts +++ b/@coven/iterables/async/initial.ts @@ -24,7 +24,7 @@ export const initial = ( const iterator = getIterator(iterable); let item = await iterator.next(); - for (; !item.done;) { + for (; !item.done; ) { const value = item.value; // deno-lint-ignore no-await-in-loop diff --git a/@coven/iterables/async/intersperse.ts b/@coven/iterables/async/intersperse.ts index 9d85536..0091167 100644 --- a/@coven/iterables/async/intersperse.ts +++ b/@coven/iterables/async/intersperse.ts @@ -21,9 +21,9 @@ import { zip } from "./zip.ts"; */ export const intersperse = ( separator: Separator, -): ( +): (( iterable: AwaitableIterable, -) => AwaitableIterableIterator => { +) => AwaitableIterableIterator) => { const repeatSeparator = repeat(Infinity)(separator); return (iterable: AwaitableIterable) => diff --git a/@coven/iterables/async/iteratorFunctionToAsyncIterableIterator.ts b/@coven/iterables/async/iteratorFunctionToAsyncIterableIterator.ts index 12f651a..fb057e9 100644 --- a/@coven/iterables/async/iteratorFunctionToAsyncIterableIterator.ts +++ b/@coven/iterables/async/iteratorFunctionToAsyncIterableIterator.ts @@ -29,12 +29,12 @@ export const iteratorFunctionToAsyncIterableIterator = ( return { next: async (...next) => await iterator.next(...next), - ...(iterator.return - ? { return: async (value) => await iterator.return?.(value) } - : undefined), - ...(iterator.throw - ? { throw: async (error) => await iterator.throw?.(error) } - : undefined), + ...(iterator.return ? + { return: async (value) => await iterator.return?.(value) } + : undefined), + ...(iterator.throw ? + { throw: async (error) => await iterator.throw?.(error) } + : undefined), [Symbol.asyncIterator]: () => iteratorFunctionToAsyncIterableIterator(iteratorFunction), } as AsyncIterableIterator; diff --git a/@coven/iterables/async/join.ts b/@coven/iterables/async/join.ts index 39bf9fd..2458e60 100644 --- a/@coven/iterables/async/join.ts +++ b/@coven/iterables/async/join.ts @@ -14,18 +14,19 @@ import { reduce } from "./reduce.ts"; * @param separator String to use as separator. * @returns Curried function with `separator` in context. */ -export const join = ( - separator: Separator, -): ( - iterable: AwaitableIterable, -) => Promise<`${string}${Separator}${string}`> => -(iterable: AwaitableIterable) => { - let first = true; +export const join = + ( + separator: Separator, + ): (( + iterable: AwaitableIterable, + ) => Promise<`${string}${Separator}${string}`>) => + (iterable: AwaitableIterable) => { + let first = true; - return reduce( - (item) => (string) => - first - ? ((first = false), `${item}`) - : `${string}${separator}${item}`, - )("")(iterable) as Promise<`${string}${Separator}${string}`>; -}; + return reduce( + (item) => (string) => + first ? + ((first = false), `${item}`) + : `${string}${separator}${item}`, + )("")(iterable) as Promise<`${string}${Separator}${string}`>; + }; diff --git a/@coven/iterables/async/map.ts b/@coven/iterables/async/map.ts index 007d24c..5ea499e 100644 --- a/@coven/iterables/async/map.ts +++ b/@coven/iterables/async/map.ts @@ -14,17 +14,18 @@ import { iteratorFunctionToAsyncIterableIterator } from "./iteratorFunctionToAsy * @param mapper Mapper function. * @returns Generator function with `mapper` function set in context. */ -export const map = ( - mapper: Unary<[item: Item], MappedItem>, -): Unary< - [iterable: AwaitableIterable], - Readonly>> -> => -(iterable: AwaitableIterable) => - iteratorFunctionToAsyncIterableIterator( - async function* (): AsyncGenerator> { - for await (const item of iterable) { - yield mapper(item); - } - }, - ); +export const map = + ( + mapper: Unary<[item: Item], MappedItem>, + ): Unary< + [iterable: AwaitableIterable], + Readonly>> + > => + (iterable: AwaitableIterable) => + iteratorFunctionToAsyncIterableIterator( + async function* (): AsyncGenerator> { + for await (const item of iterable) { + yield mapper(item); + } + }, + ); diff --git a/@coven/iterables/async/prepend.ts b/@coven/iterables/async/prepend.ts index dca7564..d0e2e86 100644 --- a/@coven/iterables/async/prepend.ts +++ b/@coven/iterables/async/prepend.ts @@ -12,9 +12,11 @@ import { append } from "./append.ts"; * @param initialIterable Iterable or asynchronous iterable to be appended. * @returns Curried generator function with `initialIterable` set in context. */ -export const prepend = ( - initialIterable: AwaitableIterable, -): ( - tailIterable: AwaitableIterable, -) => AsyncIterableIterator => -(tailIterable) => append(tailIterable)(initialIterable); +export const prepend = + ( + initialIterable: AwaitableIterable, + ): (( + tailIterable: AwaitableIterable, + ) => AsyncIterableIterator) => + (tailIterable) => + append(tailIterable)(initialIterable); diff --git a/@coven/iterables/async/reduce.ts b/@coven/iterables/async/reduce.ts index a7ae519..9b2e4da 100644 --- a/@coven/iterables/async/reduce.ts +++ b/@coven/iterables/async/reduce.ts @@ -14,25 +14,26 @@ import { forEach } from "./forEach.ts"; * @param reducer Reducer function. * @returns Curried function with `reducer` in context. */ -export const reduce = ( - reducer: Unary< - [item: Item], - Unary<[accumulator: Accumulator], Awaitable> - >, -): Unary< - [initialValue: Accumulator], - >( - iterable: Iterable, - ) => Promise -> => -(initialValue: Accumulator) => -async >(iterable: Iterable) => { - let accumulator: Accumulator = initialValue; +export const reduce = + ( + reducer: Unary< + [item: Item], + Unary<[accumulator: Accumulator], Awaitable> + >, + ): Unary< + [initialValue: Accumulator], + >( + iterable: Iterable, + ) => Promise + > => + (initialValue: Accumulator) => + async >(iterable: Iterable) => { + let accumulator: Accumulator = initialValue; - await forEach( - async (item: Item) => - void (accumulator = await reducer(item)(accumulator)), - )(iterable); + await forEach( + async (item: Item) => + void (accumulator = await reducer(item)(accumulator)), + )(iterable); - return accumulator; -}; + return accumulator; + }; diff --git a/@coven/iterables/async/some.ts b/@coven/iterables/async/some.ts index 60f2608..ed15a41 100644 --- a/@coven/iterables/async/some.ts +++ b/@coven/iterables/async/some.ts @@ -26,15 +26,16 @@ export const some: { ( predicate: Filter<[item: Item]>, ): AsyncFilter<[iterable: AwaitableIterable]>; -} = ( - predicate: Filter<[item: Item]>, -): AsyncFilter<[iterable: AwaitableIterable]> => -async (iterable) => { - for await (const item of iterable) { - if (predicate(item)) { - return true; +} = + ( + predicate: Filter<[item: Item]>, + ): AsyncFilter<[iterable: AwaitableIterable]> => + async (iterable) => { + for await (const item of iterable) { + if (predicate(item)) { + return true; + } } - } - return false; -}; + return false; + }; diff --git a/@coven/iterables/async/take.ts b/@coven/iterables/async/take.ts index 23bec52..41e2bbd 100644 --- a/@coven/iterables/async/take.ts +++ b/@coven/iterables/async/take.ts @@ -12,25 +12,26 @@ import { iteratorFunctionToAsyncIterableIterator } from "./iteratorFunctionToAsy * @param amount Amount of items to take. * @returns Curried function with `amount` in context. */ -export const take = ( - amount: number, -): ( - iterable: AwaitableIterable, -) => Readonly> => -(iterable: AwaitableIterable) => - iteratorFunctionToAsyncIterableIterator( - async function* (): AsyncGenerator { - let count = 0n; +export const take = + ( + amount: number, + ): (( + iterable: AwaitableIterable, + ) => Readonly>) => + (iterable: AwaitableIterable) => + iteratorFunctionToAsyncIterableIterator( + async function* (): AsyncGenerator { + let count = 0n; - if (amount > 0) { - for await (const item of iterable) { - if (count < amount) { - yield item; - count += 1n; - } else { - return; + if (amount > 0) { + for await (const item of iterable) { + if (count < amount) { + yield item; + count += 1n; + } else { + return; + } } } - } - }, - ); + }, + ); diff --git a/@coven/iterables/async/tests/count.test.ts b/@coven/iterables/async/tests/count.test.ts index 0f1a667..4d5a6ba 100644 --- a/@coven/iterables/async/tests/count.test.ts +++ b/@coven/iterables/async/tests/count.test.ts @@ -11,10 +11,12 @@ Deno.test( ); Deno.test("Empty array and an even counter returns 0", async () => - assertEquals(await countEvens(EMPTY_ARRAY), 0)); + assertEquals(await countEvens(EMPTY_ARRAY), 0), +); Deno.test("Array of odd numbers and an even counter returns 0", async () => - assertEquals(await countEvens([1, 3, 5, 7]), 0)); + assertEquals(await countEvens([1, 3, 5, 7]), 0), +); Deno.test( "Array of mixed numbers and a counter with no filter returns full length", diff --git a/@coven/iterables/async/tests/every.test.ts b/@coven/iterables/async/tests/every.test.ts index f0e869a..08841be 100644 --- a/@coven/iterables/async/tests/every.test.ts +++ b/@coven/iterables/async/tests/every.test.ts @@ -7,13 +7,17 @@ const numbersArray = [0, 1, 2, 3]; const numbersWithStringArray = [0, 1, 2, "foo", 3]; Deno.test("Array of numbers returns true", async () => - assert(await everyNumbers(numbersArray))); + assert(await everyNumbers(numbersArray)), +); Deno.test("Array of numbers with a string on it returns false", async () => - assertFalse(await everyNumbers(numbersWithStringArray))); + assertFalse(await everyNumbers(numbersWithStringArray)), +); Deno.test("Iterable of numbers returns true", async () => - assert(await everyNumbers(toIterable(numbersArray)))); + assert(await everyNumbers(toIterable(numbersArray))), +); Deno.test("Iterable of numbers with a string on it returns false", async () => - assertFalse(await everyNumbers(toIterable(numbersWithStringArray)))); + assertFalse(await everyNumbers(toIterable(numbersWithStringArray))), +); diff --git a/@coven/iterables/async/tests/flat.test.ts b/@coven/iterables/async/tests/flat.test.ts index fae487d..16e491e 100644 --- a/@coven/iterables/async/tests/flat.test.ts +++ b/@coven/iterables/async/tests/flat.test.ts @@ -9,7 +9,8 @@ const arrayOfArrays = [ const arrayDeeper = [arrayOfArrays, arrayOfArrays]; Deno.test("an array that already is flat returns the same array", async () => - assertEquals(await iterableToArray(flat(array)), array)); + assertEquals(await iterableToArray(flat(array)), array), +); Deno.test( "an array of arrays and a depth of 1 returns a flattened array", diff --git a/@coven/iterables/async/tests/forEach.test.ts b/@coven/iterables/async/tests/forEach.test.ts index b036627..36ad860 100644 --- a/@coven/iterables/async/tests/forEach.test.ts +++ b/@coven/iterables/async/tests/forEach.test.ts @@ -12,13 +12,16 @@ const forEachTest = async (iterable: AwaitableIterable) => { }; Deno.test("a string loops over every letter of that string", async () => - assertEquals(await forEachTest("Lou"), [..."Lou"])); + assertEquals(await forEachTest("Lou"), [..."Lou"]), +); Deno.test("an array loops over every item of that array", async () => - assertEquals(await forEachTest(["🟢", "🟩"]), ["🟢", "🟩"])); + assertEquals(await forEachTest(["🟢", "🟩"]), ["🟢", "🟩"]), +); Deno.test("a generator loops over every yielded value", async () => assertEquals( await forEachTest(range(1)(0)(10)), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], - )); + ), +); diff --git a/@coven/iterables/async/tests/getIterator.test.ts b/@coven/iterables/async/tests/getIterator.test.ts index 4a0408f..6daa402 100644 --- a/@coven/iterables/async/tests/getIterator.test.ts +++ b/@coven/iterables/async/tests/getIterator.test.ts @@ -4,4 +4,5 @@ import { assertEquals } from "@std/assert"; const array = [0, 1, 2]; Deno.test("an array returns array's iterator", () => - assertEquals(getIterator(array), array[Symbol.iterator]())); + assertEquals(getIterator(array), array[Symbol.iterator]()), +); diff --git a/@coven/iterables/async/tests/groupBy.test.ts b/@coven/iterables/async/tests/groupBy.test.ts index 1115a2a..6bc5eb9 100644 --- a/@coven/iterables/async/tests/groupBy.test.ts +++ b/@coven/iterables/async/tests/groupBy.test.ts @@ -22,9 +22,9 @@ Deno.test( "Array of numbers and a grouper by even/odd groups bu evens/odss", async () => assertEquals( - await groupBy((value: number) => value % 2 === 0 ? "even" : "odd")( - numberArray, - ), + await groupBy((value: number) => + value % 2 === 0 ? "even" : "odd", + )(numberArray), { even: [0, 2], odd: [1, 3] }, ), ); diff --git a/@coven/iterables/async/tests/head.test.ts b/@coven/iterables/async/tests/head.test.ts index 5bb221b..605308c 100644 --- a/@coven/iterables/async/tests/head.test.ts +++ b/@coven/iterables/async/tests/head.test.ts @@ -6,13 +6,17 @@ import { assertEquals } from "@std/assert"; const array = [0, 1, 2]; Deno.test("Array returns array first element", async () => - assertEquals(await head(array), 0)); + assertEquals(await head(array), 0), +); Deno.test("Iterable returns iterable's first element", async () => - assertEquals(await head(range(1)(0)(2)), 0)); + assertEquals(await head(range(1)(0)(2)), 0), +); Deno.test("Empty array returns undefined", async () => - assertEquals(await head(EMPTY_ARRAY), undefined)); + assertEquals(await head(EMPTY_ARRAY), undefined), +); Deno.test("Empty iterable returns undefined", async () => - assertEquals(await head(drop(Infinity)(array)), undefined)); + assertEquals(await head(drop(Infinity)(array)), undefined), +); diff --git a/@coven/iterables/async/tests/initial.test.ts b/@coven/iterables/async/tests/initial.test.ts index 3c939e3..20f822d 100644 --- a/@coven/iterables/async/tests/initial.test.ts +++ b/@coven/iterables/async/tests/initial.test.ts @@ -6,16 +6,20 @@ import { assertEquals } from "@std/assert"; const array = [0, 1, 2]; Deno.test("Array returns initial items", async () => - assertEquals(await iterableToArray(initial(array)), [0, 1])); + assertEquals(await iterableToArray(initial(array)), [0, 1]), +); Deno.test("Iterable returns initial items", async () => - assertEquals(await iterableToArray(initial(range(1)(0)(2))), [0, 1])); + assertEquals(await iterableToArray(initial(range(1)(0)(2))), [0, 1]), +); Deno.test("Empty array returns empty array", async () => - assertEquals(await iterableToArray(initial(EMPTY_ARRAY)), EMPTY_ARRAY)); + assertEquals(await iterableToArray(initial(EMPTY_ARRAY)), EMPTY_ARRAY), +); Deno.test("Empty iterable returns empty array", async () => assertEquals( await iterableToArray(initial(drop(Infinity)(array))), EMPTY_ARRAY, - )); + ), +); diff --git a/@coven/iterables/async/tests/intersperse.test.ts b/@coven/iterables/async/tests/intersperse.test.ts index 8ac2e8f..cfe549a 100644 --- a/@coven/iterables/async/tests/intersperse.test.ts +++ b/@coven/iterables/async/tests/intersperse.test.ts @@ -16,7 +16,8 @@ Deno.test("Array returns interspersed items", async () => 1, ",", 2, - ])); + ]), +); Deno.test("Iterable returns interspersed items", async () => assertEquals(await iterableToArray(commaIntersperse(range(1)(0)(2))), [ @@ -25,16 +26,19 @@ Deno.test("Iterable returns interspersed items", async () => 1, ",", 2, - ])); + ]), +); Deno.test("Empty array returns empty iterable", async () => assertEquals( await iterableToArray(commaIntersperse(EMPTY_ARRAY)), EMPTY_ARRAY, - )); + ), +); Deno.test("Empty iterable returns empty iterable", async () => assertEquals( await iterableToArray(commaIntersperse(toIterable(EMPTY_ARRAY))), EMPTY_ARRAY, - )); + ), +); diff --git a/@coven/iterables/async/tests/iterableToArray.test.ts b/@coven/iterables/async/tests/iterableToArray.test.ts index 5e6f02e..311f7dd 100644 --- a/@coven/iterables/async/tests/iterableToArray.test.ts +++ b/@coven/iterables/async/tests/iterableToArray.test.ts @@ -8,10 +8,12 @@ Deno.test( ); Deno.test("an array returns that same array", async () => - assertEquals(await iterableToArray(["🟢", "🟩"]), ["🟢", "🟩"])); + assertEquals(await iterableToArray(["🟢", "🟩"]), ["🟢", "🟩"]), +); Deno.test("a generator returns an array with generated values", async () => assertEquals( await iterableToArray(range(1)(0)(10)), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], - )); + ), +); diff --git a/@coven/iterables/async/tests/join.test.ts b/@coven/iterables/async/tests/join.test.ts index 973358e..67947af 100644 --- a/@coven/iterables/async/tests/join.test.ts +++ b/@coven/iterables/async/tests/join.test.ts @@ -16,10 +16,12 @@ Deno.test( ); Deno.test("Empty array returns empty string", async () => - assertEquals(await spaceJoin(EMPTY_ARRAY), "")); + assertEquals(await spaceJoin(EMPTY_ARRAY), ""), +); Deno.test("Empty iterable returns empty string", async () => - assertEquals(await spaceJoin(toIterable(EMPTY_ARRAY)), "")); + assertEquals(await spaceJoin(toIterable(EMPTY_ARRAY)), ""), +); Deno.test( "Iterable with empty strings returns spaces for each value", diff --git a/@coven/iterables/async/tests/length.test.ts b/@coven/iterables/async/tests/length.test.ts index 513c908..7548d1a 100644 --- a/@coven/iterables/async/tests/length.test.ts +++ b/@coven/iterables/async/tests/length.test.ts @@ -4,13 +4,17 @@ import { length, toIterable } from "@coven/iterables/async"; import { assertEquals } from "@std/assert"; Deno.test("Array returns length", async () => - assertEquals(await length([0, 1, 2]), 3)); + assertEquals(await length([0, 1, 2]), 3), +); Deno.test("Iterable returns length", async () => - assertEquals(await length(range(1)(0)(2)), 3)); + assertEquals(await length(range(1)(0)(2)), 3), +); Deno.test("Empty array returns 0", async () => - assertEquals(await length(EMPTY_ARRAY), 0)); + assertEquals(await length(EMPTY_ARRAY), 0), +); Deno.test("Empty iterable returns 0", async () => - assertEquals(await length(toIterable(EMPTY_ARRAY)), 0)); + assertEquals(await length(toIterable(EMPTY_ARRAY)), 0), +); diff --git a/@coven/iterables/async/tests/some.test.ts b/@coven/iterables/async/tests/some.test.ts index bf09eec..23a9e74 100644 --- a/@coven/iterables/async/tests/some.test.ts +++ b/@coven/iterables/async/tests/some.test.ts @@ -5,19 +5,25 @@ import { assert, assertFalse } from "@std/assert"; const someNumber = some(isNumber); Deno.test("Array of numbers returns true", async () => - assert(await someNumber([0, 1, 2, 3]))); + assert(await someNumber([0, 1, 2, 3])), +); Deno.test("Array of numbers with a string on it returns true", async () => - assert(await someNumber([0, 1, 2, "foo", 3]))); + assert(await someNumber([0, 1, 2, "foo", 3])), +); Deno.test("Array of strings returns false", async () => - assertFalse(await someNumber(["foo", "bar"]))); + assertFalse(await someNumber(["foo", "bar"])), +); Deno.test("Iterable of numbers returns true", async () => - assert(await someNumber(toIterable([0, 1, 2, 3])))); + assert(await someNumber(toIterable([0, 1, 2, 3]))), +); Deno.test("Iterable of numbers with a string on it returns true", async () => - assert(await someNumber(toIterable([0, 1, 2, "foo", 3])))); + assert(await someNumber(toIterable([0, 1, 2, "foo", 3]))), +); Deno.test("Iterable of strings returns false", async () => - assertFalse(await someNumber(toIterable(["foo", "bar"])))); + assertFalse(await someNumber(toIterable(["foo", "bar"]))), +); diff --git a/@coven/iterables/async/tests/toIterable.test.ts b/@coven/iterables/async/tests/toIterable.test.ts index dd1036e..a210925 100644 --- a/@coven/iterables/async/tests/toIterable.test.ts +++ b/@coven/iterables/async/tests/toIterable.test.ts @@ -2,13 +2,16 @@ import { iterableToArray, toIterable } from "@coven/iterables/async"; import { assertEquals } from "@std/assert"; Deno.test("an array returns iterable of array", async () => - assertEquals(await iterableToArray([0, 1, 2, 3, 4]), [0, 1, 2, 3, 4])); + assertEquals(await iterableToArray([0, 1, 2, 3, 4]), [0, 1, 2, 3, 4]), +); Deno.test("a string returns iterable of string", async () => assertEquals( await typeof toIterable("test")[Symbol.asyncIterator], "function", - )); + ), +); Deno.test("a number returns iterable of number", async () => - assertEquals(await iterableToArray(toIterable(1)), [1])); + assertEquals(await iterableToArray(toIterable(1)), [1]), +); diff --git a/@coven/iterables/async/tests/unique.test.ts b/@coven/iterables/async/tests/unique.test.ts index c2eb074..07d43c2 100644 --- a/@coven/iterables/async/tests/unique.test.ts +++ b/@coven/iterables/async/tests/unique.test.ts @@ -14,7 +14,9 @@ Deno.test( ); Deno.test("an array without duplicated elements returns same array", async () => - assertEquals(await iterableToArray(unique(array)), array)); + assertEquals(await iterableToArray(unique(array)), array), +); Deno.test("an empty array returns same array", async () => - assertEquals(await iterableToArray(unique(EMPTY_ARRAY)), EMPTY_ARRAY)); + assertEquals(await iterableToArray(unique(EMPTY_ARRAY)), EMPTY_ARRAY), +); diff --git a/@coven/iterables/async/tests/zip.test.ts b/@coven/iterables/async/tests/zip.test.ts index c7a3356..543181e 100644 --- a/@coven/iterables/async/tests/zip.test.ts +++ b/@coven/iterables/async/tests/zip.test.ts @@ -5,7 +5,8 @@ import { assertEquals } from "@std/assert"; const zipFooBar = zip(toIterable(["foo", "bar"])); Deno.test("zip empty array returns empty array", async () => - assertEquals(await iterableToArray(zipFooBar(EMPTY_ARRAY)), EMPTY_ARRAY)); + assertEquals(await iterableToArray(zipFooBar(EMPTY_ARRAY)), EMPTY_ARRAY), +); Deno.test( "zip with 2 strings an array with 2 numbers zips numbers and strings", diff --git a/@coven/iterables/async/tests/zipIndex.test.ts b/@coven/iterables/async/tests/zipIndex.test.ts index 0e0ba25..f1c2f3d 100644 --- a/@coven/iterables/async/tests/zipIndex.test.ts +++ b/@coven/iterables/async/tests/zipIndex.test.ts @@ -13,7 +13,8 @@ Deno.test( ); Deno.test("Empty array empties iterable", async () => - assertEquals(await iterableToArray(zipIndex(EMPTY_ARRAY)), EMPTY_ARRAY)); + assertEquals(await iterableToArray(zipIndex(EMPTY_ARRAY)), EMPTY_ARRAY), +); Deno.test( "Iterable of strings returns Iterable of tuples with indexes and strings", diff --git a/@coven/iterables/async/toIterable.ts b/@coven/iterables/async/toIterable.ts index 18676f2..8ec2c20 100644 --- a/@coven/iterables/async/toIterable.ts +++ b/@coven/iterables/async/toIterable.ts @@ -23,17 +23,16 @@ import { iteratorFunctionToAsyncIterableIterator } from "./iteratorFunctionToAsy export const toIterable = ( valueOrIterable: ValueOrAsyncIterable, ): AsyncIterableIterator< - ValueOrAsyncIterable extends AwaitableIterable - ? IterableItem - : ValueOrAsyncIterable -> => iteratorFunctionToAsyncIterableIterator( - async function* (): AsyncGenerator { - isAwaitableIterable(valueOrIterable) - ? yield* valueOrIterable - : yield valueOrIterable; + ValueOrAsyncIterable extends AwaitableIterable ? + IterableItem + : ValueOrAsyncIterable +> => + iteratorFunctionToAsyncIterableIterator(async function* (): AsyncGenerator { + isAwaitableIterable(valueOrIterable) ? + yield* valueOrIterable + : yield valueOrIterable; } as () => AsyncGenerator< - ValueOrAsyncIterable extends AwaitableIterable - ? IterableItem - : ValueOrAsyncIterable - >, -); + ValueOrAsyncIterable extends AwaitableIterable ? + IterableItem + : ValueOrAsyncIterable + >); diff --git a/@coven/iterables/async/zip.ts b/@coven/iterables/async/zip.ts index 893c0aa..d3e3f03 100644 --- a/@coven/iterables/async/zip.ts +++ b/@coven/iterables/async/zip.ts @@ -15,27 +15,28 @@ import { iteratorFunctionToAsyncIterableIterator } from "./iteratorFunctionToAsy * @param iterableFirst One of the iterables to be zipped. * @returns Curried function with `iterableFirst` in context. */ -export const zip = ( - iterableFirst: AwaitableIterable, -): ( - iterableSecond: AwaitableIterable, -) => AsyncIterableIterator> => -(iterableSecond: AwaitableIterable) => - iteratorFunctionToAsyncIterableIterator( - async function* (): AsyncGenerator< - Readonly<[ItemFirst, ItemSecond]> - > { - const asyncIteratorSecond = getIterator(iterableSecond); +export const zip = + ( + iterableFirst: AwaitableIterable, + ): (( + iterableSecond: AwaitableIterable, + ) => AsyncIterableIterator>) => + (iterableSecond: AwaitableIterable) => + iteratorFunctionToAsyncIterableIterator( + async function* (): AsyncGenerator< + Readonly<[ItemFirst, ItemSecond]> + > { + const asyncIteratorSecond = getIterator(iterableSecond); - for await (const itemFirst of iterableFirst) { - const { done = false, value } = await asyncIteratorSecond - .next(); + for await (const itemFirst of iterableFirst) { + const { done = false, value } = + await asyncIteratorSecond.next(); - if (done) { - return; - } + if (done) { + return; + } - yield [itemFirst as ItemFirst, value] as const; - } - }, - ); + yield [itemFirst as ItemFirst, value] as const; + } + }, + ); diff --git a/@coven/iterables/drop.ts b/@coven/iterables/drop.ts index 5fb9ea4..a2589bb 100644 --- a/@coven/iterables/drop.ts +++ b/@coven/iterables/drop.ts @@ -12,10 +12,11 @@ import { iteratorFunctionToIterableIterator } from "./iteratorFunctionToIterable * @param amount Amount of items to drop. * @returns Curried function with `amount` in context. */ -export const drop = ( - amount: number, -): (iterable: Iterable) => IterableIterator => -(iterable: Iterable) => - iteratorFunctionToIterableIterator(() => - getIterator(iterable).drop(amount) - ); +export const drop = + ( + amount: number, + ): ((iterable: Iterable) => IterableIterator) => + (iterable: Iterable) => + iteratorFunctionToIterableIterator(() => + getIterator(iterable).drop(amount), + ); diff --git a/@coven/iterables/every.ts b/@coven/iterables/every.ts index ab16f6b..fd85814 100644 --- a/@coven/iterables/every.ts +++ b/@coven/iterables/every.ts @@ -14,13 +14,11 @@ import { getIterator } from "./getIterator.ts"; * @param predicate Predicate function to evaluate each item. * @returns Curried function with `predicate` set in context. */ -export const every = - ((predicate: Filter<[item: Item]>) => (iterable: Iterable) => +export const every = ((predicate: Filter<[item: Item]>) => + (iterable: Iterable) => getIterator(iterable).every(predicate)) as { - ( - predicate: Predicate, - ): Predicate, Iterable>; - ( - predicate: Filter<[item: Item]>, - ): Filter<[iterable: Iterable]>; - }; + ( + predicate: Predicate, + ): Predicate, Iterable>; + (predicate: Filter<[item: Item]>): Filter<[iterable: Iterable]>; +}; diff --git a/@coven/iterables/filter.ts b/@coven/iterables/filter.ts index daff930..42cf4e9 100644 --- a/@coven/iterables/filter.ts +++ b/@coven/iterables/filter.ts @@ -25,10 +25,11 @@ export const filter: { ( predicate: Filter<[item: Item]>, ): Unary<[iterable: Iterable], IterableIterator>; -} = ( - predicate: Filter<[item: Item]>, -): Unary<[iterable: Iterable], IterableIterator> => -(iterable) => - iteratorFunctionToIterableIterator(() => - getIterator(iterable).filter(predicate) - ); +} = + ( + predicate: Filter<[item: Item]>, + ): Unary<[iterable: Iterable], IterableIterator> => + (iterable) => + iteratorFunctionToIterableIterator(() => + getIterator(iterable).filter(predicate), + ); diff --git a/@coven/iterables/find.ts b/@coven/iterables/find.ts index 4848239..734fda6 100644 --- a/@coven/iterables/find.ts +++ b/@coven/iterables/find.ts @@ -14,7 +14,9 @@ import { getIterator } from "./getIterator.ts"; * @param predicate Predicate function to search for item. * @returns Curried function with `predicate` set in context. */ -export const find = ( - predicate: Filter<[item: Item]>, -): Unary<[iterable: Iterable], Maybe> => -(iterable) => getIterator(iterable).find(predicate) as Maybe; +export const find = + ( + predicate: Filter<[item: Item]>, + ): Unary<[iterable: Iterable], Maybe> => + (iterable) => + getIterator(iterable).find(predicate) as Maybe; diff --git a/@coven/iterables/flat.ts b/@coven/iterables/flat.ts index 4eb32d4..5c7a7d0 100644 --- a/@coven/iterables/flat.ts +++ b/@coven/iterables/flat.ts @@ -13,17 +13,19 @@ import { iteratorFunctionToIterableIterator } from "./iteratorFunctionToIterable */ export const flat = >( iterable: IterableToFlat, -): IterableToFlat extends Iterable - ? Item extends Iterable ? IterableIterator - : IterableIterator - : never => +): IterableToFlat extends Iterable ? + Item extends Iterable ? + IterableIterator + : IterableIterator +: never => iteratorFunctionToIterableIterator(function* (): Generator { for (const iterableOrItem of iterable) { - isIterable(iterableOrItem) - ? yield* iterableOrItem - : yield iterableOrItem; + isIterable(iterableOrItem) ? + yield* iterableOrItem + : yield iterableOrItem; } - }) as IterableToFlat extends Iterable - ? Item extends Iterable ? IterableIterator - : IterableIterator - : never; + }) as IterableToFlat extends Iterable ? + Item extends Iterable ? + IterableIterator + : IterableIterator + : never; diff --git a/@coven/iterables/forEach.ts b/@coven/iterables/forEach.ts index 863287c..adb1fab 100644 --- a/@coven/iterables/forEach.ts +++ b/@coven/iterables/forEach.ts @@ -15,4 +15,5 @@ import { getIterator } from "./getIterator.ts"; */ export const forEach = (effect: Effect<[item: Item]>): Effect<[iterable: Iterable]> => - (iterable) => getIterator(iterable).forEach(effect); + (iterable) => + getIterator(iterable).forEach(effect); diff --git a/@coven/iterables/groupBy.ts b/@coven/iterables/groupBy.ts index 4b5a08d..2151463 100644 --- a/@coven/iterables/groupBy.ts +++ b/@coven/iterables/groupBy.ts @@ -20,11 +20,12 @@ export const groupBy = ( ): Unary< [iterable: Iterable], Readonly>> -> => reduce((item: Item) => { - const group = grouper(item); +> => + reduce((item: Item) => { + const group = grouper(item); - return ((groups: ReadonlyRecord>>) => - set(group)([...(groups[group] ?? EMPTY_ARRAY), item])(groups)) as ( + return ((groups: ReadonlyRecord>>) => + set(group)([...(groups[group] ?? EMPTY_ARRAY), item])(groups)) as ( groups: ReadonlyRecord>>, ) => ReadonlyRecord>; -})(EMPTY_OBJECT as ReadonlyRecord>); + })(EMPTY_OBJECT as ReadonlyRecord>); diff --git a/@coven/iterables/head.ts b/@coven/iterables/head.ts index 0dce3ab..4438b6d 100644 --- a/@coven/iterables/head.ts +++ b/@coven/iterables/head.ts @@ -14,8 +14,9 @@ import { getIterator } from "./getIterator.ts"; export const head = >( iterable: IterableToGetHead, ): IterableToGetHead extends ReadonlyArray ? Head - : Maybe> => +: Maybe> => getIterator(iterable).next().value as IterableToGetHead extends ( ReadonlyArray - ) ? Head - : Maybe>; + ) ? + Head + : Maybe>; diff --git a/@coven/iterables/initial.ts b/@coven/iterables/initial.ts index 0969e7f..84b0ce9 100644 --- a/@coven/iterables/initial.ts +++ b/@coven/iterables/initial.ts @@ -15,27 +15,28 @@ import { iteratorFunctionToIterableIterator } from "./iteratorFunctionToIterable export const initial = >( iterable: IterableToGetInitial, ): IterableIterator< - IterableToGetInitial extends ReadonlyArray - ? Initial extends ReadonlyArray - ? Initial[number] - : IterableItem - : IterableItem -> => iteratorFunctionToIterableIterator(function* (): Generator { - const iterator = getIterator(iterable); + IterableToGetInitial extends ReadonlyArray ? + Initial extends ReadonlyArray ? + Initial[number] + : IterableItem + : IterableItem +> => + iteratorFunctionToIterableIterator(function* (): Generator { + const iterator = getIterator(iterable); - let item = iterator.next(); + let item = iterator.next(); - for (; !item.done;) { - const value = item.value; + for (; !item.done; ) { + const value = item.value; - item = iterator.next(); + item = iterator.next(); - item.done ? undefined : yield value; - } -}) as IterableIterator< - IterableToGetInitial extends ReadonlyArray - ? Initial extends ReadonlyArray - ? Initial[number] - : IterableItem - : IterableItem ->; + item.done ? undefined : yield value; + } + }) as IterableIterator< + IterableToGetInitial extends ReadonlyArray ? + Initial extends ReadonlyArray ? + Initial[number] + : IterableItem + : IterableItem + >; diff --git a/@coven/iterables/intersperse.ts b/@coven/iterables/intersperse.ts index c49ff4f..4ba6071 100644 --- a/@coven/iterables/intersperse.ts +++ b/@coven/iterables/intersperse.ts @@ -16,7 +16,7 @@ import { zip } from "./zip.ts"; */ export const intersperse = ( separator: Separator, -): (iterable: Iterable) => IterableIterator => { +): ((iterable: Iterable) => IterableIterator) => { const repeatSeparator = repeat(Infinity)(separator); return (iterable: Iterable) => { diff --git a/@coven/iterables/iteratorFunctionToIterableIterator.ts b/@coven/iterables/iteratorFunctionToIterableIterator.ts index 638ac0b..b67fa45 100644 --- a/@coven/iterables/iteratorFunctionToIterableIterator.ts +++ b/@coven/iterables/iteratorFunctionToIterableIterator.ts @@ -28,12 +28,12 @@ export const iteratorFunctionToIterableIterator = ( return { next: iterator.next.bind(iterator), - ...(iterator.return - ? { return: iterator.return.bind(iterator) } - : undefined), - ...(iterator.throw - ? { throw: iterator.throw.bind(iterator) } - : undefined), + ...(iterator.return ? + { return: iterator.return.bind(iterator) } + : undefined), + ...(iterator.throw ? + { throw: iterator.throw.bind(iterator) } + : undefined), [Symbol.iterator]: () => iteratorFunctionToIterableIterator(iteratorFunction), } as IterableIterator; diff --git a/@coven/iterables/join.ts b/@coven/iterables/join.ts index 6978ec9..43b2d52 100644 --- a/@coven/iterables/join.ts +++ b/@coven/iterables/join.ts @@ -13,18 +13,19 @@ import { reduce } from "./reduce.ts"; * @param separator String to use as separator. * @returns Curried function with `separator` in context. */ -export const join = ( - separator: Separator, -): ( - iterable: Iterable, -) => `${string}${Separator}${string}` => -(iterable: Iterable) => { - let first = true; +export const join = + ( + separator: Separator, + ): (( + iterable: Iterable, + ) => `${string}${Separator}${string}`) => + (iterable: Iterable) => { + let first = true; - return reduce( - (item) => (string) => - first - ? ((first = false), `${item}`) - : `${string}${separator}${item}`, - )("")(iterable) as `${string}${Separator}${string}`; -}; + return reduce( + (item) => (string) => + first ? + ((first = false), `${item}`) + : `${string}${separator}${item}`, + )("")(iterable) as `${string}${Separator}${string}`; + }; diff --git a/@coven/iterables/map.ts b/@coven/iterables/map.ts index 4807f67..0398d1d 100644 --- a/@coven/iterables/map.ts +++ b/@coven/iterables/map.ts @@ -15,8 +15,11 @@ import { iteratorFunctionToIterableIterator } from "./iteratorFunctionToIterable * @param mapper Mapper function. * @returns Generator function with `mapper` function set in context. */ -export const map = ( - mapper: Unary<[item: Item], MappedItem>, -): Unary<[iterable: Iterable], IterableIterator> => -(iterable: Iterable) => - iteratorFunctionToIterableIterator(() => getIterator(iterable).map(mapper)); +export const map = + ( + mapper: Unary<[item: Item], MappedItem>, + ): Unary<[iterable: Iterable], IterableIterator> => + (iterable: Iterable) => + iteratorFunctionToIterableIterator(() => + getIterator(iterable).map(mapper), + ); diff --git a/@coven/iterables/prepend.ts b/@coven/iterables/prepend.ts index f31d35c..c412e60 100644 --- a/@coven/iterables/prepend.ts +++ b/@coven/iterables/prepend.ts @@ -11,9 +11,11 @@ import { append } from "./append.ts"; * @param initialIterable Iterable to be appended. * @returns Curried generator function with `initialIterable` set in context. */ -export const prepend = ( - initialIterable: Iterable, -): ( - tailIterable: Iterable, -) => IterableIterator => -(tailIterable) => append(tailIterable)(initialIterable); +export const prepend = + ( + initialIterable: Iterable, + ): (( + tailIterable: Iterable, + ) => IterableIterator) => + (tailIterable) => + append(tailIterable)(initialIterable); diff --git a/@coven/iterables/random.ts b/@coven/iterables/random.ts index 3dde170..5c7562f 100644 --- a/@coven/iterables/random.ts +++ b/@coven/iterables/random.ts @@ -19,16 +19,16 @@ import { iteratorFunctionToIterableIterator } from "./iteratorFunctionToIterable * @param seed Seed to be used to generate random numbers. * @returns Curried generator function with `seed` set in context. */ -export const random = ( - seed: Stringable, -): Unary< - [from: number], - Unary<[to: number], Readonly>> -> => -(from) => -(to) => - iteratorFunctionToIterableIterator( - function* (): Generator { +export const random = + ( + seed: Stringable, + ): Unary< + [from: number], + Unary<[to: number], Readonly>> + > => + (from) => + (to) => + iteratorFunctionToIterableIterator(function* (): Generator { let state: string | number = `${seed}`; const min = from < to ? from : to; const max = from > to ? from : to; @@ -36,15 +36,13 @@ export const random = ( for (;;) { yield Math.min( Math.max( - state = (seededRandom( - `${state}(${min}-${max})`, - )) + (state = + seededRandom(`${state}(${min}-${max})`) * (max + 2 - min) - + (min - 1), + + (min - 1)), min, ), max, ); } - }, - ); + }); diff --git a/@coven/iterables/range.ts b/@coven/iterables/range.ts index 90f5742..c03f661 100644 --- a/@coven/iterables/range.ts +++ b/@coven/iterables/range.ts @@ -30,6 +30,6 @@ export const range = ( yield current; } } - }) - ) + }), + ), ); diff --git a/@coven/iterables/reduce.ts b/@coven/iterables/reduce.ts index e1f2af2..f342842 100644 --- a/@coven/iterables/reduce.ts +++ b/@coven/iterables/reduce.ts @@ -14,18 +14,19 @@ import { getIterator } from "./getIterator.ts"; * @param reducer Reducer function. * @returns Curried function with `reducer` in context. */ -export const reduce = ( - reducer: Unary< - [item: Item], - Unary<[accumulator: Accumulator], Accumulator> - >, -): Unary< - [initialValue: Accumulator], - Unary<[iterable: Iterable], Accumulator> -> => -(initialValue) => -(iterable) => - getIterator(iterable).reduce( - (accumulator, item) => reducer(item)(accumulator), - initialValue, - ); +export const reduce = + ( + reducer: Unary< + [item: Item], + Unary<[accumulator: Accumulator], Accumulator> + >, + ): Unary< + [initialValue: Accumulator], + Unary<[iterable: Iterable], Accumulator> + > => + (initialValue) => + (iterable) => + getIterator(iterable).reduce( + (accumulator, item) => reducer(item)(accumulator), + initialValue, + ); diff --git a/@coven/iterables/repeat.ts b/@coven/iterables/repeat.ts index d46698b..15ad175 100644 --- a/@coven/iterables/repeat.ts +++ b/@coven/iterables/repeat.ts @@ -16,17 +16,17 @@ import { iteratorFunctionToIterableIterator } from "./iteratorFunctionToIterable export const repeat: ( times: number, ) => (item: Item) => IterableIterator = memo( - (times): (item: Item) => IterableIterator => - (item: Item) => - iteratorFunctionToIterableIterator(function* (): Generator { - if (times === Infinity) { - for (;;) { - yield item; + (times): ((item: Item) => IterableIterator) => + (item: Item) => + iteratorFunctionToIterableIterator(function* (): Generator { + if (times === Infinity) { + for (;;) { + yield item; + } + } else { + for (let count = 0n; count < times; count += 1n) { + yield item; + } } - } else { - for (let count = 0n; count < times; count += 1n) { - yield item; - } - } - }), + }), ); diff --git a/@coven/iterables/some.ts b/@coven/iterables/some.ts index 4526f97..3127604 100644 --- a/@coven/iterables/some.ts +++ b/@coven/iterables/some.ts @@ -15,10 +15,12 @@ import { getIterator } from "./getIterator.ts"; * @returns Curried function with `predicate` set in context. */ export const some = (( - predicate: Single extends Single ? Filter<[item: Item]> - : Predicate, -): Filter<[iterable: Iterable]> => -(iterable: Iterable) => getIterator(iterable).some(predicate)) as { + predicate: Single extends Single ? + Filter<[item: Item]> + : Predicate, + ): Filter<[iterable: Iterable]> => + (iterable: Iterable) => + getIterator(iterable).some(predicate)) as { ( predicate: Predicate, ): Predicate, Iterable>; diff --git a/@coven/iterables/take.ts b/@coven/iterables/take.ts index bfd2ad8..de7536d 100644 --- a/@coven/iterables/take.ts +++ b/@coven/iterables/take.ts @@ -12,10 +12,11 @@ import { iteratorFunctionToIterableIterator } from "./iteratorFunctionToIterable * @param amount Amount of items to take. * @returns Curried function with `amount` in context. */ -export const take = ( - amount: number, -): (iterable: Iterable) => IterableIterator => -(iterable: Iterable) => - iteratorFunctionToIterableIterator(() => - getIterator(iterable).take(amount) - ); +export const take = + ( + amount: number, + ): ((iterable: Iterable) => IterableIterator) => + (iterable: Iterable) => + iteratorFunctionToIterableIterator(() => + getIterator(iterable).take(amount), + ); diff --git a/@coven/iterables/tests/count.test.ts b/@coven/iterables/tests/count.test.ts index 3cf7cc9..fda1c09 100644 --- a/@coven/iterables/tests/count.test.ts +++ b/@coven/iterables/tests/count.test.ts @@ -11,10 +11,12 @@ Deno.test( ); Deno.test("Empty array and an even counter returns 0", () => - assertEquals(countEvens(EMPTY_ARRAY), 0)); + assertEquals(countEvens(EMPTY_ARRAY), 0), +); Deno.test("Array of odd numbers and an even counter returns 0", () => - assertEquals(countEvens([1, 3, 5, 7]), 0)); + assertEquals(countEvens([1, 3, 5, 7]), 0), +); Deno.test( "Array of mixed numbers and a counter with no filter returns full length", diff --git a/@coven/iterables/tests/every.test.ts b/@coven/iterables/tests/every.test.ts index 35ce616..35c35e7 100644 --- a/@coven/iterables/tests/every.test.ts +++ b/@coven/iterables/tests/every.test.ts @@ -7,13 +7,17 @@ const numbersArray = [0, 1, 2, 3]; const numbersWithStringArray = [0, 1, 2, "foo", 3]; Deno.test("Array of numbers returns true", () => - assert(everyNumbers(numbersArray))); + assert(everyNumbers(numbersArray)), +); Deno.test("Array of numbers with a string on it returns false", () => - assertFalse(everyNumbers(numbersWithStringArray))); + assertFalse(everyNumbers(numbersWithStringArray)), +); Deno.test("Iterable of numbers returns true", () => - assert(everyNumbers(Iterator.from(numbersArray)))); + assert(everyNumbers(Iterator.from(numbersArray))), +); Deno.test("Iterable of numbers with a string on it returns false", () => - assertFalse(everyNumbers(Iterator.from(numbersWithStringArray)))); + assertFalse(everyNumbers(Iterator.from(numbersWithStringArray))), +); diff --git a/@coven/iterables/tests/flat.test.ts b/@coven/iterables/tests/flat.test.ts index 63fe33a..2120321 100644 --- a/@coven/iterables/tests/flat.test.ts +++ b/@coven/iterables/tests/flat.test.ts @@ -9,10 +9,12 @@ const arrayOfArrays = [ const arrayDeeper = [arrayOfArrays, arrayOfArrays]; Deno.test("an array that already is flat returns the same array", () => - assertEquals(iterableToArray(flat(array)), array)); + assertEquals(iterableToArray(flat(array)), array), +); Deno.test("an array of arrays and a depth of 1 returns a flattened array", () => - assertEquals(iterableToArray(flat(arrayOfArrays)), [0, 1, 2, 3])); + assertEquals(iterableToArray(flat(arrayOfArrays)), [0, 1, 2, 3]), +); Deno.test( "an array arrays of arrays and a depth of 1 returns an array of arrays", diff --git a/@coven/iterables/tests/forEach.test.ts b/@coven/iterables/tests/forEach.test.ts index 9a48a9c..51db311 100644 --- a/@coven/iterables/tests/forEach.test.ts +++ b/@coven/iterables/tests/forEach.test.ts @@ -10,13 +10,16 @@ const forEachTest = (iterable: Iterable) => { }; Deno.test("a string loops over every letter of that string", () => - assertEquals(forEachTest("Coven"), [..."Coven"])); + assertEquals(forEachTest("Coven"), [..."Coven"]), +); Deno.test("an array loops over every item of that array", () => - assertEquals(forEachTest(["🧙🏻", "🎃"]), ["🧙🏻", "🎃"])); + assertEquals(forEachTest(["🧙🏻", "🎃"]), ["🧙🏻", "🎃"]), +); Deno.test("a generator loops over every yielded value", () => assertEquals( forEachTest(range(1)(0)(10)), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], - )); + ), +); diff --git a/@coven/iterables/tests/getIterator.test.ts b/@coven/iterables/tests/getIterator.test.ts index 5bc9f5f..4b0b9d1 100644 --- a/@coven/iterables/tests/getIterator.test.ts +++ b/@coven/iterables/tests/getIterator.test.ts @@ -4,4 +4,5 @@ import { assertEquals } from "@std/assert"; const array = [0, 1, 2] as const; Deno.test("an array returns array's iterator", () => - assertEquals(getIterator(array), array[Symbol.iterator]())); + assertEquals(getIterator(array), array[Symbol.iterator]()), +); diff --git a/@coven/iterables/tests/head.test.ts b/@coven/iterables/tests/head.test.ts index 480d729..c8745ce 100644 --- a/@coven/iterables/tests/head.test.ts +++ b/@coven/iterables/tests/head.test.ts @@ -5,13 +5,17 @@ import { assertEquals } from "@std/assert"; const array = [0, 1, 2]; Deno.test("Array returns array first element", () => - assertEquals(head(array), 0)); + assertEquals(head(array), 0), +); Deno.test("Iterable returns iterable's first element", () => - assertEquals(head(range(1)(0)(2)), 0)); + assertEquals(head(range(1)(0)(2)), 0), +); Deno.test("Empty array returns undefined", () => - assertEquals(head(EMPTY_ARRAY), undefined)); + assertEquals(head(EMPTY_ARRAY), undefined), +); Deno.test("Empty iterable returns undefined", () => - assertEquals(head(drop(Infinity)(array)), undefined)); + assertEquals(head(drop(Infinity)(array)), undefined), +); diff --git a/@coven/iterables/tests/includes.test.ts b/@coven/iterables/tests/includes.test.ts index 9fa6b2d..40335d0 100644 --- a/@coven/iterables/tests/includes.test.ts +++ b/@coven/iterables/tests/includes.test.ts @@ -9,7 +9,8 @@ Deno.test( ); Deno.test("String and an array not containing that string returns false", () => - assertFalse(includesFoo(["baz", "bar"]))); + assertFalse(includesFoo(["baz", "bar"])), +); Deno.test( "String and an iterable of strings containing that string returns true", diff --git a/@coven/iterables/tests/initial.test.ts b/@coven/iterables/tests/initial.test.ts index ced6e15..ad7b91a 100644 --- a/@coven/iterables/tests/initial.test.ts +++ b/@coven/iterables/tests/initial.test.ts @@ -5,13 +5,17 @@ import { assertEquals } from "@std/assert"; const array = [0, 1, 2]; Deno.test("Array returns initial items", () => - assertEquals(iterableToArray(initial(array)), [0, 1])); + assertEquals(iterableToArray(initial(array)), [0, 1]), +); Deno.test("Iterable returns initial items", () => - assertEquals(iterableToArray(initial(range(1)(0)(2))), [0, 1])); + assertEquals(iterableToArray(initial(range(1)(0)(2))), [0, 1]), +); Deno.test("Empty array returns empty array", () => - assertEquals(iterableToArray(initial(EMPTY_ARRAY)), EMPTY_ARRAY)); + assertEquals(iterableToArray(initial(EMPTY_ARRAY)), EMPTY_ARRAY), +); Deno.test("Empty iterable returns empty array", () => - assertEquals(iterableToArray(initial(drop(Infinity)(array))), EMPTY_ARRAY)); + assertEquals(iterableToArray(initial(drop(Infinity)(array))), EMPTY_ARRAY), +); diff --git a/@coven/iterables/tests/intersperse.test.ts b/@coven/iterables/tests/intersperse.test.ts index e561dd2..6ca30b3 100644 --- a/@coven/iterables/tests/intersperse.test.ts +++ b/@coven/iterables/tests/intersperse.test.ts @@ -6,13 +6,8 @@ const array = [0, 1, 2]; const commaIntersperse = intersperse(","); Deno.test("Array returns interspersed items", () => - assertEquals(iterableToArray(commaIntersperse(array)), [ - 0, - ",", - 1, - ",", - 2, - ])); + assertEquals(iterableToArray(commaIntersperse(array)), [0, ",", 1, ",", 2]), +); Deno.test("Iterable returns interspersed items", () => assertEquals(iterableToArray(commaIntersperse(range(1)(0)(2))), [ @@ -21,13 +16,16 @@ Deno.test("Iterable returns interspersed items", () => 1, ",", 2, - ])); + ]), +); Deno.test("Empty array returns empty iterable", () => - assertEquals(iterableToArray(commaIntersperse(EMPTY_ARRAY)), EMPTY_ARRAY)); + assertEquals(iterableToArray(commaIntersperse(EMPTY_ARRAY)), EMPTY_ARRAY), +); Deno.test("Empty iterable returns empty iterable", () => assertEquals( iterableToArray(commaIntersperse(Iterator.from(EMPTY_ARRAY))), EMPTY_ARRAY, - )); + ), +); diff --git a/@coven/iterables/tests/iterableToArray.test.ts b/@coven/iterables/tests/iterableToArray.test.ts index 0f892e5..9972838 100644 --- a/@coven/iterables/tests/iterableToArray.test.ts +++ b/@coven/iterables/tests/iterableToArray.test.ts @@ -2,13 +2,16 @@ import { iterableToArray, range } from "@coven/iterables"; import { assertEquals } from "@std/assert"; Deno.test("a string returns an array with every letter of that string", () => - assertEquals(iterableToArray("Lou"), [..."Lou"])); + assertEquals(iterableToArray("Lou"), [..."Lou"]), +); Deno.test("an array returns that same array", () => - assertEquals(iterableToArray(["🟢", "🟩"]), ["🟢", "🟩"])); + assertEquals(iterableToArray(["🟢", "🟩"]), ["🟢", "🟩"]), +); Deno.test("a generator returns an array with generated values", () => assertEquals( iterableToArray(range(1)(0)(10)), [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], - )); + ), +); diff --git a/@coven/iterables/tests/iteratorFunctionToIterableIterator.test.ts b/@coven/iterables/tests/iteratorFunctionToIterableIterator.test.ts index 39abb03..0f64fac 100644 --- a/@coven/iterables/tests/iteratorFunctionToIterableIterator.test.ts +++ b/@coven/iterables/tests/iteratorFunctionToIterableIterator.test.ts @@ -3,7 +3,7 @@ import { assertEquals } from "@std/assert"; const numbers = [0, 1, 2, 3]; const iterableIteratorNumbers = iteratorFunctionToIterableIterator(() => - Iterator.from(numbers) + Iterator.from(numbers), ); const iterableIteratorSimple = iteratorFunctionToIterableIterator(() => { let done = false; diff --git a/@coven/iterables/tests/join.test.ts b/@coven/iterables/tests/join.test.ts index 674a080..1ee10fa 100644 --- a/@coven/iterables/tests/join.test.ts +++ b/@coven/iterables/tests/join.test.ts @@ -6,19 +6,24 @@ const spaceJoin = join(" "); const array = [0, 1, 2, 3]; Deno.test("Array of numbers returns those numbers separated by spaces", () => - assertEquals(spaceJoin(array), "0 1 2 3")); + assertEquals(spaceJoin(array), "0 1 2 3"), +); Deno.test("Iterable of numbers returns those numbers separated by spaces", () => - assertEquals(spaceJoin(Iterator.from(array)), "0 1 2 3")); + assertEquals(spaceJoin(Iterator.from(array)), "0 1 2 3"), +); Deno.test("Empty array returns empty string", () => - assertEquals(spaceJoin(EMPTY_ARRAY), "")); + assertEquals(spaceJoin(EMPTY_ARRAY), ""), +); Deno.test("Empty iterable returns empty string", () => - assertEquals(spaceJoin(Iterator.from(EMPTY_ARRAY)), "")); + assertEquals(spaceJoin(Iterator.from(EMPTY_ARRAY)), ""), +); Deno.test("Iterable with empty strings returns spaces for each value", () => - assertEquals(spaceJoin(Iterator.from(["", "", ""])), " ")); + assertEquals(spaceJoin(Iterator.from(["", "", ""])), " "), +); Deno.test( "Iterable with undefined values returns empty stringified undefined values", diff --git a/@coven/iterables/tests/length.test.ts b/@coven/iterables/tests/length.test.ts index 0600b12..2fc02e5 100644 --- a/@coven/iterables/tests/length.test.ts +++ b/@coven/iterables/tests/length.test.ts @@ -7,10 +7,13 @@ const array = [0, 1, 2]; Deno.test("Array returns length", () => assertStrictEquals(length(array), 3)); Deno.test("Iterable returns length", () => - assertStrictEquals(length(range(1)(0)(2)), 3)); + assertStrictEquals(length(range(1)(0)(2)), 3), +); Deno.test("Empty array returns 0", () => - assertStrictEquals(length(EMPTY_ARRAY), 0)); + assertStrictEquals(length(EMPTY_ARRAY), 0), +); Deno.test("Empty iterable returns 0", () => - assertStrictEquals(length(Iterator.from(EMPTY_ARRAY)), 0)); + assertStrictEquals(length(Iterator.from(EMPTY_ARRAY)), 0), +); diff --git a/@coven/iterables/tests/objectToentries.test.ts b/@coven/iterables/tests/objectToentries.test.ts index 5855029..c5fcf04 100644 --- a/@coven/iterables/tests/objectToentries.test.ts +++ b/@coven/iterables/tests/objectToentries.test.ts @@ -5,7 +5,8 @@ import { assertEquals } from "@std/assert"; const symbol = Symbol("🟩"); Deno.test("an empty object returns an empty array", () => - assertEquals(iterableToArray(objectToEntries(EMPTY_OBJECT)), EMPTY_ARRAY)); + assertEquals(iterableToArray(objectToEntries(EMPTY_OBJECT)), EMPTY_ARRAY), +); Deno.test( "an object with a single property returns an array with a single tuple", @@ -38,4 +39,5 @@ Deno.test( Deno.test("an object with a symbol property returns that symbol entry", () => assertEquals(iterableToArray(objectToEntries({ [symbol]: "🟢" })), [ [symbol, "🟢"], - ])); + ]), +); diff --git a/@coven/iterables/tests/random.test.ts b/@coven/iterables/tests/random.test.ts index efe8f1d..d0cef03 100644 --- a/@coven/iterables/tests/random.test.ts +++ b/@coven/iterables/tests/random.test.ts @@ -7,9 +7,10 @@ const seededRandomInverse = random("test")(10)(0); Deno.test( 'random with the seed "test" and a take(1) returns the expected value for it', () => - assertEquals(iterableToArray(take(1)(seededRandom)), [ - 3.141_213_210_299_611, - ]), + assertEquals( + iterableToArray(take(1)(seededRandom)), + [3.141_213_210_299_611], + ), ); Deno.test( @@ -27,15 +28,10 @@ Deno.test( assertEquals( iterableToArray(take(10)(seededRandom)), [ - 3.141_213_210_299_611, - 5.272_234_064_526_856, - 0.474_120_759_405_1957, - 3.828_503_423_370_421, - 0, - 6.255_908_024_497_33, - 9.114_267_439_581_454, - 4.361_579_724_587_5, - 9.915_763_438_679_278, + 3.141_213_210_299_611, 5.272_234_064_526_856, + 0.474_120_759_405_1957, 3.828_503_423_370_421, 0, + 6.255_908_024_497_33, 9.114_267_439_581_454, + 4.361_579_724_587_5, 9.915_763_438_679_278, 6.130_150_911_398_232, ], ), @@ -44,9 +40,10 @@ Deno.test( Deno.test( 'random with the seed "test", and inverted from/to and a take(1) returns the expected value for it', () => - assertEquals(iterableToArray(take(1)(seededRandomInverse)), [ - 3.141_213_210_299_611, - ]), + assertEquals( + iterableToArray(take(1)(seededRandomInverse)), + [3.141_213_210_299_611], + ), ); Deno.test( @@ -64,15 +61,10 @@ Deno.test( assertEquals( iterableToArray(take(10)(seededRandomInverse)), [ - 3.141_213_210_299_611, - 5.272_234_064_526_856, - 0.474_120_759_405_1957, - 3.828_503_423_370_421, - 0, - 6.255_908_024_497_33, - 9.114_267_439_581_454, - 4.361_579_724_587_5, - 9.915_763_438_679_278, + 3.141_213_210_299_611, 5.272_234_064_526_856, + 0.474_120_759_405_1957, 3.828_503_423_370_421, 0, + 6.255_908_024_497_33, 9.114_267_439_581_454, + 4.361_579_724_587_5, 9.915_763_438_679_278, 6.130_150_911_398_232, ], ), diff --git a/@coven/iterables/tests/reduce.test.ts b/@coven/iterables/tests/reduce.test.ts index 20bac93..79b4312 100644 --- a/@coven/iterables/tests/reduce.test.ts +++ b/@coven/iterables/tests/reduce.test.ts @@ -6,4 +6,5 @@ const sum = reduce(add); const sumFrom0 = sum(0); Deno.test("an array of numbers and a sum reducer returns the total sum", () => - assertEquals(sumFrom0([1, 2, 3]), 6)); + assertEquals(sumFrom0([1, 2, 3]), 6), +); diff --git a/@coven/iterables/tests/some.test.ts b/@coven/iterables/tests/some.test.ts index 650152e..9658252 100644 --- a/@coven/iterables/tests/some.test.ts +++ b/@coven/iterables/tests/some.test.ts @@ -5,19 +5,25 @@ import { assert, assertFalse } from "@std/assert"; const someNumber = some(isNumber); Deno.test("Array of numbers returns true", () => - assert(someNumber([0, 1, 2, 3]))); + assert(someNumber([0, 1, 2, 3])), +); Deno.test("Array of numbers with a string on it returns true", () => - assert(someNumber([0, 1, 2, "foo", 3]))); + assert(someNumber([0, 1, 2, "foo", 3])), +); Deno.test("Array of strings returns false", () => - assertFalse(someNumber(["foo", "bar"]))); + assertFalse(someNumber(["foo", "bar"])), +); Deno.test("Iterable of numbers returns true", () => - assert(someNumber(Iterator.from([0, 1, 2, 3])))); + assert(someNumber(Iterator.from([0, 1, 2, 3]))), +); Deno.test("Iterable of numbers with a string on it returns true", () => - assert(someNumber(Iterator.from([0, 1, 2, "foo", 3])))); + assert(someNumber(Iterator.from([0, 1, 2, "foo", 3]))), +); Deno.test("Iterable of strings returns false", () => - assertFalse(someNumber(Iterator.from(["foo", "bar"])))); + assertFalse(someNumber(Iterator.from(["foo", "bar"]))), +); diff --git a/@coven/iterables/tests/take.test.ts b/@coven/iterables/tests/take.test.ts index 3b6bbb4..b683608 100644 --- a/@coven/iterables/tests/take.test.ts +++ b/@coven/iterables/tests/take.test.ts @@ -17,7 +17,8 @@ Deno.test( ); Deno.test("Array of numbers and a take 0 function returns an empty array", () => - assertEquals(iterableToArray(takeNone([0, 1, 2, 3, 4])), EMPTY_ARRAY)); + assertEquals(iterableToArray(takeNone([0, 1, 2, 3, 4])), EMPTY_ARRAY), +); Deno.test( "Array of numbers and a take all function returns the whole array", diff --git a/@coven/iterables/tests/toIterable.test.ts b/@coven/iterables/tests/toIterable.test.ts index f5a822e..f8c8b13 100644 --- a/@coven/iterables/tests/toIterable.test.ts +++ b/@coven/iterables/tests/toIterable.test.ts @@ -2,16 +2,13 @@ import { iterableToArray, toIterable } from "@coven/iterables"; import { assertEquals } from "@std/assert"; Deno.test("an array returns iterable of array", () => - assertEquals(iterableToArray(toIterable([0, 1, 2, 3, 4])), [ - 0, - 1, - 2, - 3, - 4, - ])); + assertEquals(iterableToArray(toIterable([0, 1, 2, 3, 4])), [0, 1, 2, 3, 4]), +); Deno.test("a string returns iterable of string", () => - assertEquals(typeof toIterable("test")[Symbol.iterator], "function")); + assertEquals(typeof toIterable("test")[Symbol.iterator], "function"), +); Deno.test("a number returns iterable of number", () => - assertEquals(iterableToArray(toIterable(1)), [1])); + assertEquals(iterableToArray(toIterable(1)), [1]), +); diff --git a/@coven/iterables/tests/unique.test.ts b/@coven/iterables/tests/unique.test.ts index 6472c68..576949d 100644 --- a/@coven/iterables/tests/unique.test.ts +++ b/@coven/iterables/tests/unique.test.ts @@ -10,7 +10,9 @@ Deno.test( ); Deno.test("an array without duplicated elements returns same array", () => - assertEquals(iterableToArray(unique(array)), array)); + assertEquals(iterableToArray(unique(array)), array), +); Deno.test("an empty array returns same array", () => - assertEquals(iterableToArray(unique(EMPTY_ARRAY)), EMPTY_ARRAY)); + assertEquals(iterableToArray(unique(EMPTY_ARRAY)), EMPTY_ARRAY), +); diff --git a/@coven/iterables/tests/zip.test.ts b/@coven/iterables/tests/zip.test.ts index 6a2fdcb..f9ad67a 100644 --- a/@coven/iterables/tests/zip.test.ts +++ b/@coven/iterables/tests/zip.test.ts @@ -5,7 +5,8 @@ import { assertEquals } from "@std/assert"; const zipFooBar = zip(["foo", "bar"]); Deno.test("zip empty array returns empty array", () => - assertEquals(iterableToArray(zipFooBar(EMPTY_ARRAY)), EMPTY_ARRAY)); + assertEquals(iterableToArray(zipFooBar(EMPTY_ARRAY)), EMPTY_ARRAY), +); Deno.test( "zip with 2 strings an array with 2 numbers zips numbers and strings", diff --git a/@coven/iterables/tests/zipIndex.test.ts b/@coven/iterables/tests/zipIndex.test.ts index 02e060b..e7b1337 100644 --- a/@coven/iterables/tests/zipIndex.test.ts +++ b/@coven/iterables/tests/zipIndex.test.ts @@ -12,7 +12,8 @@ Deno.test( ); Deno.test("Empty array empties iterable", () => - assertEquals(iterableToArray(zipIndex(EMPTY_ARRAY)), EMPTY_ARRAY)); + assertEquals(iterableToArray(zipIndex(EMPTY_ARRAY)), EMPTY_ARRAY), +); Deno.test( "Iterable of strings returns Iterable of tuples with indexes and strings", diff --git a/@coven/iterables/toIterable.ts b/@coven/iterables/toIterable.ts index b50527c..82158f3 100644 --- a/@coven/iterables/toIterable.ts +++ b/@coven/iterables/toIterable.ts @@ -24,15 +24,14 @@ export const toIterable = ( valueOrIterable: ValueOrIterable, ): IterableIterator< ValueOrIterable extends AwaitableIterable ? IterableItem - : ValueOrIterable -> => iteratorFunctionToIterableIterator( - function* (): Generator { - isIterable(valueOrIterable) - ? yield* valueOrIterable - : yield valueOrIterable; + : ValueOrIterable +> => + iteratorFunctionToIterableIterator(function* (): Generator { + isIterable(valueOrIterable) ? + yield* valueOrIterable + : yield valueOrIterable; } as () => Generator< - ValueOrIterable extends AwaitableIterable - ? IterableItem - : ValueOrIterable - >, -); + ValueOrIterable extends AwaitableIterable ? + IterableItem + : ValueOrIterable + >); diff --git a/@coven/iterables/zip.ts b/@coven/iterables/zip.ts index 41f4a81..39a0c4e 100644 --- a/@coven/iterables/zip.ts +++ b/@coven/iterables/zip.ts @@ -13,24 +13,25 @@ import { iteratorFunctionToIterableIterator } from "./iteratorFunctionToIterable * @param iterableFirst One of the iterables to be zipped. * @returns Curried function with `iterableFirst` in context. */ -export const zip = ( - iterableFirst: Iterable, -): ( - iterableSecond: Iterable, -) => IterableIterator> => -(iterableSecond: Iterable) => - iteratorFunctionToIterableIterator(function* (): Generator< - Readonly<[ItemFirst, ItemSecond]> - > { - const iteratorSecond = getIterator(iterableSecond); +export const zip = + ( + iterableFirst: Iterable, + ): (( + iterableSecond: Iterable, + ) => IterableIterator>) => + (iterableSecond: Iterable) => + iteratorFunctionToIterableIterator(function* (): Generator< + Readonly<[ItemFirst, ItemSecond]> + > { + const iteratorSecond = getIterator(iterableSecond); - for (const itemFirst of iterableFirst) { - const { done = false, value } = iteratorSecond.next(); + for (const itemFirst of iterableFirst) { + const { done = false, value } = iteratorSecond.next(); - if (done) { - return; - } + if (done) { + return; + } - yield [itemFirst, value as ItemSecond]; - } - }); + yield [itemFirst, value as ItemSecond]; + } + }); diff --git a/@coven/math/add.ts b/@coven/math/add.ts index af484c5..972aca8 100644 --- a/@coven/math/add.ts +++ b/@coven/math/add.ts @@ -16,6 +16,5 @@ import { preciseAdd } from "./preciseAdd.ts"; * @param augend Augend value to be on the right side. * @returns Curried function with `augend` in context. */ -export const add: (augend: number) => (addend: number) => number = pipe( - preciseAdd, -); +export const add: (augend: number) => (addend: number) => number = + pipe(preciseAdd); diff --git a/@coven/math/divide.ts b/@coven/math/divide.ts index d97f113..815a9db 100644 --- a/@coven/math/divide.ts +++ b/@coven/math/divide.ts @@ -15,6 +15,5 @@ import { preciseDivide } from "./preciseDivide.ts"; * @param divisor Divisor to be used in the division. * @returns Curried function with `divisor` in context. */ -export const divide: (divisor: number) => (dividend: number) => number = pipe( - preciseDivide, -); +export const divide: (divisor: number) => (dividend: number) => number = + pipe(preciseDivide); diff --git a/@coven/math/pipe.ts b/@coven/math/pipe.ts index 0086cba..261fa93 100644 --- a/@coven/math/pipe.ts +++ b/@coven/math/pipe.ts @@ -26,11 +26,11 @@ export const pipe = < ) => (...left: Precise) => Precise, >( preciseOperation: PreciseOperation, -): (right: number) => (left: number) => number => +): ((right: number) => (left: number) => number) => memo((right) => { const rightOperation = preciseOperation(...numberToPrecise(right)); return memo((left) => - preciseToNumber(...rightOperation(...numberToPrecise(left))) + preciseToNumber(...rightOperation(...numberToPrecise(left))), ); }); diff --git a/@coven/math/precise.ts b/@coven/math/precise.ts index dc94fdc..9d21340 100644 --- a/@coven/math/precise.ts +++ b/@coven/math/precise.ts @@ -41,9 +41,9 @@ export const precise: { if (isBigInt(base)) { const { normalizedBase, zeroes } = rightSideZeroes.exec(`${base}`) ?.groups as Readonly<{ - normalizedBase: `${bigint}`; - zeroes: `${bigint}`; - }>; + normalizedBase: `${bigint}`; + zeroes: `${bigint}`; + }>; const normalizedExponent = BigInt(zeroes.length) + (exponent as bigint); return memo([ diff --git a/@coven/math/preciseDivide.ts b/@coven/math/preciseDivide.ts index 6284840..46ab391 100644 --- a/@coven/math/preciseDivide.ts +++ b/@coven/math/preciseDivide.ts @@ -29,10 +29,12 @@ export const preciseDivide: ( divisorExponent?: bigint, ) => (dividendBase: MaybeInfinity, dividendExponent?: bigint) => Precise = memo( (divisorBase, divisorExponent) => - divisorBase === 0n ? always(precise(Infinity)) : preciseMultiply( - ...numberToPrecise( - preciseToNumber(1n, -(divisorExponent ?? 0n)) - / preciseToNumber(divisorBase, 0n), + divisorBase === 0n ? + always(precise(Infinity)) + : preciseMultiply( + ...numberToPrecise( + preciseToNumber(1n, -(divisorExponent ?? 0n)) + / preciseToNumber(divisorBase, 0n), + ), ), - ), ); diff --git a/@coven/math/preciseMultiply.ts b/@coven/math/preciseMultiply.ts index b23255d..48f0bc9 100644 --- a/@coven/math/preciseMultiply.ts +++ b/@coven/math/preciseMultiply.ts @@ -27,11 +27,11 @@ export const preciseMultiply: ( multiplicandExponent?: bigint, ) => Precise = memo((multiplierBase, multiplierExponent) => memo((multiplicandBase, multiplicandExponent) => - isBigInt(multiplicandBase) && isBigInt(multiplierBase) - ? precise( + isBigInt(multiplicandBase) && isBigInt(multiplierBase) ? + precise( multiplicandBase * multiplierBase, (multiplicandExponent ?? 0n) + (multiplierExponent ?? 0n), ) - : precise(Infinity) - ) + : precise(Infinity), + ), ); diff --git a/@coven/math/tests/add.test.ts b/@coven/math/tests/add.test.ts index 9c227fc..a6a8673 100644 --- a/@coven/math/tests/add.test.ts +++ b/@coven/math/tests/add.test.ts @@ -21,7 +21,8 @@ Deno.test("-1 + -2 = -3", () => assertStrictEquals(addNegative(-1), -3)); Deno.test("0.1 + -2 = -1.9", () => assertStrictEquals(addNegative(0.1), -1.9)); Deno.test("-0.1 + -2 = -2.1", () => - assertStrictEquals(addNegative(-0.1), -2.1)); + assertStrictEquals(addNegative(-0.1), -2.1), +); Deno.test("1 + 0.2 = 1.2", () => assertStrictEquals(addFloat(1), 1.2)); @@ -34,16 +35,21 @@ Deno.test("-0.1 + 0.2 = 0.1", () => assertStrictEquals(addFloat(-0.1), 0.1)); Deno.test("1 + -0.2 = 0.8", () => assertStrictEquals(addNegativeFloat(1), 0.8)); Deno.test("-1 + -0.2 = -1.2", () => - assertStrictEquals(addNegativeFloat(-1), -1.2)); + assertStrictEquals(addNegativeFloat(-1), -1.2), +); Deno.test("0.1 + -0.2 = -0.1", () => - assertStrictEquals(addNegativeFloat(0.1), -0.1)); + assertStrictEquals(addNegativeFloat(0.1), -0.1), +); Deno.test("-0.1 + -0.2 = -0.3", () => - assertStrictEquals(addNegativeFloat(-0.1), -0.3)); + assertStrictEquals(addNegativeFloat(-0.1), -0.3), +); Deno.test("5 + 0.00001 = 5.00001", () => - assertStrictEquals(add(0.000_01)(5), 5.000_01)); + assertStrictEquals(add(0.000_01)(5), 5.000_01), +); Deno.test("0.00001 + 5 = 5.00001", () => - assertStrictEquals(add(5)(0.000_01), 5.000_01)); + assertStrictEquals(add(5)(0.000_01), 5.000_01), +); diff --git a/@coven/math/tests/calculate.test.ts b/@coven/math/tests/calculate.test.ts index a70c1b1..ca8af88 100644 --- a/@coven/math/tests/calculate.test.ts +++ b/@coven/math/tests/calculate.test.ts @@ -2,16 +2,20 @@ import { calculate } from "@coven/math"; import { assertStrictEquals } from "@std/assert"; Deno.test("Simple addition returns correct value", () => - assertStrictEquals(calculate(0.1).plus(0.2).total, 0.3)); + assertStrictEquals(calculate(0.1).plus(0.2).total, 0.3), +); Deno.test("Simple division returns correct value", () => - assertStrictEquals(calculate(0.6).dividedBy(2).total, 0.3)); + assertStrictEquals(calculate(0.6).dividedBy(2).total, 0.3), +); Deno.test("Simple multiplication returns correct value", () => - assertStrictEquals(calculate(0.1).times(3).total, 0.3)); + assertStrictEquals(calculate(0.1).times(3).total, 0.3), +); Deno.test("Simple subtraction returns correct value", () => - assertStrictEquals(calculate(0.5).minus(0.2).total, 0.3)); + assertStrictEquals(calculate(0.5).minus(0.2).total, 0.3), +); Deno.test( "Complex operation combining all operations returns correct value", @@ -26,4 +30,5 @@ Deno.test("Memoized value isn't broken", () => assertStrictEquals( calculate(2).plus(2).dividedBy(2).times(2).minus(2).total, 2, - )); + ), +); diff --git a/@coven/math/tests/divide.test.ts b/@coven/math/tests/divide.test.ts index f0135d9..07a0d89 100644 --- a/@coven/math/tests/divide.test.ts +++ b/@coven/math/tests/divide.test.ts @@ -11,20 +11,24 @@ Deno.test("1 / 2 = 0.5", () => assertStrictEquals(dividePositive(1), 0.5)); Deno.test("-1 / 2 = -0.5", () => assertStrictEquals(dividePositive(-1), -0.5)); Deno.test("0.1 / 2 = 0.05", () => - assertStrictEquals(dividePositive(0.1), 0.05)); + assertStrictEquals(dividePositive(0.1), 0.05), +); Deno.test("-0.1 / 2 = -0.05", () => - assertStrictEquals(dividePositive(-0.1), -0.05)); + assertStrictEquals(dividePositive(-0.1), -0.05), +); Deno.test("1 / -2 = -0.5", () => assertStrictEquals(divideNegative(1), -0.5)); Deno.test("-1 / -2 = 0.5", () => assertStrictEquals(divideNegative(-1), 0.5)); Deno.test("0.1 / -2 = -0.05", () => - assertStrictEquals(divideNegative(0.1), -0.05)); + assertStrictEquals(divideNegative(0.1), -0.05), +); Deno.test("-0.1 / -2 = 0.05", () => - assertStrictEquals(divideNegative(-0.1), 0.05)); + assertStrictEquals(divideNegative(-0.1), 0.05), +); Deno.test("1 / 0.2 = 5", () => assertStrictEquals(divideFloat(1), 5)); @@ -33,22 +37,29 @@ Deno.test("-1 / 0.2 = -5", () => assertStrictEquals(divideFloat(-1), -5)); Deno.test("0.1 / 0.2 = 0.5", () => assertStrictEquals(divideFloat(0.1), 0.5)); Deno.test("-0.1 / 0.2 = -0.5", () => - assertStrictEquals(divideFloat(-0.1), -0.5)); + assertStrictEquals(divideFloat(-0.1), -0.5), +); Deno.test("1 / -0.2 = -5", () => - assertStrictEquals(divideNegativeFloat(1), -5)); + assertStrictEquals(divideNegativeFloat(1), -5), +); Deno.test("-1 / -0.2 = 5", () => - assertStrictEquals(divideNegativeFloat(-1), 5)); + assertStrictEquals(divideNegativeFloat(-1), 5), +); Deno.test("0.1 / -0.2 = -0.5", () => - assertStrictEquals(divideNegativeFloat(0.1), -0.5)); + assertStrictEquals(divideNegativeFloat(0.1), -0.5), +); Deno.test("-0.1 / -0.2 = 0.5", () => - assertStrictEquals(divideNegativeFloat(-0.1), 0.5)); + assertStrictEquals(divideNegativeFloat(-0.1), 0.5), +); Deno.test("5 / 0.00001 = 500000", () => - assertStrictEquals(divide(0.000_01)(5), 500_000)); + assertStrictEquals(divide(0.000_01)(5), 500_000), +); Deno.test("0.00001 / 5 = 0.000002", () => - assertStrictEquals(divide(5)(0.000_01), 0.000_002)); + assertStrictEquals(divide(5)(0.000_01), 0.000_002), +); diff --git a/@coven/math/tests/multiply.test.ts b/@coven/math/tests/multiply.test.ts index 03a1310..085e654 100644 --- a/@coven/math/tests/multiply.test.ts +++ b/@coven/math/tests/multiply.test.ts @@ -11,51 +11,65 @@ Deno.test("1 * 2 = 2", () => assertStrictEquals(multiplyPositive(1), 2)); Deno.test("-1 * 2 = -2", () => assertStrictEquals(multiplyPositive(-1), -2)); Deno.test("0.1 * 2 = 0.2", () => - assertStrictEquals(multiplyPositive(0.1), 0.2)); + assertStrictEquals(multiplyPositive(0.1), 0.2), +); Deno.test("-0.1 * 2 = -0.2", () => - assertStrictEquals(multiplyPositive(-0.1), -0.2)); + assertStrictEquals(multiplyPositive(-0.1), -0.2), +); Deno.test("1 * -2 = -2", () => assertStrictEquals(multiplyNegative(1), -2)); Deno.test("-1 * -2 = 2", () => assertStrictEquals(multiplyNegative(-1), 2)); Deno.test("0.1 * -2 = -0.2", () => - assertStrictEquals(multiplyNegative(0.1), -0.2)); + assertStrictEquals(multiplyNegative(0.1), -0.2), +); Deno.test("-0.1 * -2 = 0.2", () => - assertStrictEquals(multiplyNegative(-0.1), 0.2)); + assertStrictEquals(multiplyNegative(-0.1), 0.2), +); Deno.test("1 * 0.2 = 0.2", () => assertStrictEquals(multiplyFloat(1), 0.2)); Deno.test("-1 * 0.2 = -0.2", () => assertStrictEquals(multiplyFloat(-1), -0.2)); Deno.test("0.1 * 0.2 = 0.02", () => - assertStrictEquals(multiplyFloat(0.1), 0.02)); + assertStrictEquals(multiplyFloat(0.1), 0.02), +); Deno.test("-0.1 * 0.2 = -0.02", () => - assertStrictEquals(multiplyFloat(-0.1), -0.02)); + assertStrictEquals(multiplyFloat(-0.1), -0.02), +); Deno.test("1 * -0.2 = -0.2", () => - assertStrictEquals(multiplyNegativeFloat(1), -0.2)); + assertStrictEquals(multiplyNegativeFloat(1), -0.2), +); Deno.test("-1 * -0.2 = 0.2", () => - assertStrictEquals(multiplyNegativeFloat(-1), 0.2)); + assertStrictEquals(multiplyNegativeFloat(-1), 0.2), +); Deno.test("0.1 * -0.2 = -0.02", () => - assertStrictEquals(multiplyNegativeFloat(0.1), -0.02)); + assertStrictEquals(multiplyNegativeFloat(0.1), -0.02), +); Deno.test("-0.1 * -0.2 = 0.02", () => - assertStrictEquals(multiplyNegativeFloat(-0.1), 0.02)); + assertStrictEquals(multiplyNegativeFloat(-0.1), 0.02), +); Deno.test("5 * 0.00001 = 0.00005", () => - assertStrictEquals(multiply(0.000_01)(5), 0.000_05)); + assertStrictEquals(multiply(0.000_01)(5), 0.000_05), +); Deno.test("0.00001 * 5 = 0.00005", () => - assertStrictEquals(multiply(5)(0.000_01), 0.000_05)); + assertStrictEquals(multiply(5)(0.000_01), 0.000_05), +); Deno.test("Infinity * Infinity = Infinity", () => - assertStrictEquals(multiply(Infinity)(Infinity), Infinity)); + assertStrictEquals(multiply(Infinity)(Infinity), Infinity), +); Deno.test("13 * Infinity = Infinity", () => - assertStrictEquals(multiply(Infinity)(13), Infinity)); + assertStrictEquals(multiply(Infinity)(13), Infinity), +); diff --git a/@coven/math/tests/numberToPrecise.test.ts b/@coven/math/tests/numberToPrecise.test.ts index 30edd7a..654dcd7 100644 --- a/@coven/math/tests/numberToPrecise.test.ts +++ b/@coven/math/tests/numberToPrecise.test.ts @@ -22,13 +22,17 @@ Deno.test( ); Deno.test("Positive float without zeroes on the right returns a tuple", () => - assertEquals(numberToPrecise(13.1), [131n, -1n])); + assertEquals(numberToPrecise(13.1), [131n, -1n]), +); Deno.test("Positive float with zeroes on the right returns a tuple", () => - assertEquals(numberToPrecise(1300.1), [13_001n, -1n])); + assertEquals(numberToPrecise(1300.1), [13_001n, -1n]), +); Deno.test("Negative float without zeroes on the right returns tuple", () => - assertEquals(numberToPrecise(-13.1), [-131n, -1n])); + assertEquals(numberToPrecise(-13.1), [-131n, -1n]), +); Deno.test("Negative float with zeroes on the right returns a tuple", () => - assertEquals(numberToPrecise(-1300.1), [-13_001n, -1n])); + assertEquals(numberToPrecise(-1300.1), [-13_001n, -1n]), +); diff --git a/@coven/math/tests/precise.test.ts b/@coven/math/tests/precise.test.ts index 74e7bef..018112f 100644 --- a/@coven/math/tests/precise.test.ts +++ b/@coven/math/tests/precise.test.ts @@ -3,13 +3,17 @@ import { memo } from "@coven/memo"; import { assertStrictEquals } from "@std/assert"; Deno.test("Infinity returns Infinity", () => - assertStrictEquals(precise(Infinity), memo([Infinity]))); + assertStrictEquals(precise(Infinity), memo([Infinity])), +); Deno.test("Number valid tuple returns said tuple", () => - assertStrictEquals(precise(1n, 5n), memo([1n, 5n]))); + assertStrictEquals(precise(1n, 5n), memo([1n, 5n])), +); Deno.test("Number with 0 exponent returns only base", () => - assertStrictEquals(precise(1n, 0n), memo([1n]))); + assertStrictEquals(precise(1n, 0n), memo([1n])), +); Deno.test("Number with no exponent returns only base", () => - assertStrictEquals(precise(1n), memo([1n]))); + assertStrictEquals(precise(1n), memo([1n])), +); diff --git a/@coven/math/tests/preciseAdd.test.ts b/@coven/math/tests/preciseAdd.test.ts index 29c1024..5deec27 100644 --- a/@coven/math/tests/preciseAdd.test.ts +++ b/@coven/math/tests/preciseAdd.test.ts @@ -7,58 +7,77 @@ const preciseAddFloat = preciseAdd(2n, -1n); const preciseAddNegativeFloat = preciseAdd(-2n, -1n); Deno.test("1 + 2 = 3", () => - assertStrictEquals(preciseAddPositive(1n), precise(3n))); + assertStrictEquals(preciseAddPositive(1n), precise(3n)), +); Deno.test("-1 + 2 = 1", () => - assertStrictEquals(preciseAddPositive(-1n), precise(1n))); + assertStrictEquals(preciseAddPositive(-1n), precise(1n)), +); Deno.test("0.1 + 2 = 2.1", () => - assertStrictEquals(preciseAddPositive(1n, -1n), precise(21n, -1n))); + assertStrictEquals(preciseAddPositive(1n, -1n), precise(21n, -1n)), +); Deno.test("-0.1 + 2 = 1.9", () => - assertStrictEquals(preciseAddPositive(-1n, -1n), precise(19n, -1n))); + assertStrictEquals(preciseAddPositive(-1n, -1n), precise(19n, -1n)), +); Deno.test("1 + -2 = -1", () => - assertStrictEquals(preciseAddNegative(1n), precise(-1n))); + assertStrictEquals(preciseAddNegative(1n), precise(-1n)), +); Deno.test("-1 + -2 = -3", () => - assertStrictEquals(preciseAddNegative(-1n), precise(-3n))); + assertStrictEquals(preciseAddNegative(-1n), precise(-3n)), +); Deno.test("0.1 + -2 = -1.9", () => - assertStrictEquals(preciseAddNegative(1n, -1n), precise(-19n, -1n))); + assertStrictEquals(preciseAddNegative(1n, -1n), precise(-19n, -1n)), +); Deno.test("-0.1 + -2 = -2.1", () => - assertStrictEquals(preciseAddNegative(-1n, -1n), precise(-21n, -1n))); + assertStrictEquals(preciseAddNegative(-1n, -1n), precise(-21n, -1n)), +); Deno.test("1 + 0.2 = 1.2", () => - assertStrictEquals(preciseAddFloat(1n), precise(12n, -1n))); + assertStrictEquals(preciseAddFloat(1n), precise(12n, -1n)), +); Deno.test("-1 + 0.2 = -0.8", () => - assertStrictEquals(preciseAddFloat(-1n), precise(-8n, -1n))); + assertStrictEquals(preciseAddFloat(-1n), precise(-8n, -1n)), +); Deno.test("0.1 + 0.2 = 0.3", () => - assertStrictEquals(preciseAddFloat(1n, -1n), precise(3n, -1n))); + assertStrictEquals(preciseAddFloat(1n, -1n), precise(3n, -1n)), +); Deno.test("-0.1 + 0.2 = 0.1", () => - assertStrictEquals(preciseAddFloat(-1n, -1n), precise(1n, -1n))); + assertStrictEquals(preciseAddFloat(-1n, -1n), precise(1n, -1n)), +); Deno.test("1 + -0.2 = 0.8", () => - assertStrictEquals(preciseAddNegativeFloat(1n), precise(8n, -1n))); + assertStrictEquals(preciseAddNegativeFloat(1n), precise(8n, -1n)), +); Deno.test("-1 + -0.2 = -1.2", () => - assertStrictEquals(preciseAddNegativeFloat(-1n), precise(-12n, -1n))); + assertStrictEquals(preciseAddNegativeFloat(-1n), precise(-12n, -1n)), +); Deno.test("0.1 + -0.2 = -0.1", () => - assertStrictEquals(preciseAddNegativeFloat(1n, -1n), precise(-1n, -1n))); + assertStrictEquals(preciseAddNegativeFloat(1n, -1n), precise(-1n, -1n)), +); Deno.test("-0.1 + -0.2 = -0.3", () => - assertStrictEquals(preciseAddNegativeFloat(-1n, -1n), precise(-3n, -1n))); + assertStrictEquals(preciseAddNegativeFloat(-1n, -1n), precise(-3n, -1n)), +); Deno.test("5 + 0.00001 = 5.00001", () => - assertStrictEquals(preciseAdd(1n, -5n)(5n), precise(500_001n, -5n))); + assertStrictEquals(preciseAdd(1n, -5n)(5n), precise(500_001n, -5n)), +); Deno.test("0.00001 + 5 = 5.00001", () => - assertStrictEquals(preciseAdd(5n)(1n, -5n), precise(500_001n, -5n))); + assertStrictEquals(preciseAdd(5n)(1n, -5n), precise(500_001n, -5n)), +); Deno.test("Same Precise returned with same values", () => - assertStrictEquals(preciseAdd(2n)(3n), preciseAdd(2n)(3n))); + assertStrictEquals(preciseAdd(2n)(3n), preciseAdd(2n)(3n)), +); diff --git a/@coven/math/tests/preciseDivide.test.ts b/@coven/math/tests/preciseDivide.test.ts index 3543916..9bc1398 100644 --- a/@coven/math/tests/preciseDivide.test.ts +++ b/@coven/math/tests/preciseDivide.test.ts @@ -7,61 +7,81 @@ const preciseDivideFloat = preciseDivide(2n, -1n); const preciseDivideNegativeFloat = preciseDivide(-2n, -1n); Deno.test("1 / 2 = 0.5", () => - assertStrictEquals(preciseDividePositive(1n), precise(5n, -1n))); + assertStrictEquals(preciseDividePositive(1n), precise(5n, -1n)), +); Deno.test("-1 / 2 = -0.5", () => - assertStrictEquals(preciseDividePositive(-1n), precise(-5n, -1n))); + assertStrictEquals(preciseDividePositive(-1n), precise(-5n, -1n)), +); Deno.test("0.1 / 2 = 0.05", () => - assertStrictEquals(preciseDividePositive(1n, -1n), precise(5n, -2n))); + assertStrictEquals(preciseDividePositive(1n, -1n), precise(5n, -2n)), +); Deno.test("-0.1 / 2 = 0.05", () => - assertStrictEquals(preciseDividePositive(-1n, -1n), precise(-5n, -2n))); + assertStrictEquals(preciseDividePositive(-1n, -1n), precise(-5n, -2n)), +); Deno.test("1 / -2 = -0.5", () => - assertStrictEquals(preciseDivideNegative(1n, 1n), precise(-5n))); + assertStrictEquals(preciseDivideNegative(1n, 1n), precise(-5n)), +); Deno.test("-1 / -2 = 0.5", () => - assertStrictEquals(preciseDivideNegative(-1n), precise(5n, -1n))); + assertStrictEquals(preciseDivideNegative(-1n), precise(5n, -1n)), +); Deno.test("0.1 / -2 = 0.05", () => - assertStrictEquals(preciseDivideNegative(1n, -1n), precise(-5n, -2n))); + assertStrictEquals(preciseDivideNegative(1n, -1n), precise(-5n, -2n)), +); Deno.test("-0.1 / -2 = 0.05", () => - assertStrictEquals(preciseDivideNegative(-1n, -1n), precise(5n, -2n))); + assertStrictEquals(preciseDivideNegative(-1n, -1n), precise(5n, -2n)), +); Deno.test("1 / 0.2 = 5", () => - assertStrictEquals(preciseDivideFloat(1n), precise(5n))); + assertStrictEquals(preciseDivideFloat(1n), precise(5n)), +); Deno.test("-1 / 0.2 = -5", () => - assertStrictEquals(preciseDivideFloat(-1n), precise(-5n))); + assertStrictEquals(preciseDivideFloat(-1n), precise(-5n)), +); Deno.test("0.1 / 0.2 = 0.5", () => - assertStrictEquals(preciseDivideFloat(1n, -1n), precise(5n, -1n))); + assertStrictEquals(preciseDivideFloat(1n, -1n), precise(5n, -1n)), +); Deno.test("-0.1 / 0.2 = -0.5", () => - assertStrictEquals(preciseDivideFloat(-1n, -1n), precise(-5n, -1n))); + assertStrictEquals(preciseDivideFloat(-1n, -1n), precise(-5n, -1n)), +); Deno.test("1 / -0.2 = -5", () => - assertStrictEquals(preciseDivideNegativeFloat(1n), precise(-5n))); + assertStrictEquals(preciseDivideNegativeFloat(1n), precise(-5n)), +); Deno.test("-1 / -0.2 = 5", () => - assertStrictEquals(preciseDivideNegativeFloat(-1n), precise(5n))); + assertStrictEquals(preciseDivideNegativeFloat(-1n), precise(5n)), +); Deno.test("0.1 / -0.2 = -0.5", () => - assertStrictEquals(preciseDivideNegativeFloat(1n, -1n), precise(-5n, -1n))); + assertStrictEquals(preciseDivideNegativeFloat(1n, -1n), precise(-5n, -1n)), +); Deno.test("-0.1 / -0.2 = 0.5", () => - assertStrictEquals(preciseDivideNegativeFloat(-1n, -1n), precise(5n, -1n))); + assertStrictEquals(preciseDivideNegativeFloat(-1n, -1n), precise(5n, -1n)), +); Deno.test("5 / 0.00001 = 500000", () => - assertStrictEquals(preciseDivide(1n, -5n)(5n), precise(5n, 5n))); + assertStrictEquals(preciseDivide(1n, -5n)(5n), precise(5n, 5n)), +); Deno.test("0.00001 / 5 = 0.000002", () => - assertStrictEquals(preciseDivide(5n)(1n, -5n), precise(2n, -6n))); + assertStrictEquals(preciseDivide(5n)(1n, -5n), precise(2n, -6n)), +); Deno.test("1 / 0 = Infinity", () => - assertStrictEquals(preciseDivide(0n)(1n), precise(Infinity))); + assertStrictEquals(preciseDivide(0n)(1n), precise(Infinity)), +); Deno.test("Same Precise returned with same values", () => - assertStrictEquals(preciseDivide(2n)(3n), preciseDivide(2n)(3n))); + assertStrictEquals(preciseDivide(2n)(3n), preciseDivide(2n)(3n)), +); diff --git a/@coven/math/tests/preciseMultiply.test.ts b/@coven/math/tests/preciseMultiply.test.ts index 94c3bd1..a50c743 100644 --- a/@coven/math/tests/preciseMultiply.test.ts +++ b/@coven/math/tests/preciseMultiply.test.ts @@ -7,70 +7,91 @@ const preciseMultiplyFloat = preciseMultiply(2n, -1n); const preciseMultiplyNegativeFloat = preciseMultiply(-2n, -1n); Deno.test("1 * 2 = 2", () => - assertStrictEquals(preciseMultiplyPositive(1n), precise(2n))); + assertStrictEquals(preciseMultiplyPositive(1n), precise(2n)), +); Deno.test("-1 * 2 = -2", () => - assertStrictEquals(preciseMultiplyPositive(-1n), precise(-2n))); + assertStrictEquals(preciseMultiplyPositive(-1n), precise(-2n)), +); Deno.test("0.1 * 2 = 0.2", () => - assertStrictEquals(preciseMultiplyPositive(1n, -1n), precise(2n, -1n))); + assertStrictEquals(preciseMultiplyPositive(1n, -1n), precise(2n, -1n)), +); Deno.test("-0.1 * 2 = -0.2", () => - assertStrictEquals(preciseMultiplyPositive(-1n, -1n), precise(-2n, -1n))); + assertStrictEquals(preciseMultiplyPositive(-1n, -1n), precise(-2n, -1n)), +); Deno.test("1 * -2 = -2", () => - assertStrictEquals(preciseMultiplyNegative(1n), precise(-2n))); + assertStrictEquals(preciseMultiplyNegative(1n), precise(-2n)), +); Deno.test("-1 * -2 = 2", () => - assertStrictEquals(preciseMultiplyNegative(-1n), precise(2n))); + assertStrictEquals(preciseMultiplyNegative(-1n), precise(2n)), +); Deno.test("0.1 * -2 = -0.2", () => - assertStrictEquals(preciseMultiplyNegative(1n, -1n), precise(-2n, -1n))); + assertStrictEquals(preciseMultiplyNegative(1n, -1n), precise(-2n, -1n)), +); Deno.test("-0.1 * -2 = 0.2", () => - assertStrictEquals(preciseMultiplyNegative(-1n, -1n), precise(2n, -1n))); + assertStrictEquals(preciseMultiplyNegative(-1n, -1n), precise(2n, -1n)), +); Deno.test("1 * 0.2 = 0.2", () => - assertStrictEquals(preciseMultiplyFloat(1n), precise(2n, -1n))); + assertStrictEquals(preciseMultiplyFloat(1n), precise(2n, -1n)), +); Deno.test("-1 * 0.2 = -0.2", () => - assertStrictEquals(preciseMultiplyFloat(-1n), precise(-2n, -1n))); + assertStrictEquals(preciseMultiplyFloat(-1n), precise(-2n, -1n)), +); Deno.test("0.1 * 0.2 = 0.02", () => - assertStrictEquals(preciseMultiplyFloat(1n, -1n), precise(2n, -2n))); + assertStrictEquals(preciseMultiplyFloat(1n, -1n), precise(2n, -2n)), +); Deno.test("-0.1 * 0.2 = -0.02", () => - assertStrictEquals(preciseMultiplyFloat(-1n, -1n), precise(-2n, -2n))); + assertStrictEquals(preciseMultiplyFloat(-1n, -1n), precise(-2n, -2n)), +); Deno.test("1 * -0.2 = -0.2", () => - assertStrictEquals(preciseMultiplyNegativeFloat(1n), precise(-2n, -1n))); + assertStrictEquals(preciseMultiplyNegativeFloat(1n), precise(-2n, -1n)), +); Deno.test("-1 * -0.2 = 0.2", () => - assertStrictEquals(preciseMultiplyNegativeFloat(-1n), precise(2n, -1n))); + assertStrictEquals(preciseMultiplyNegativeFloat(-1n), precise(2n, -1n)), +); Deno.test("0.1 * -0.2 = -0.02", () => assertStrictEquals( preciseMultiplyNegativeFloat(1n, -1n), precise(-2n, -2n), - )); + ), +); Deno.test("-0.1 * -0.2 = 0.02", () => assertStrictEquals( preciseMultiplyNegativeFloat(-1n, -1n), precise(2n, -2n), - )); + ), +); Deno.test("5 * 0.00001 = 0.00005", () => - assertStrictEquals(preciseMultiply(1n, -5n)(5n), precise(5n, -5n))); + assertStrictEquals(preciseMultiply(1n, -5n)(5n), precise(5n, -5n)), +); Deno.test("0.00001 * 5 = 0.00005", () => - assertStrictEquals(preciseMultiply(5n)(1n, -5n), precise(5n, -5n))); + assertStrictEquals(preciseMultiply(5n)(1n, -5n), precise(5n, -5n)), +); Deno.test("Infinity * Infinity = [Infinity]", () => - assertStrictEquals(preciseMultiply(Infinity)(Infinity), precise(Infinity))); + assertStrictEquals(preciseMultiply(Infinity)(Infinity), precise(Infinity)), +); Deno.test("13 * Infinity = [Infinity]", () => - assertStrictEquals(preciseMultiply(Infinity)(13), precise(Infinity))); + assertStrictEquals(preciseMultiply(Infinity)(13), precise(Infinity)), +); Deno.test("Same Precise returned with same values", () => - assertStrictEquals(preciseMultiply(2n)(3n), preciseMultiply(2n)(3n))); + assertStrictEquals(preciseMultiply(2n)(3n), preciseMultiply(2n)(3n)), +); diff --git a/@coven/math/tests/preciseSubtract.test.ts b/@coven/math/tests/preciseSubtract.test.ts index b775c34..b333fee 100644 --- a/@coven/math/tests/preciseSubtract.test.ts +++ b/@coven/math/tests/preciseSubtract.test.ts @@ -7,64 +7,80 @@ const preciseSubtractFloat = preciseSubtract(2n, -1n); const preciseSubtractNegativeFloat = preciseSubtract(-2n, -1n); Deno.test("1 - 2 = -1", () => - assertStrictEquals(preciseSubtractPositive(1n), precise(-1n))); + assertStrictEquals(preciseSubtractPositive(1n), precise(-1n)), +); Deno.test("-1 - 2 = -3", () => - assertStrictEquals(preciseSubtractPositive(-1n), precise(-3n))); + assertStrictEquals(preciseSubtractPositive(-1n), precise(-3n)), +); Deno.test("0.1 - 2 = -1.9", () => - assertStrictEquals(preciseSubtractPositive(1n, -1n), precise(-19n, -1n))); + assertStrictEquals(preciseSubtractPositive(1n, -1n), precise(-19n, -1n)), +); Deno.test("-0.1 - 2 = -2.1", () => - assertStrictEquals(preciseSubtractPositive(-1n, -1n), precise(-21n, -1n))); + assertStrictEquals(preciseSubtractPositive(-1n, -1n), precise(-21n, -1n)), +); Deno.test("1 - -2 = 3", () => - assertStrictEquals(preciseSubtractNegative(1n), precise(3n))); + assertStrictEquals(preciseSubtractNegative(1n), precise(3n)), +); Deno.test("-1 - -2 = 1", () => - assertStrictEquals(preciseSubtractNegative(-1n), precise(1n))); + assertStrictEquals(preciseSubtractNegative(-1n), precise(1n)), +); Deno.test("0.1 - -2 = 2.1", () => - assertStrictEquals(preciseSubtractNegative(1n, -1n), precise(21n, -1n))); + assertStrictEquals(preciseSubtractNegative(1n, -1n), precise(21n, -1n)), +); Deno.test("-0.1 - -2 = 1.9", () => - assertStrictEquals(preciseSubtractNegative(-1n, -1n), precise(19n, -1n))); + assertStrictEquals(preciseSubtractNegative(-1n, -1n), precise(19n, -1n)), +); Deno.test("1 - 0.2 = 0.8", () => - assertStrictEquals(preciseSubtractFloat(1n), precise(8n, -1n))); + assertStrictEquals(preciseSubtractFloat(1n), precise(8n, -1n)), +); Deno.test("-1 - 0.2 = -1.2", () => - assertStrictEquals(preciseSubtractFloat(-1n), precise(-12n, -1n))); + assertStrictEquals(preciseSubtractFloat(-1n), precise(-12n, -1n)), +); Deno.test("0.1 - 0.2 = -0.1", () => - assertStrictEquals(preciseSubtractFloat(1n, -1n), precise(-1n, -1n))); + assertStrictEquals(preciseSubtractFloat(1n, -1n), precise(-1n, -1n)), +); Deno.test("-0.1 - 0.2 = -0.3", () => - assertStrictEquals(preciseSubtractFloat(-1n, -1n), precise(-3n, -1n))); + assertStrictEquals(preciseSubtractFloat(-1n, -1n), precise(-3n, -1n)), +); Deno.test("1 - -0.2 = 1.2", () => - assertStrictEquals(preciseSubtractNegativeFloat(1n), precise(12n, -1n))); + assertStrictEquals(preciseSubtractNegativeFloat(1n), precise(12n, -1n)), +); Deno.test("-1 - -0.2 = -0.8", () => - assertStrictEquals(preciseSubtractNegativeFloat(-1n), precise(-8n, -1n))); + assertStrictEquals(preciseSubtractNegativeFloat(-1n), precise(-8n, -1n)), +); Deno.test("0.1 - -0.2 = 0.3", () => - assertStrictEquals( - preciseSubtractNegativeFloat(1n, -1n), - precise(3n, -1n), - )); + assertStrictEquals(preciseSubtractNegativeFloat(1n, -1n), precise(3n, -1n)), +); Deno.test("-0.1 - -0.2 = 0.1", () => assertStrictEquals( preciseSubtractNegativeFloat(-1n, -1n), precise(1n, -1n), - )); + ), +); Deno.test("5 - 0.00001 = 4.99999", () => - assertStrictEquals(preciseSubtract(1n, -5n)(5n), precise(499_999n, -5n))); + assertStrictEquals(preciseSubtract(1n, -5n)(5n), precise(499_999n, -5n)), +); Deno.test("0.00001 - 5 = -4.99999", () => - assertStrictEquals(preciseSubtract(5n)(1n, -5n), precise(-499_999n, -5n))); + assertStrictEquals(preciseSubtract(5n)(1n, -5n), precise(-499_999n, -5n)), +); Deno.test("Same Precise returned with same values", () => - assertStrictEquals(preciseSubtract(2n)(3n), preciseSubtract(2n)(3n))); + assertStrictEquals(preciseSubtract(2n)(3n), preciseSubtract(2n)(3n)), +); diff --git a/@coven/math/tests/preciseToNumber.test.ts b/@coven/math/tests/preciseToNumber.test.ts index d02f694..3fed316 100644 --- a/@coven/math/tests/preciseToNumber.test.ts +++ b/@coven/math/tests/preciseToNumber.test.ts @@ -42,4 +42,5 @@ Deno.test( ); Deno.test("Tuple of not normalized values returns number", () => - assertStrictEquals(preciseToNumber(-13_000n, 0n), -13_000)); + assertStrictEquals(preciseToNumber(-13_000n, 0n), -13_000), +); diff --git a/@coven/math/tests/subtract.test.ts b/@coven/math/tests/subtract.test.ts index d36b23f..c2ebbb4 100644 --- a/@coven/math/tests/subtract.test.ts +++ b/@coven/math/tests/subtract.test.ts @@ -11,45 +11,57 @@ Deno.test("1 - 2 = -1", () => assertStrictEquals(subtractPositive(1), -1)); Deno.test("-1 - 2 = -3", () => assertStrictEquals(subtractPositive(-1), -3)); Deno.test("0.1 - 2 = -1.9", () => - assertStrictEquals(subtractPositive(0.1), -1.9)); + assertStrictEquals(subtractPositive(0.1), -1.9), +); Deno.test("-0.1 - 2 = -2.1", () => - assertStrictEquals(subtractPositive(-0.1), -2.1)); + assertStrictEquals(subtractPositive(-0.1), -2.1), +); Deno.test("1 - -2 = 3", () => assertStrictEquals(subtractNegative(1), 3)); Deno.test("-1 - -2 = 1", () => assertStrictEquals(subtractNegative(-1), 1)); Deno.test("0.1 - -2 = 2.1", () => - assertStrictEquals(subtractNegative(0.1), 2.1)); + assertStrictEquals(subtractNegative(0.1), 2.1), +); Deno.test("-0.1 - -2 = 1.9", () => - assertStrictEquals(subtractNegative(-0.1), 1.9)); + assertStrictEquals(subtractNegative(-0.1), 1.9), +); Deno.test("1 - 0.2 = 0.8", () => assertStrictEquals(subtractFloat(1), 0.8)); Deno.test("-1 - 0.2 = -1.2", () => assertStrictEquals(subtractFloat(-1), -1.2)); Deno.test("0.1 - 0.2 = -0.1", () => - assertStrictEquals(subtractFloat(0.1), -0.1)); + assertStrictEquals(subtractFloat(0.1), -0.1), +); Deno.test("-0.1 - 0.2 = -0.3", () => - assertStrictEquals(subtractFloat(-0.1), -0.3)); + assertStrictEquals(subtractFloat(-0.1), -0.3), +); Deno.test("1 - -0.2 = 1.2", () => - assertStrictEquals(subtractNegativeFloat(1), 1.2)); + assertStrictEquals(subtractNegativeFloat(1), 1.2), +); Deno.test("-1 - -0.2 = -0.8", () => - assertStrictEquals(subtractNegativeFloat(-1), -0.8)); + assertStrictEquals(subtractNegativeFloat(-1), -0.8), +); Deno.test("0.1 - -0.2 = 0.3", () => - assertStrictEquals(subtractNegativeFloat(0.1), 0.3)); + assertStrictEquals(subtractNegativeFloat(0.1), 0.3), +); Deno.test("-0.1 - -0.2 = 0.1", () => - assertStrictEquals(subtractNegativeFloat(-0.1), 0.1)); + assertStrictEquals(subtractNegativeFloat(-0.1), 0.1), +); Deno.test("5 - 0.00001 = 4.99999", () => - assertStrictEquals(subtract(0.000_01)(5), 4.999_99)); + assertStrictEquals(subtract(0.000_01)(5), 4.999_99), +); Deno.test("0.00001 - 5 = -4.99999", () => - assertStrictEquals(subtract(5)(0.000_01), -4.999_99)); + assertStrictEquals(subtract(5)(0.000_01), -4.999_99), +); diff --git a/@coven/memo/MemoCacheValueIntersection.ts b/@coven/memo/MemoCacheValueIntersection.ts index fcc0e15..97f5cc7 100644 --- a/@coven/memo/MemoCacheValueIntersection.ts +++ b/@coven/memo/MemoCacheValueIntersection.ts @@ -6,8 +6,7 @@ import type { MemoizedTupleCache } from "./MemoizedTupleCache.ts"; /** * Intersection of `MemoCache` possible values. */ -export type MemoCacheValueIntersection = - & MemoizableRecord +export type MemoCacheValueIntersection = MemoizableRecord & MemoizableTuple & MemoizedRecordCache & MemoizedTupleCache; diff --git a/@coven/memo/memo.ts b/@coven/memo/memo.ts index 4b5cd3f..ffc56ab 100644 --- a/@coven/memo/memo.ts +++ b/@coven/memo/memo.ts @@ -37,10 +37,9 @@ export const memo: { * @returns Memoized read-ony record or tuple. */ ( - memoizable: - & MemoizableValue + memoizable: MemoizableValue & (MemoizableValue extends ReadonlyArray ? MemoizableTuple - : MemoizableRecord), + : MemoizableRecord), ): Memoized; /** * Memoize function return values. Given the same arguments, the same value @@ -70,30 +69,25 @@ export const memo: { const tupleParameters = memo(parameters); return ( - memoizedOutputCache.has(tupleParameters) - ? memoizedOutputCache - : memoizedOutputCache.set( + memoizedOutputCache.has(tupleParameters) ? memoizedOutputCache + : memoizedOutputCache.set( tupleParameters, value( - ...(tupleParameters as unknown as ReadonlyArray< - never - >), + ...(tupleParameters as unknown as ReadonlyArray), ), - ) - ).get(tupleParameters); + )).get(tupleParameters); }; } else { // Array.isArray type isn't great, so this is an inline patch const isArray = ( Array.isArray as (value: unknown) => value is MemoizableTuple )(value); - const normalizedValue = isArray - ? value - : memoizableRecordToMemoizableTuple(value); + const normalizedValue = + isArray ? value : memoizableRecordToMemoizableTuple(value); return ( - normalizedValue.length > 0 - ? memoizedCacheReducer( + normalizedValue.length > 0 ? + memoizedCacheReducer( normalizedValue.reduce( memoizedCacheReducer as ( cache: MemoCache, @@ -104,9 +98,8 @@ export const memo: { MEMO_ROOT, value, ) - : isArray - ? EMPTY_ARRAY - : EMPTY_OBJECT + : isArray ? EMPTY_ARRAY + : EMPTY_OBJECT ); } }; diff --git a/@coven/memo/memoizedCacheReducer.ts b/@coven/memo/memoizedCacheReducer.ts index 677b510..933acca 100644 --- a/@coven/memo/memoizedCacheReducer.ts +++ b/@coven/memo/memoizedCacheReducer.ts @@ -29,17 +29,15 @@ export const memoizedCacheReducer = < (cache.has(item as MemoCacheKeyIntersection) ? cache : ( cache.set( item as MemoCacheKeyIntersection, - (item === MEMO_ROOT - ? Object.freeze( - Array.isArray(value) - ? structuredClone(value) - : Object.assign( - Object.create(null), - structuredClone(value), - ), + (item === MEMO_ROOT ? + Object.freeze( + Array.isArray(value) ? + structuredClone(value) + : Object.assign(Object.create(null), structuredClone(value)), ) - : new Map()) as MemoCacheValueIntersection, + : new Map()) as MemoCacheValueIntersection, ) - )).get(item as MemoCacheKeyIntersection) as Item extends typeof MEMO_ROOT - ? Value - : MemoCache; + ) + ).get(item as MemoCacheKeyIntersection) as Item extends typeof MEMO_ROOT ? + Value + : MemoCache; diff --git a/@coven/memo/tests/memo.test.ts b/@coven/memo/tests/memo.test.ts index aba2670..815c867 100644 --- a/@coven/memo/tests/memo.test.ts +++ b/@coven/memo/tests/memo.test.ts @@ -9,65 +9,78 @@ import { } from "@std/assert"; Deno.test("Tuples with same values are equal", () => - assertStrictEquals(memo(["✨", "🔮"]), memo(["✨", "🔮"]))); + assertStrictEquals(memo(["✨", "🔮"]), memo(["✨", "🔮"])), +); Deno.test("Tuples with similar values are different", () => assertNotStrictEquals>( memo(["✨", "🔮"]), memo(["🔮", "✨"]), - )); + ), +); Deno.test("Tuples with similar different lengths", () => assertNotStrictEquals>( memo(["✨", "🔮"]), memo(["✨", "🔮", "💀"]), - )); + ), +); Deno.test("Tuple preserves items", () => - assertEquals>(memo(["✨", "🔮"]), ["✨", "🔮"])); + assertEquals>(memo(["✨", "🔮"]), ["✨", "🔮"]), +); Deno.test("Tuple with nested record works", () => assertStrictEquals( memo([memo({ foo: "🔮" })]), memo([memo({ foo: "🔮" })]), - )); + ), +); Deno.test("Records with same values are equal", () => - assertStrictEquals(memo({ foo: "🔮" }), memo({ foo: "🔮" }))); + assertStrictEquals(memo({ foo: "🔮" }), memo({ foo: "🔮" })), +); Deno.test("Records with similar values are different", () => assertNotStrictEquals( memo({ foo: "🔮" }), memo({ bar: "✨" }), - )); + ), +); Deno.test("Record order doesn't matter", () => assertStrictEquals( memo({ foo: "🔮", bar: "💀" }), memo({ bar: "💀", foo: "🔮" }), - )); + ), +); Deno.test("Record preserves shape", () => assertEquals(memo({ foo: "🔮", bar: "💀" }), { foo: "🔮", bar: "💀", - })); + }), +); Deno.test("Record with nested tuple works", () => assertStrictEquals( memo({ foo: memo(["🔮", "💀"]) }), memo({ foo: memo(["🔮", "💀"]) }), - )); + ), +); Deno.test("Empty tuple is the same as EMPTY_ARRAY", () => - assertStrictEquals(memo([]), EMPTY_ARRAY)); + assertStrictEquals(memo([]), EMPTY_ARRAY), +); Deno.test("Empty record is the same as EMPTY_OBJECT", () => - assertStrictEquals(memo({}), EMPTY_OBJECT)); + assertStrictEquals(memo({}), EMPTY_OBJECT), +); Deno.test("Record doesn't have a prototype", () => // deno-lint-ignore coven/no-null - assertStrictEquals(Object.getPrototypeOf(memo({ foo: "🔮" })), null)); + assertStrictEquals(Object.getPrototypeOf(memo({ foo: "🔮" })), null), +); Deno.test( "Trying to mutate, throws", @@ -89,12 +102,13 @@ Deno.test( () => assertStrictEquals( ([2, 2, 2, 3, 3, 3, 2, 2, 2].map((number) => - memoizedDouble(number) + memoizedDouble(number), ), - times), + times), 2, ), ); Deno.test("Memoized function returns expected value", () => - assertStrictEquals(memoizedDouble(2), 4)); + assertStrictEquals(memoizedDouble(2), 4), +); diff --git a/@coven/pair/README.md b/@coven/pair/README.md index 791188b..b4010f5 100644 --- a/@coven/pair/README.md +++ b/@coven/pair/README.md @@ -40,10 +40,7 @@ const Component = ({ array = [] }) => ( return (
  • -
  • ); }} @@ -77,10 +74,7 @@ const Component = ({ array = [] }) => ( return (
  • -
  • ); }} diff --git a/@coven/pair/preact/tests/preact.test.tsx b/@coven/pair/preact/tests/preact.test.tsx index be5c568..54be2a9 100644 --- a/@coven/pair/preact/tests/preact.test.tsx +++ b/@coven/pair/preact/tests/preact.test.tsx @@ -7,10 +7,7 @@ const Render = (usePairedState: typeof useState) => { const [count, setCount] = usePairedState(0); return ( - ); diff --git a/@coven/pair/react/tests/react.test.tsx b/@coven/pair/react/tests/react.test.tsx index 3046f7e..2b46175 100644 --- a/@coven/pair/react/tests/react.test.tsx +++ b/@coven/pair/react/tests/react.test.tsx @@ -8,10 +8,7 @@ const Render = (usePairedState: typeof useState) => { const [count, setCount] = usePairedState(0); return ( - ); diff --git a/@coven/parsers/attempt.ts b/@coven/parsers/attempt.ts index 669d7d3..6da786d 100644 --- a/@coven/parsers/attempt.ts +++ b/@coven/parsers/attempt.ts @@ -17,14 +17,15 @@ import type { Just, Maybe } from "@coven/types"; * @param wrappedFunction Function to be wrapped. * @returns Function wrapped in `try`/`catch`. */ -export const attempt = , Output>( - wrappedFunction: (...wrappedArguments: Arguments) => Output, -): (...parameters: Arguments) => Maybe => -(...parameters) => { - // deno-lint-ignore coven/no-try - try { - return wrappedFunction(...parameters) as Just; - } catch { - return undefined; - } -}; +export const attempt = + , Output>( + wrappedFunction: (...wrappedArguments: Arguments) => Output, + ): ((...parameters: Arguments) => Maybe) => + (...parameters) => { + // deno-lint-ignore coven/no-try + try { + return wrappedFunction(...parameters) as Just; + } catch { + return undefined; + } + }; diff --git a/@coven/parsers/parseInteger.ts b/@coven/parsers/parseInteger.ts index a8dcfb7..725b3e8 100644 --- a/@coven/parsers/parseInteger.ts +++ b/@coven/parsers/parseInteger.ts @@ -30,5 +30,5 @@ export const parseInteger: (radix: Radix) => NumberParser = memo((radix) => * @param string String to parse. * @returns Parsed `number` or `undefined` if it fails. */ - memo((string) => undefineNaN(parseInt(string, radix as number))) + memo((string) => undefineNaN(parseInt(string, radix as number))), ); diff --git a/@coven/parsers/parseJSON.ts b/@coven/parsers/parseJSON.ts index 63a0760..9166697 100644 --- a/@coven/parsers/parseJSON.ts +++ b/@coven/parsers/parseJSON.ts @@ -30,8 +30,7 @@ export const parseJSON: { [string: string, reviver?: (key: string, value: unknown) => unknown], JSONValue >((string, reviver) => - JSON.parse( - string, - (key, value) => omitProtoReviver(key, reviver?.(key, value) ?? value), - ) + JSON.parse(string, (key, value) => + omitProtoReviver(key, reviver?.(key, value) ?? value), + ), ) as (string: string) => Maybe; diff --git a/@coven/parsers/tests/attempt.test.ts b/@coven/parsers/tests/attempt.test.ts index c6287e2..aa8647c 100644 --- a/@coven/parsers/tests/attempt.test.ts +++ b/@coven/parsers/tests/attempt.test.ts @@ -16,7 +16,9 @@ const throwingFunction = (shouldThrow: boolean) => { const safeFunction = attempt(throwingFunction); Deno.test("Returns expected value when function doesn't throw", () => - assertEquals(safeFunction(DOES_NOT_THROW), "success")); + assertEquals(safeFunction(DOES_NOT_THROW), "success"), +); Deno.test("Returns undefined when function throw", () => - assertEquals(safeFunction(THROWS), undefined)); + assertEquals(safeFunction(THROWS), undefined), +); diff --git a/@coven/parsers/tests/clone.test.ts b/@coven/parsers/tests/clone.test.ts index f248f6d..0591b28 100644 --- a/@coven/parsers/tests/clone.test.ts +++ b/@coven/parsers/tests/clone.test.ts @@ -4,25 +4,32 @@ import type { StructuredData } from "@coven/types"; import { assertEquals } from "@std/assert"; Deno.test("Cloning empty object returns copy of object", () => - assertEquals(clone(EMPTY_OBJECT), EMPTY_OBJECT)); + assertEquals(clone(EMPTY_OBJECT), EMPTY_OBJECT), +); Deno.test("Cloning object with a string returns copy of object", () => - assertEquals(clone({ foo: "bar" }), { foo: "bar" })); + assertEquals(clone({ foo: "bar" }), { foo: "bar" }), +); Deno.test("Cloning empty array returns copy of empty array", () => - assertEquals(clone(EMPTY_ARRAY), EMPTY_ARRAY)); + assertEquals(clone(EMPTY_ARRAY), EMPTY_ARRAY), +); Deno.test("Cloning array with numbers returns copy of array", () => - assertEquals(clone([1, 2, 3]), [1, 2, 3])); + assertEquals(clone([1, 2, 3]), [1, 2, 3]), +); Deno.test("Cloning string returns copy of string", () => - assertEquals(clone("string"), "string")); + assertEquals(clone("string"), "string"), +); Deno.test("Cloning non serializable object returns undefined", () => assertEquals( clone({ function: () => undefined } as unknown as StructuredData), undefined, - )); + ), +); Deno.test("Cloning number returns a copy of number", () => - assertEquals(clone(13), 13)); + assertEquals(clone(13), 13), +); diff --git a/@coven/parsers/tests/parseBinary.test.ts b/@coven/parsers/tests/parseBinary.test.ts index a62d2ca..fed0aa6 100644 --- a/@coven/parsers/tests/parseBinary.test.ts +++ b/@coven/parsers/tests/parseBinary.test.ts @@ -2,10 +2,13 @@ import { parseBinary } from "@coven/parsers"; import { assertEquals } from "@std/assert"; Deno.test("Parsing valid binary string returns parsed value", () => - assertEquals(parseBinary("101"), 0b101)); + assertEquals(parseBinary("101"), 0b101), +); Deno.test("Parsing binary string with a dot returns parsed value", () => - assertEquals(parseBinary("101.5"), 0b101)); + assertEquals(parseBinary("101.5"), 0b101), +); Deno.test("Parsing invalid string returns undefined", () => - assertEquals(parseBinary("invalid"), undefined)); + assertEquals(parseBinary("invalid"), undefined), +); diff --git a/@coven/parsers/tests/parseDecimal.test.ts b/@coven/parsers/tests/parseDecimal.test.ts index 4dbf494..6f715b7 100644 --- a/@coven/parsers/tests/parseDecimal.test.ts +++ b/@coven/parsers/tests/parseDecimal.test.ts @@ -2,10 +2,13 @@ import { parseDecimal } from "@coven/parsers"; import { assertEquals } from "@std/assert"; Deno.test("Parsing valid decimal string returns parsed value", () => - assertEquals(parseDecimal("101"), 101)); + assertEquals(parseDecimal("101"), 101), +); Deno.test("Parsing decimal string with a dot returns parsed value", () => - assertEquals(parseDecimal("101.5"), 101)); + assertEquals(parseDecimal("101.5"), 101), +); Deno.test("Parsing invalid string returns undefined", () => - assertEquals(parseDecimal("invalid"), undefined)); + assertEquals(parseDecimal("invalid"), undefined), +); diff --git a/@coven/parsers/tests/parseFloatingPoint.test.ts b/@coven/parsers/tests/parseFloatingPoint.test.ts index 16f8fc6..1fd81f6 100644 --- a/@coven/parsers/tests/parseFloatingPoint.test.ts +++ b/@coven/parsers/tests/parseFloatingPoint.test.ts @@ -2,10 +2,13 @@ import { parseFloatingPoint } from "@coven/parsers"; import { assertEquals } from "@std/assert"; Deno.test("Parsing valid float point string returns parsed value", () => - assertEquals(parseFloatingPoint("101"), 101)); + assertEquals(parseFloatingPoint("101"), 101), +); Deno.test("Parsing float point string with a dot returns parsed value", () => - assertEquals(parseFloatingPoint("101.5"), 101.5)); + assertEquals(parseFloatingPoint("101.5"), 101.5), +); Deno.test("Parsing invalid string returns undefined", () => - assertEquals(parseFloatingPoint("invalid"), undefined)); + assertEquals(parseFloatingPoint("invalid"), undefined), +); diff --git a/@coven/parsers/tests/parseHexadecimal.test.ts b/@coven/parsers/tests/parseHexadecimal.test.ts index e5af89a..392ff1e 100644 --- a/@coven/parsers/tests/parseHexadecimal.test.ts +++ b/@coven/parsers/tests/parseHexadecimal.test.ts @@ -2,10 +2,13 @@ import { parseHexadecimal } from "@coven/parsers"; import { assertEquals } from "@std/assert"; Deno.test("Parsing valid hexadecimal string returns parsed value", () => - assertEquals(parseHexadecimal("101"), 0x1_01)); + assertEquals(parseHexadecimal("101"), 0x1_01), +); Deno.test("Parsing hexadecimal string with a dot returns parsed value", () => - assertEquals(parseHexadecimal("101.5"), 0x1_01)); + assertEquals(parseHexadecimal("101.5"), 0x1_01), +); Deno.test("Parsing invalid string returns undefined", () => - assertEquals(parseHexadecimal("invalid"), undefined)); + assertEquals(parseHexadecimal("invalid"), undefined), +); diff --git a/@coven/parsers/tests/parseInteger.test.ts b/@coven/parsers/tests/parseInteger.test.ts index 476c1b1..394496d 100644 --- a/@coven/parsers/tests/parseInteger.test.ts +++ b/@coven/parsers/tests/parseInteger.test.ts @@ -4,13 +4,17 @@ import { assertEquals } from "@std/assert"; const parseDecimal = parseInteger(10); Deno.test("Parsing valid decimal string returns parsed value", () => - assertEquals(parseDecimal("101"), 101)); + assertEquals(parseDecimal("101"), 101), +); Deno.test("Parsing decimal string with a dot returns parsed value", () => - assertEquals(parseDecimal("101.5"), 101)); + assertEquals(parseDecimal("101.5"), 101), +); Deno.test("Parsing number with a weird radix returns parsed value", () => - assertEquals(parseInteger(36)("z"), 35)); + assertEquals(parseInteger(36)("z"), 35), +); Deno.test("Parsing invalid string returns undefined", () => - assertEquals(parseDecimal("invalid"), undefined)); + assertEquals(parseDecimal("invalid"), undefined), +); diff --git a/@coven/parsers/tests/parseJSON.test.ts b/@coven/parsers/tests/parseJSON.test.ts index 1140ae6..a9b8dca 100644 --- a/@coven/parsers/tests/parseJSON.test.ts +++ b/@coven/parsers/tests/parseJSON.test.ts @@ -8,31 +8,38 @@ Deno.test( ); Deno.test("Parsing JSON with an empty object returns empty object", () => - assertEquals(parseJSON("{}"), EMPTY_OBJECT)); + assertEquals(parseJSON("{}"), EMPTY_OBJECT), +); Deno.test("Parsing JSON with an object returns empty object", () => - assertEquals(parseJSON('{"✨":"🎃"}'), { "✨": "🎃" })); + assertEquals(parseJSON('{"✨":"🎃"}'), { "✨": "🎃" }), +); Deno.test("Parsing JSON with an empty array returns empty array", () => - assertEquals(parseJSON("[]"), EMPTY_ARRAY)); + assertEquals(parseJSON("[]"), EMPTY_ARRAY), +); Deno.test("Parsing JSON with an array with numbers returns array", () => - assertEquals(parseJSON("[13,42,665]"), [13, 42, 665])); + assertEquals(parseJSON("[13,42,665]"), [13, 42, 665]), +); Deno.test("Parsing JSON with a string returns a string", () => - assertEquals(parseJSON('"✨"'), "✨")); + assertEquals(parseJSON('"✨"'), "✨"), +); Deno.test("Parsing invalid JSON returns undefined and `SyntaxError`", () => - assertEquals(parseJSON("invalid"), undefined)); + assertEquals(parseJSON("invalid"), undefined), +); Deno.test("Parsing JSON with a number returns a number", () => - assertEquals(parseJSON("13"), 13)); + assertEquals(parseJSON("13"), 13), +); Deno.test("Parsing JSON with custom reviver", () => assertEquals( parseJSON('{"url":"https://coven.engineering"}', (key, value) => - key === "url" && typeof value === "string" - ? new URL(value) - : value), + key === "url" && typeof value === "string" ? new URL(value) : value, + ), { url: new URL("https://coven.engineering") }, - )); + ), +); diff --git a/@coven/parsers/tests/parseOctal.test.ts b/@coven/parsers/tests/parseOctal.test.ts index 3d9ecd2..8dcad35 100644 --- a/@coven/parsers/tests/parseOctal.test.ts +++ b/@coven/parsers/tests/parseOctal.test.ts @@ -2,10 +2,13 @@ import { parseOctal } from "@coven/parsers"; import { assertEquals } from "@std/assert"; Deno.test("Parsing valid octal string returns parsed value", () => - assertEquals(parseOctal("101"), 0o101)); + assertEquals(parseOctal("101"), 0o101), +); Deno.test("Parsing octal string with a dot returns parsed value", () => - assertEquals(parseOctal("101.5"), 0o101)); + assertEquals(parseOctal("101.5"), 0o101), +); Deno.test("Parsing invalid string returns undefined", () => - assertEquals(parseOctal("nope"), undefined)); + assertEquals(parseOctal("nope"), undefined), +); diff --git a/@coven/parsers/tests/undefineNaN.test.ts b/@coven/parsers/tests/undefineNaN.test.ts index 04a6a0a..0c08b7c 100644 --- a/@coven/parsers/tests/undefineNaN.test.ts +++ b/@coven/parsers/tests/undefineNaN.test.ts @@ -2,7 +2,9 @@ import { undefineNaN } from "@coven/parsers"; import { assertEquals } from "@std/assert"; Deno.test("Number returns the same number", () => - assertEquals(undefineNaN(13), 13)); + assertEquals(undefineNaN(13), 13), +); Deno.test("NaN returns undefined", () => - assertEquals(undefineNaN(NaN), undefined)); + assertEquals(undefineNaN(NaN), undefined), +); diff --git a/@coven/predicates/between.ts b/@coven/predicates/between.ts index 7731425..aedc6aa 100644 --- a/@coven/predicates/between.ts +++ b/@coven/predicates/between.ts @@ -18,15 +18,15 @@ import type { Numeric } from "@coven/types"; */ export const between = ( start: NumericOrString, -): ( +): (( end: NumericOrString extends string ? string - : NumericOrString extends number ? number - : bigint, + : NumericOrString extends number ? number + : bigint, ) => ( value: NumericOrString extends string ? string - : NumericOrString extends number ? number - : bigint, -) => boolean => + : NumericOrString extends number ? number + : bigint, +) => boolean) => memo((end) => memo( (value) => @@ -37,5 +37,5 @@ export const between = ( && (value as number) <= (end as number)) || ((value as number) <= (start as number) && (value as number) >= (end as number)), - ) + ), ); diff --git a/@coven/predicates/is.ts b/@coven/predicates/is.ts index 04876f6..2856267 100644 --- a/@coven/predicates/is.ts +++ b/@coven/predicates/is.ts @@ -13,7 +13,9 @@ */ export const is: ( expected: Expected, -) => (actual: unknown) => actual is Expected = ( - expected: Expected, -): (actual: unknown) => actual is Expected => -(actual): actual is Expected => Object.is(expected, actual); +) => (actual: unknown) => actual is Expected = + ( + expected: Expected, + ): ((actual: unknown) => actual is Expected) => + (actual): actual is Expected => + Object.is(expected, actual); diff --git a/@coven/predicates/isInstanceOf.ts b/@coven/predicates/isInstanceOf.ts index ebf0959..a5bfc76 100644 --- a/@coven/predicates/isInstanceOf.ts +++ b/@coven/predicates/isInstanceOf.ts @@ -13,7 +13,9 @@ import type { IsInstanceOfFunction } from "./IsInstanceOfFunction.ts"; * ``` * @returns Returns a curried function with `constructor` in context. */ -export const isInstanceOf = >( - constructor: Expected, -): IsInstanceOfFunction => -(input): input is InstanceType => input instanceof constructor; +export const isInstanceOf = + >( + constructor: Expected, + ): IsInstanceOfFunction => + (input): input is InstanceType => + input instanceof constructor; diff --git a/@coven/predicates/isPromise.ts b/@coven/predicates/isPromise.ts index 0642b02..0f8ccd1 100644 --- a/@coven/predicates/isPromise.ts +++ b/@coven/predicates/isPromise.ts @@ -13,6 +13,5 @@ import type { IsInstanceOfFunction } from "./IsInstanceOfFunction.ts"; * ``` * @returns `true` if the given value is an instance of `Promise`, `false` otherwise. */ -export const isPromise: IsInstanceOfFunction = isInstanceOf( - Promise, -); +export const isPromise: IsInstanceOfFunction = + isInstanceOf(Promise); diff --git a/@coven/predicates/isPropertyOf.ts b/@coven/predicates/isPropertyOf.ts index d59549e..1423dc1 100644 --- a/@coven/predicates/isPropertyOf.ts +++ b/@coven/predicates/isPropertyOf.ts @@ -12,7 +12,9 @@ import type { ReadonlyRecord } from "@coven/types"; * @param object Object to check. * @returns Curried function with `context` set. */ -export const isPropertyOf = ( - object: ReadonlyRecord, -): (key: Key) => boolean => -(key) => Object.hasOwn(object, key); +export const isPropertyOf = + ( + object: ReadonlyRecord, + ): ((key: Key) => boolean) => + (key) => + Object.hasOwn(object, key); diff --git a/@coven/predicates/isPrototypeOfObject.ts b/@coven/predicates/isPrototypeOfObject.ts index 72a1467..620f4fc 100644 --- a/@coven/predicates/isPrototypeOfObject.ts +++ b/@coven/predicates/isPrototypeOfObject.ts @@ -12,6 +12,5 @@ import type { IsPrototypeOfFunction } from "./IsPrototypeOfFunction.ts"; * @returns `true` if the given value is an object inheriting directly from `Object`, `false` otherwise. */ // deno-lint-ignore ban-types -export const isPrototypeOfObject: IsPrototypeOfFunction = isPrototypeOf( - Object, -); +export const isPrototypeOfObject: IsPrototypeOfFunction = + isPrototypeOf(Object); diff --git a/@coven/predicates/isRegExp.ts b/@coven/predicates/isRegExp.ts index 3983035..493c014 100644 --- a/@coven/predicates/isRegExp.ts +++ b/@coven/predicates/isRegExp.ts @@ -12,6 +12,5 @@ import type { IsInstanceOfFunction } from "./IsInstanceOfFunction.ts"; * ``` * @returns `true` if the given value is an instance of `RegExp`, `false` otherwise. */ -export const isRegExp: IsInstanceOfFunction = isInstanceOf( - RegExp, -); +export const isRegExp: IsInstanceOfFunction = + isInstanceOf(RegExp); diff --git a/@coven/predicates/isType.ts b/@coven/predicates/isType.ts index cb7f643..49d9328 100644 --- a/@coven/predicates/isType.ts +++ b/@coven/predicates/isType.ts @@ -24,7 +24,7 @@ export const isType: ( type: Type, ) => IsTypeFunction = memo( (type: Type): IsTypeFunction => - (input): input is TypeOfDictionary[Type] => - // deno-lint-ignore coven/no-null - (input === null ? `${input}` : typeof input) === type, + (input): input is TypeOfDictionary[Type] => + // deno-lint-ignore coven/no-null + (input === null ? `${input}` : typeof input) === type, ); diff --git a/@coven/predicates/test.ts b/@coven/predicates/test.ts index e0fd458..e25a6c9 100644 --- a/@coven/predicates/test.ts +++ b/@coven/predicates/test.ts @@ -20,7 +20,7 @@ export const test = ({ source, }: Pick, "flags" | "source">): Filter<[text: string]> => { const attemptTest = attempt((text: string) => - new RegExp(source, flags).test(text) + new RegExp(source, flags).test(text), ); return (text) => attemptTest(text) ?? false; diff --git a/@coven/predicates/tests/between.test.ts b/@coven/predicates/tests/between.test.ts index 5ae3761..6427479 100644 --- a/@coven/predicates/tests/between.test.ts +++ b/@coven/predicates/tests/between.test.ts @@ -9,43 +9,57 @@ const between13And42 = between13(42); const between13AndNegative13 = between13(-13); Deno.test("Between 13 and 13, receiving 13 returns true", () => - assert(between13And13(13))); + assert(between13And13(13)), +); Deno.test('Between "✨" and "✨", receiving "✨" returns true', () => - assert(betweenMagicAndMagic("✨"))); + assert(betweenMagicAndMagic("✨")), +); Deno.test("Between 13 and 13, receiving 42 returns false", () => - assertFalse(between13And13(42))); + assertFalse(between13And13(42)), +); Deno.test('Between "✨" and "✨", receiving "🎃" returns true', () => - assertFalse(betweenMagicAndMagic("🎃"))); + assertFalse(betweenMagicAndMagic("🎃")), +); Deno.test("Between 13 and 42, receiving 29 returns true", () => - assert(between13And42(29))); + assert(between13And42(29)), +); Deno.test("Between 13 and 42, receiving 13 returns true", () => - assert(between13And42(13))); + assert(between13And42(13)), +); Deno.test("Between 13 and 42, receiving 42 returns true", () => - assert(between13And42(42))); + assert(between13And42(42)), +); Deno.test("Between 13 and 42, receiving 0 returns false", () => - assertFalse(between13And42(0))); + assertFalse(between13And42(0)), +); Deno.test("Between 13 and 42, receiving 69 returns false", () => - assertFalse(between13And42(69))); + assertFalse(between13And42(69)), +); Deno.test("Between 13 and -13, receiving -5 returns true", () => - assert(between13AndNegative13(-5))); + assert(between13AndNegative13(-5)), +); Deno.test("Between 13 and -13, receiving 5 returns true", () => - assert(between13AndNegative13(5))); + assert(between13AndNegative13(5)), +); Deno.test("Between 13 and -13, receiving -13 returns true", () => - assert(between13AndNegative13(-13))); + assert(between13AndNegative13(-13)), +); Deno.test("Between 13 and -13, receiving -42 returns false", () => - assertFalse(between13AndNegative13(-42))); + assertFalse(between13AndNegative13(-42)), +); Deno.test("Between 13 and -13, receiving 42 returns false", () => - assertFalse(between13AndNegative13(42))); + assertFalse(between13AndNegative13(42)), +); diff --git a/@coven/predicates/tests/has.test.ts b/@coven/predicates/tests/has.test.ts index 4ebdd29..e4106b6 100644 --- a/@coven/predicates/tests/has.test.ts +++ b/@coven/predicates/tests/has.test.ts @@ -15,37 +15,49 @@ const emptyObject = EMPTY_OBJECT; const emptyArray = EMPTY_ARRAY; Deno.test("Object with string key when looking for a string key", () => - assert(has(magic)(objectWithString))); + assert(has(magic)(objectWithString)), +); Deno.test("Object with symbol key when looking for a symbol key", () => - assert(has(magicSymbol)(objectWithSymbol))); + assert(has(magicSymbol)(objectWithSymbol)), +); Deno.test("Object with number key when looking for a number key", () => - assert(has(number)(objectWithNumber))); + assert(has(number)(objectWithNumber)), +); Deno.test("Array with number key when looking for a number key", () => - assert(has(number)(arrayWith2Items))); + assert(has(number)(arrayWith2Items)), +); Deno.test("Array without number key when looking for a number key", () => - assertFalse(has(number)(arrayWith1Item))); + assertFalse(has(number)(arrayWith1Item)), +); Deno.test("Empty array looking for a number key", () => - assertFalse(has(number)(emptyArray))); + assertFalse(has(number)(emptyArray)), +); Deno.test("Empty object when looking for a string key", () => - assertFalse(has(magic)(emptyObject))); + assertFalse(has(magic)(emptyObject)), +); Deno.test("Empty object when looking for a symbol key", () => - assertFalse(has(magicSymbol)(emptyObject))); + assertFalse(has(magicSymbol)(emptyObject)), +); Deno.test("Empty object when looking for a number key", () => - assertFalse(has(number)(emptyObject))); + assertFalse(has(number)(emptyObject)), +); Deno.test("Object with symbol key when looking for a string key", () => - assertFalse(has(magic)(objectWithSymbol))); + assertFalse(has(magic)(objectWithSymbol)), +); Deno.test("Object with number key when looking for a symbol key", () => - assertFalse(has(magicSymbol)(objectWithNumber))); + assertFalse(has(magicSymbol)(objectWithNumber)), +); Deno.test("Object with string key when looking for a number key", () => - assertFalse(has(number)(objectWithString))); + assertFalse(has(number)(objectWithString)), +); diff --git a/@coven/predicates/tests/hasAsyncIteratorSymbol.test.ts b/@coven/predicates/tests/hasAsyncIteratorSymbol.test.ts index 1686632..63e5903 100644 --- a/@coven/predicates/tests/hasAsyncIteratorSymbol.test.ts +++ b/@coven/predicates/tests/hasAsyncIteratorSymbol.test.ts @@ -5,9 +5,11 @@ import { assert, assertFalse } from "@std/assert"; const objectWithAsyncIteratorSymbol = { [Symbol.asyncIterator]: () => void 0 }; Deno.test("Object with an async iterator symbol", () => - assert(hasAsyncIteratorSymbol(objectWithAsyncIteratorSymbol))); + assert(hasAsyncIteratorSymbol(objectWithAsyncIteratorSymbol)), +); Deno.test("Object without an async iterator symbol", () => - assertFalse(hasAsyncIteratorSymbol(EMPTY_OBJECT))); + assertFalse(hasAsyncIteratorSymbol(EMPTY_OBJECT)), +); Deno.test("Array", () => assertFalse(hasAsyncIteratorSymbol(EMPTY_ARRAY))); diff --git a/@coven/predicates/tests/hasIteratorSymbol.test.ts b/@coven/predicates/tests/hasIteratorSymbol.test.ts index e0d388d..3407d31 100644 --- a/@coven/predicates/tests/hasIteratorSymbol.test.ts +++ b/@coven/predicates/tests/hasIteratorSymbol.test.ts @@ -5,9 +5,11 @@ import { assert, assertFalse } from "@std/assert"; const objectWithIteratorSymbol = { [Symbol.iterator]: () => void 0 }; Deno.test("Object with an iterator symbol", () => - assert(hasIteratorSymbol(objectWithIteratorSymbol))); + assert(hasIteratorSymbol(objectWithIteratorSymbol)), +); Deno.test("Object without an iterator symbol", () => - assertFalse(hasIteratorSymbol(EMPTY_OBJECT))); + assertFalse(hasIteratorSymbol(EMPTY_OBJECT)), +); Deno.test("Array", () => assert(hasIteratorSymbol(EMPTY_ARRAY))); diff --git a/@coven/predicates/tests/hasPrototype.test.ts b/@coven/predicates/tests/hasPrototype.test.ts index 3c3f6ee..fb4a90e 100644 --- a/@coven/predicates/tests/hasPrototype.test.ts +++ b/@coven/predicates/tests/hasPrototype.test.ts @@ -2,12 +2,15 @@ import { hasPrototype } from "@coven/predicates"; import { assert, assertFalse } from "@std/assert"; Deno.test("Array instance doesn't have prototype", () => - assertFalse(hasPrototype([]))); + assertFalse(hasPrototype([])), +); Deno.test("Array constructor has prototype", () => assert(hasPrototype(Array))); Deno.test("Object instance doesn't have prototype", () => - assertFalse(hasPrototype({}))); + assertFalse(hasPrototype({})), +); Deno.test("Object constructor has prototype", () => - assert(hasPrototype(Object))); + assert(hasPrototype(Object)), +); diff --git a/@coven/predicates/tests/is.test.ts b/@coven/predicates/tests/is.test.ts index 1619746..202244b 100644 --- a/@coven/predicates/tests/is.test.ts +++ b/@coven/predicates/tests/is.test.ts @@ -11,6 +11,7 @@ Deno.test("Equal values", () => assert(is(magic)(magicCopy))); Deno.test("Different strings", () => assertFalse(is(magic)(pumpkin))); Deno.test("Equal objects", () => - assertFalse(is(createObject())(createObject()))); + assertFalse(is(createObject())(createObject())), +); Deno.test("Equal arrays", () => assertFalse(is([])([]))); diff --git a/@coven/predicates/tests/isArray.test.ts b/@coven/predicates/tests/isArray.test.ts index a800752..7a5a840 100644 --- a/@coven/predicates/tests/isArray.test.ts +++ b/@coven/predicates/tests/isArray.test.ts @@ -51,4 +51,5 @@ Deno.test("Other types", () => || isArray(Symbol.iterator) // Undefined || isArray(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isAsyncIterable.test.ts b/@coven/predicates/tests/isAsyncIterable.test.ts index d7bc272..d0b550b 100644 --- a/@coven/predicates/tests/isAsyncIterable.test.ts +++ b/@coven/predicates/tests/isAsyncIterable.test.ts @@ -3,7 +3,8 @@ import { isAsyncIterable } from "@coven/predicates"; import { assert, assertFalse } from "@std/assert"; Deno.test("AsyncGenerator", () => - assert(isAsyncIterable((async function* (): AsyncGenerator {})()))); + assert(isAsyncIterable((async function* (): AsyncGenerator {})())), +); Deno.test("Other types", () => assertFalse( @@ -52,4 +53,5 @@ Deno.test("Other types", () => || isAsyncIterable(Symbol.iterator) // Undefined || isAsyncIterable(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isAwaitableIterable.test.ts b/@coven/predicates/tests/isAwaitableIterable.test.ts index 16337c9..a54292c 100644 --- a/@coven/predicates/tests/isAwaitableIterable.test.ts +++ b/@coven/predicates/tests/isAwaitableIterable.test.ts @@ -12,7 +12,8 @@ Deno.test("Awaitable iterables", () => // String && isAwaitableIterable("string") && isAwaitableIterable(`string`), - )); + ), +); Deno.test("Other types", () => assertFalse( @@ -54,4 +55,5 @@ Deno.test("Other types", () => || isAwaitableIterable(Symbol.iterator) // Undefined || isAwaitableIterable(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isBigInt.test.ts b/@coven/predicates/tests/isBigInt.test.ts index 1167c93..4da12ce 100644 --- a/@coven/predicates/tests/isBigInt.test.ts +++ b/@coven/predicates/tests/isBigInt.test.ts @@ -3,7 +3,8 @@ import { isBigInt } from "@coven/predicates"; import { assert, assertFalse } from "@std/assert"; Deno.test("BigInts", () => - assert(isBigInt(BigInt(13)) && isBigInt(BigInt("13")) && isBigInt(13n))); + assert(isBigInt(BigInt(13)) && isBigInt(BigInt("13")) && isBigInt(13n)), +); Deno.test("Other types", () => assertFalse( @@ -50,4 +51,5 @@ Deno.test("Other types", () => || isBigInt(Symbol.iterator) // Undefined || isBigInt(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isBoolean.test.ts b/@coven/predicates/tests/isBoolean.test.ts index e550de7..dea05e6 100644 --- a/@coven/predicates/tests/isBoolean.test.ts +++ b/@coven/predicates/tests/isBoolean.test.ts @@ -4,7 +4,8 @@ import { assert, assertFalse } from "@std/assert"; Deno.test("Booleans", () => // deno-lint-ignore no-boolean-literal-for-arguments - assert(isBoolean(true) && isBoolean(false))); + assert(isBoolean(true) && isBoolean(false)), +); Deno.test("Other types", () => assertFalse( @@ -50,4 +51,5 @@ Deno.test("Other types", () => || isBoolean(Symbol.iterator) // Undefined || isBoolean(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isDate.test.ts b/@coven/predicates/tests/isDate.test.ts index f5b5170..d39be55 100644 --- a/@coven/predicates/tests/isDate.test.ts +++ b/@coven/predicates/tests/isDate.test.ts @@ -51,4 +51,5 @@ Deno.test("Other types", () => || isDate(Symbol.iterator) // Undefined || isDate(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isFalsy.test.ts b/@coven/predicates/tests/isFalsy.test.ts index 553c635..44af348 100644 --- a/@coven/predicates/tests/isFalsy.test.ts +++ b/@coven/predicates/tests/isFalsy.test.ts @@ -23,7 +23,8 @@ Deno.test("Falsies", () => // String && isFalsy("") && isFalsy(``), - )); + ), +); Deno.test("Truthy", () => assertFalse( @@ -66,4 +67,5 @@ Deno.test("Truthy", () => || isFalsy(Symbol("description")) || isFalsy(Symbol()) || isFalsy(Symbol.iterator), - )); + ), +); diff --git a/@coven/predicates/tests/isFunction.test.ts b/@coven/predicates/tests/isFunction.test.ts index 8146484..ea2a27d 100644 --- a/@coven/predicates/tests/isFunction.test.ts +++ b/@coven/predicates/tests/isFunction.test.ts @@ -10,7 +10,8 @@ Deno.test("Functions", () => && isFunction(async function (): Promise {}) && isFunction(function* (): Generator {}) && isFunction(async function* (): AsyncGenerator {}), - )); + ), +); Deno.test("Other types", () => assertFalse( @@ -54,4 +55,5 @@ Deno.test("Other types", () => || isFunction(EMPTY_OBJECT) // Undefined || isFunction(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isIterable.test.ts b/@coven/predicates/tests/isIterable.test.ts index 6d1c927..e04f86f 100644 --- a/@coven/predicates/tests/isIterable.test.ts +++ b/@coven/predicates/tests/isIterable.test.ts @@ -10,7 +10,8 @@ Deno.test("Iterables", () => // String && isIterable("string") && isIterable(`string`), - )); + ), +); Deno.test("Other types", () => assertFalse( @@ -54,4 +55,5 @@ Deno.test("Other types", () => || isIterable(Symbol.iterator) // Undefined || isIterable(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isNull.test.ts b/@coven/predicates/tests/isNull.test.ts index a30bab1..a70db8b 100644 --- a/@coven/predicates/tests/isNull.test.ts +++ b/@coven/predicates/tests/isNull.test.ts @@ -51,4 +51,5 @@ Deno.test("Other types", () => || isNull(Symbol.iterator) // Undefined || isNull(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isNullish.test.ts b/@coven/predicates/tests/isNullish.test.ts index 71feb45..f0e852a 100644 --- a/@coven/predicates/tests/isNullish.test.ts +++ b/@coven/predicates/tests/isNullish.test.ts @@ -4,7 +4,8 @@ import { assert, assertFalse } from "@std/assert"; Deno.test("Nullish", () => // deno-lint-ignore coven/no-null - assert(isNullish(null) && isNullish(undefined))); + assert(isNullish(null) && isNullish(undefined)), +); Deno.test("Other types", () => assertFalse( @@ -50,4 +51,5 @@ Deno.test("Other types", () => || isNullish(Symbol("description")) || isNullish(Symbol()) || isNullish(Symbol.iterator), - )); + ), +); diff --git a/@coven/predicates/tests/isNumber.test.ts b/@coven/predicates/tests/isNumber.test.ts index 88e2c04..6f73207 100644 --- a/@coven/predicates/tests/isNumber.test.ts +++ b/@coven/predicates/tests/isNumber.test.ts @@ -3,7 +3,8 @@ import { isNumber } from "@coven/predicates"; import { assert, assertFalse } from "@std/assert"; Deno.test("Numbers", () => - assert(isNumber(13) && isNumber(Infinity) && isNumber(NaN))); + assert(isNumber(13) && isNumber(Infinity) && isNumber(NaN)), +); Deno.test("Other types", () => assertFalse( @@ -50,4 +51,5 @@ Deno.test("Other types", () => || isNumber(Symbol.iterator) // Undefined || isNumber(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isObject.test.ts b/@coven/predicates/tests/isObject.test.ts index 9a8154a..befc19b 100644 --- a/@coven/predicates/tests/isObject.test.ts +++ b/@coven/predicates/tests/isObject.test.ts @@ -19,7 +19,8 @@ Deno.test("Objects", () => && isObject(new RegExp("expression", "u")) // Object && isObject(EMPTY_OBJECT), - )); + ), +); Deno.test("Other types", () => assertFalse( @@ -55,4 +56,5 @@ Deno.test("Other types", () => || isObject(Symbol.iterator) // Undefined || isObject(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isPromise.test.ts b/@coven/predicates/tests/isPromise.test.ts index 26c82eb..a76823e 100644 --- a/@coven/predicates/tests/isPromise.test.ts +++ b/@coven/predicates/tests/isPromise.test.ts @@ -51,4 +51,5 @@ Deno.test("Other types", () => || isPromise(Symbol.iterator) // Undefined || isPromise(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isPropertyKey.test.ts b/@coven/predicates/tests/isPropertyKey.test.ts index 45ad941..1bb9a03 100644 --- a/@coven/predicates/tests/isPropertyKey.test.ts +++ b/@coven/predicates/tests/isPropertyKey.test.ts @@ -15,7 +15,8 @@ Deno.test("Promise", () => && isPropertyKey(Symbol("description")) && isPropertyKey(Symbol()) && isPropertyKey(Symbol.iterator), - )); + ), +); Deno.test("Other types", () => assertFalse( @@ -55,4 +56,5 @@ Deno.test("Other types", () => || isPropertyKey(new RegExp("expression", "u")) // Undefined || isPropertyKey(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isPropertyOf.test.ts b/@coven/predicates/tests/isPropertyOf.test.ts index ef288a1..028e313 100644 --- a/@coven/predicates/tests/isPropertyOf.test.ts +++ b/@coven/predicates/tests/isPropertyOf.test.ts @@ -17,22 +17,29 @@ const missingString = "missingString"; const missingNumber = 2; Deno.test("Symbol that exist in the given object", () => - assert(isPropertyOfObject(symbol))); + assert(isPropertyOfObject(symbol)), +); Deno.test("String that exist in the given object", () => - assert(isPropertyOfObject(string))); + assert(isPropertyOfObject(string)), +); Deno.test("Number that exist in the given object", () => - assert(isPropertyOfObject(number))); + assert(isPropertyOfObject(number)), +); Deno.test("Symbol that doesn't exist in the given object", () => - assertFalse(isPropertyOfObject(missingSymbol))); + assertFalse(isPropertyOfObject(missingSymbol)), +); Deno.test("String that doesn't exist in the given object", () => - assertFalse(isPropertyOfObject(missingString))); + assertFalse(isPropertyOfObject(missingString)), +); Deno.test("Number that doesn't exist in the given object", () => - assertFalse(isPropertyOfObject(missingNumber))); + assertFalse(isPropertyOfObject(missingNumber)), +); Deno.test("String property on an empty object", () => - assertFalse(isPropertyOf(EMPTY_OBJECT as ReadonlyRecord)(string))); + assertFalse(isPropertyOf(EMPTY_OBJECT as ReadonlyRecord)(string)), +); diff --git a/@coven/predicates/tests/isPrototypeOf.test.ts b/@coven/predicates/tests/isPrototypeOf.test.ts index fcea508..cc444ce 100644 --- a/@coven/predicates/tests/isPrototypeOf.test.ts +++ b/@coven/predicates/tests/isPrototypeOf.test.ts @@ -7,7 +7,8 @@ const isPrototypeOfObject = isPrototypeOf(Object); Deno.test("Empty object", () => assert(isPrototypeOfObject({}))); Deno.test("Empty object with null prototype", () => - assertFalse(isPrototypeOfObject(EMPTY_OBJECT))); + assertFalse(isPrototypeOfObject(EMPTY_OBJECT)), +); Deno.test("Array", () => assertFalse(isPrototypeOfObject(EMPTY_ARRAY))); diff --git a/@coven/predicates/tests/isRegExp.test.ts b/@coven/predicates/tests/isRegExp.test.ts index 94f6f69..991ea21 100644 --- a/@coven/predicates/tests/isRegExp.test.ts +++ b/@coven/predicates/tests/isRegExp.test.ts @@ -3,7 +3,8 @@ import { isRegExp } from "@coven/predicates"; import { assert, assertFalse } from "@std/assert"; Deno.test("Regular expressions", () => - assert(isRegExp(/expression/u) && isRegExp(new RegExp("expression", "u")))); + assert(isRegExp(/expression/u) && isRegExp(new RegExp("expression", "u"))), +); Deno.test("Other types", () => assertFalse( @@ -51,4 +52,5 @@ Deno.test("Other types", () => || isRegExp(Symbol.iterator) // Undefined || isRegExp(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isString.test.ts b/@coven/predicates/tests/isString.test.ts index afb1441..874a2f7 100644 --- a/@coven/predicates/tests/isString.test.ts +++ b/@coven/predicates/tests/isString.test.ts @@ -3,7 +3,8 @@ import { isString } from "@coven/predicates"; import { assert, assertFalse } from "@std/assert"; Deno.test("Regular expressions", () => - assert(isString("string") && isString(`string`))); + assert(isString("string") && isString(`string`)), +); Deno.test("Other types", () => assertFalse( @@ -51,4 +52,5 @@ Deno.test("Other types", () => || isString(Symbol.iterator) // Undefined || isString(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isSymbol.test.ts b/@coven/predicates/tests/isSymbol.test.ts index d2388e8..433eb51 100644 --- a/@coven/predicates/tests/isSymbol.test.ts +++ b/@coven/predicates/tests/isSymbol.test.ts @@ -7,7 +7,8 @@ Deno.test("Regular expressions", () => isSymbol(Symbol("description")) && isSymbol(Symbol()) && isSymbol(Symbol.iterator), - )); + ), +); Deno.test("Other types", () => assertFalse( @@ -54,4 +55,5 @@ Deno.test("Other types", () => || isSymbol(`string`) // Undefined || isSymbol(undefined), - )); + ), +); diff --git a/@coven/predicates/tests/isTruthy.test.ts b/@coven/predicates/tests/isTruthy.test.ts index b002b04..58a66b3 100644 --- a/@coven/predicates/tests/isTruthy.test.ts +++ b/@coven/predicates/tests/isTruthy.test.ts @@ -43,7 +43,8 @@ Deno.test("Truthy", () => && isTruthy(Symbol("description")) && isTruthy(Symbol()) && isTruthy(Symbol.iterator), - )); + ), +); Deno.test("Falsies", () => assertFalse( @@ -66,4 +67,5 @@ Deno.test("Falsies", () => // String || isTruthy("") || isTruthy(``), - )); + ), +); diff --git a/@coven/predicates/tests/isUndefined.test.ts b/@coven/predicates/tests/isUndefined.test.ts index 1f7fe26..568e3e0 100644 --- a/@coven/predicates/tests/isUndefined.test.ts +++ b/@coven/predicates/tests/isUndefined.test.ts @@ -51,4 +51,5 @@ Deno.test("Other types", () => || isUndefined(Symbol("description")) || isUndefined(Symbol()) || isUndefined(Symbol.iterator), - )); + ), +); diff --git a/@coven/predicates/tests/test.test.ts b/@coven/predicates/tests/test.test.ts index 82621d4..ed99e7e 100644 --- a/@coven/predicates/tests/test.test.ts +++ b/@coven/predicates/tests/test.test.ts @@ -16,10 +16,13 @@ Deno.test( ); Deno.test("Given a string with numbers and a test looking for numbers", () => - assert(testNumbersRegExp("13"))); + assert(testNumbersRegExp("13")), +); Deno.test("Given a string without numbers and a test looking for numbers", () => - assertFalse(testNumbersRegExp("✨"))); + assertFalse(testNumbersRegExp("✨")), +); Deno.test("Given a string and a test with syntax errors", () => - assertFalse(testWithErrors("✨"))); + assertFalse(testWithErrors("✨")), +); diff --git a/@coven/terminal/format.ts b/@coven/terminal/format.ts index 9f17e1b..dbe8450 100644 --- a/@coven/terminal/format.ts +++ b/@coven/terminal/format.ts @@ -39,11 +39,10 @@ export const format = memo((open, close) => { ( input: string | TemplateStringsArray, ...expressions: ReadonlyArray - ) => `${sgrOpen}${ - normalizeString(input, ...expressions).replaceAll( + ) => + `${sgrOpen}${normalizeString(input, ...expressions).replaceAll( sgrClose, sgrOpen, - ) - }${sgrClose}`, + )}${sgrClose}`, ); }) as FormatFunction; diff --git a/@coven/terminal/mix.ts b/@coven/terminal/mix.ts index 1797cd4..4a9af9a 100644 --- a/@coven/terminal/mix.ts +++ b/@coven/terminal/mix.ts @@ -20,17 +20,18 @@ import type { Formatter } from "./Formatter.ts"; * @param formatters Array of formatters to be composed. * @returns Formatter composed of the given formatters. */ -export const mix = (...formatters: ReadonlyArray): Formatter => -/** - * {@linkcode mix} function with formatters set in context. - * - * @see {@linkcode mix} - * @param input String or template string. - * @param expressions Possible values passed to the template string. - * @returns Formatted string. - */ -(input, ...expressions) => - formatters.reduce( - (output, formatter) => formatter(output, ...expressions), - input, - ) as string; +export const mix = + (...formatters: ReadonlyArray): Formatter => + /** + * {@linkcode mix} function with formatters set in context. + * + * @see {@linkcode mix} + * @param input String or template string. + * @param expressions Possible values passed to the template string. + * @returns Formatted string. + */ + (input, ...expressions) => + formatters.reduce( + (output, formatter) => formatter(output, ...expressions), + input, + ) as string; diff --git a/@coven/terminal/tests/format.test.ts b/@coven/terminal/tests/format.test.ts index 5007b45..c191a8e 100644 --- a/@coven/terminal/tests/format.test.ts +++ b/@coven/terminal/tests/format.test.ts @@ -5,22 +5,26 @@ Deno.test("Format works on string", () => assertEquals( format(13, 42)("Coven Engineering"), "Coven Engineering", - )); + ), +); Deno.test("Format works as a template tag function", () => assertEquals( format(13, 42)`Coven Engineering ${665}`, "Coven Engineering 665", - )); + ), +); Deno.test("Nested when closing value is the same works", () => assertEquals( format(13, 42)`Hi ${format(665, 42)`Witch`}!`, "Hi Witch!", - )); + ), +); Deno.test("Nested when closing value is the different works", () => assertEquals( format(13, 42)`Hi ${format(665, 666)`Witch`}!`, "Hi Witch!", - )); + ), +); diff --git a/@coven/terminal/tests/mix.test.ts b/@coven/terminal/tests/mix.test.ts index bc39e8c..3b1e4e4 100644 --- a/@coven/terminal/tests/mix.test.ts +++ b/@coven/terminal/tests/mix.test.ts @@ -9,10 +9,12 @@ Deno.test("Mix works", () => assertEquals( mixed("Coven Engineering"), second(first("Coven Engineering")), - )); + ), +); Deno.test("Mix works as a template string tag function", () => assertEquals( mixed`Coven Engineering ${13}`, second`${first`Coven Engineering ${13}`}`, - )); + ), +); diff --git a/@coven/terminal/tests/normalizeString.test.ts b/@coven/terminal/tests/normalizeString.test.ts index bf5ba71..743fc6e 100644 --- a/@coven/terminal/tests/normalizeString.test.ts +++ b/@coven/terminal/tests/normalizeString.test.ts @@ -2,7 +2,9 @@ import { normalizeString } from "@coven/terminal"; import { assertEquals } from "@std/assert"; Deno.test("Normalize string works on a plain string", () => - assertEquals(normalizeString("✨"), "✨")); + assertEquals(normalizeString("✨"), "✨"), +); Deno.test("Normalize string works as a template string tag function", () => - assertEquals(normalizeString`${13}`, "13")); + assertEquals(normalizeString`${13}`, "13"), +); diff --git a/@coven/types/AwaitableEffect.ts b/@coven/types/AwaitableEffect.ts index b94dbdc..3bc0bb0 100644 --- a/@coven/types/AwaitableEffect.ts +++ b/@coven/types/AwaitableEffect.ts @@ -16,4 +16,4 @@ import type { Awaitable } from "./Awaitable.ts"; */ export type AwaitableEffect> = Arguments extends Readonly<[]> ? () => Awaitable - : (..._: Arguments) => Awaitable; + : (..._: Arguments) => Awaitable; diff --git a/@coven/types/Branded.ts b/@coven/types/Branded.ts index 2de593e..216e166 100644 --- a/@coven/types/Branded.ts +++ b/@coven/types/Branded.ts @@ -23,6 +23,5 @@ export declare const BRAND: unique symbol; * @template Brand Name of brand. * @template Value Value to brand with {@linkcode Brand}. */ -export type Branded = - & Value +export type Branded = Value & Readonly<{ [BRAND]: Brand }>; diff --git a/@coven/types/EntryOf.ts b/@coven/types/EntryOf.ts index 5b3e35e..5f35166 100644 --- a/@coven/types/EntryOf.ts +++ b/@coven/types/EntryOf.ts @@ -18,16 +18,14 @@ import type { ReadonlyArrayLike } from "./ReadonlyArrayLike.ts"; * @see {@linkcode ReadonlyArrayLike} * @template Object Object to get the entry from. */ -export type EntryOf = Readonly< - { - /** - * @see {@linkcode EntryOf} property that shouldn't be referenced directly - */ - [Property in KeyOf]: Entry< - Property, - Property extends keyof Object ? Object[Property] - : Object extends ReadonlyArrayLike ? Object[number] - : never - >; - } ->[KeyOf]; +export type EntryOf = Readonly<{ + /** + * @see {@linkcode EntryOf} property that shouldn't be referenced directly + */ + [Property in KeyOf]: Entry< + Property, + Property extends keyof Object ? Object[Property] + : Object extends ReadonlyArrayLike ? Object[number] + : never + >; +}>[KeyOf]; diff --git a/@coven/types/Enumerate.ts b/@coven/types/Enumerate.ts index 005e3e1..cfbca15 100644 --- a/@coven/types/Enumerate.ts +++ b/@coven/types/Enumerate.ts @@ -12,5 +12,5 @@ import type { IndexArray } from "./IndexArray.ts"; * ``` * @template To Last number of the union (starts at `0`). */ -export type Enumerate = To extends 0 ? To - : IndexArray[keyof IndexArray & number] | To; +export type Enumerate = + To extends 0 ? To : IndexArray[keyof IndexArray & number] | To; diff --git a/@coven/types/Fallback.ts b/@coven/types/Fallback.ts index 9f333c3..abe58a5 100644 --- a/@coven/types/Fallback.ts +++ b/@coven/types/Fallback.ts @@ -15,8 +15,10 @@ import type { Single } from "./Single.ts"; * @template MaybeWrong Type to check. * @template FallbackType Fallback if `MaybeWrong` extends `Wrong`. */ -export type Fallback = Single extends - Single ? Single extends Single ? FallbackType - : MaybeWrong +export type Fallback = + Single extends Single ? + Single extends Single ? + FallbackType + : MaybeWrong : MaybeWrong extends Wrong ? FallbackType : MaybeWrong; diff --git a/@coven/types/Head.ts b/@coven/types/Head.ts index 897ce72..59dd3cf 100644 --- a/@coven/types/Head.ts +++ b/@coven/types/Head.ts @@ -16,6 +16,5 @@ import type { ReadonlyArrayLike } from "./ReadonlyArrayLike.ts"; * @see {@linkcode ReadonlyArrayLike} * @template ArrayLike `ReadonlyArrayLike` value (such as `Array` or `string`). */ -export type Head = HeadAndTail< - ArrayLike ->[0]; +export type Head = + HeadAndTail[0]; diff --git a/@coven/types/HeadAndTail.ts b/@coven/types/HeadAndTail.ts index 835dad7..687c16d 100644 --- a/@coven/types/HeadAndTail.ts +++ b/@coven/types/HeadAndTail.ts @@ -18,12 +18,13 @@ import type { ReadonlyArrayLike } from "./ReadonlyArrayLike.ts"; * @see {@linkcode ReadonlyArrayLike} * @template ArrayLike `ReadonlyArrayLike` to get the head and tail. */ -export type HeadAndTail = ArrayLike extends - ( +export type HeadAndTail = + ArrayLike extends ( Readonly<[head: infer HeadItem, ...tail: infer TailItems]> - ) ? Readonly<[head: HeadItem, tail: TailItems]> - : ArrayLike extends `${infer FirstCharacter}${infer RestOfString}` - ? Readonly<[head: FirstCharacter, tail: RestOfString]> - : ArrayLike extends EmptyArray | "" - ? Readonly<[head: undefined, tail: undefined]> - : Readonly<[head: Maybe, tail: Maybe]>; + ) ? + Readonly<[head: HeadItem, tail: TailItems]> + : ArrayLike extends `${infer FirstCharacter}${infer RestOfString}` ? + Readonly<[head: FirstCharacter, tail: RestOfString]> + : ArrayLike extends EmptyArray | "" ? + Readonly<[head: undefined, tail: undefined]> + : Readonly<[head: Maybe, tail: Maybe]>; diff --git a/@coven/types/ISODate.ts b/@coven/types/ISODate.ts index e1d5e8b..ac9e0da 100644 --- a/@coven/types/ISODate.ts +++ b/@coven/types/ISODate.ts @@ -18,6 +18,4 @@ import type { MinimumLengthNumberString } from "./MinimumLengthNumberString.ts"; * @see {@linkcode https://en.wikipedia.org/wiki/ISO_8601 ISO 8601} */ export type ISODate = - `${ISOYear}-${MinimumLengthNumberString}-${MinimumLengthNumberString}T${MinimumLengthNumberString}:${MinimumLengthNumberString}:${MinimumLengthNumberString}.${MinimumLengthNumberString< - 3 - >}Z`; + `${ISOYear}-${MinimumLengthNumberString}-${MinimumLengthNumberString}T${MinimumLengthNumberString}:${MinimumLengthNumberString}:${MinimumLengthNumberString}.${MinimumLengthNumberString<3>}Z`; diff --git a/@coven/types/IndexArray.ts b/@coven/types/IndexArray.ts index a2fd047..62c6a16 100644 --- a/@coven/types/IndexArray.ts +++ b/@coven/types/IndexArray.ts @@ -17,5 +17,6 @@ import type { EmptyArray } from "./EmptyArray.ts"; export type IndexArray< Length extends number = 0, _Accumulator extends ReadonlyArray = EmptyArray, -> = _Accumulator["length"] extends Length ? _Accumulator - : IndexArray; +> = + _Accumulator["length"] extends Length ? _Accumulator + : IndexArray; diff --git a/@coven/types/Initial.ts b/@coven/types/Initial.ts index cd11188..4f6fc92 100644 --- a/@coven/types/Initial.ts +++ b/@coven/types/Initial.ts @@ -13,6 +13,5 @@ import type { ReadonlyArrayLike } from "./ReadonlyArrayLike.ts"; * @see {@linkcode ReadonlyArrayLike} * @template ArrayLike `ReadonlyArrayLike` value (such as `Array` or `string`). */ -export type Initial = InitialAndLast< - ArrayLike ->[0]; +export type Initial = + InitialAndLast[0]; diff --git a/@coven/types/InitialAndLast.ts b/@coven/types/InitialAndLast.ts index bc633c8..216cf4c 100644 --- a/@coven/types/InitialAndLast.ts +++ b/@coven/types/InitialAndLast.ts @@ -24,20 +24,20 @@ import type { UndefinedFallback } from "./UndefinedFallback.ts"; * @template ArrayLike `ReadonlyArrayLike` to get the initial and last types. */ export type InitialAndLast = - ArrayLike extends Readonly<[...infer InitialItems, infer LastItem]> - ? Readonly<[initial: InitialItems, last: LastItem]> - : ArrayLike extends EmptyArray | "" - ? Readonly<[initial: undefined, last: undefined]> - : ArrayLike extends `${infer FirstCharacter}${infer RestOfString}` - ? Readonly< - [ - initial: `${RestOfString extends "" ? "" - : FirstCharacter}${UndefinedFallback< - Head>, - "" - >}`, - last: `${RestOfString extends "" ? FirstCharacter - : Last}`, - ] - > - : Readonly<[initial: Maybe, last: Maybe]>; + ArrayLike extends Readonly<[...infer InitialItems, infer LastItem]> ? + Readonly<[initial: InitialItems, last: LastItem]> + : ArrayLike extends EmptyArray | "" ? + Readonly<[initial: undefined, last: undefined]> + : ArrayLike extends `${infer FirstCharacter}${infer RestOfString}` ? + Readonly< + [ + initial: `${RestOfString extends "" ? "" + : FirstCharacter}${UndefinedFallback< + Head>, + "" + >}`, + last: `${RestOfString extends "" ? FirstCharacter + : Last}`, + ] + > + : Readonly<[initial: Maybe, last: Maybe]>; diff --git a/@coven/types/IsomorphicIteratorItem.ts b/@coven/types/IsomorphicIteratorItem.ts index 48762d9..2a3ee92 100644 --- a/@coven/types/IsomorphicIteratorItem.ts +++ b/@coven/types/IsomorphicIteratorItem.ts @@ -14,5 +14,5 @@ import type { AwaitableIterator } from "./AwaitableIterator.ts"; * @see {@linkcode AwaitableIterator} * @template Iterator `AwaitableIterator` to get the item type from. */ -export type IteratorItem = Iterator extends - AwaitableIterator ? Item : never; +export type IteratorItem = + Iterator extends AwaitableIterator ? Item : never; diff --git a/@coven/types/IterableItem.ts b/@coven/types/IterableItem.ts index d70e606..d5855f6 100644 --- a/@coven/types/IterableItem.ts +++ b/@coven/types/IterableItem.ts @@ -13,5 +13,5 @@ import type { AwaitableIterable } from "./AwaitableIterable.ts"; * @see {@linkcode AwaitableIterable} * @template Iterable `AwaitableIterable` type to get the item type from. */ -export type IterableItem = Iterable extends - AwaitableIterable ? Item : never; +export type IterableItem = + Iterable extends AwaitableIterable ? Item : never; diff --git a/@coven/types/IteratorItem.ts b/@coven/types/IteratorItem.ts index db27501..c9a6db6 100644 --- a/@coven/types/IteratorItem.ts +++ b/@coven/types/IteratorItem.ts @@ -14,5 +14,5 @@ import type { AwaitableIterator } from "./AwaitableIterator.ts"; * @see {@linkcode AwaitableIterator} * @template Iterator AwaitableIterator to get the item type from. */ -export type IteratorItem = Iterator extends - AwaitableIterator ? Item : never; +export type IteratorItem = + Iterator extends AwaitableIterator ? Item : never; diff --git a/@coven/types/JSONValue.ts b/@coven/types/JSONValue.ts index 0f3033c..18db6c3 100644 --- a/@coven/types/JSONValue.ts +++ b/@coven/types/JSONValue.ts @@ -13,10 +13,10 @@ import type { Primitive } from "./Primitive.ts"; */ export type JSONValue = | Readonly<{ - /** - * @see {@linkcode JSONValue} untyped property. - */ - [property: string]: JSONValue; - }> + /** + * @see {@linkcode JSONValue} untyped property. + */ + [property: string]: JSONValue; + }> | Exclude | ReadonlyArray; diff --git a/@coven/types/KeyOf.ts b/@coven/types/KeyOf.ts index 780dac4..f45bd9e 100644 --- a/@coven/types/KeyOf.ts +++ b/@coven/types/KeyOf.ts @@ -16,6 +16,6 @@ import type { ReadonlyArrayLike } from "./ReadonlyArrayLike.ts"; * @see {@linkcode ReadonlyArrayLike} * @template Object Object type to get the key from. */ -export type KeyOf = `${Object extends ReadonlyArrayLike - ? ArrayLikeIndex - : Exclude}`; +export type KeyOf = `${Object extends ReadonlyArrayLike ? + ArrayLikeIndex +: Exclude}`; diff --git a/@coven/types/LanguageCode.ts b/@coven/types/LanguageCode.ts index 835a6f4..85deb0d 100644 --- a/@coven/types/LanguageCode.ts +++ b/@coven/types/LanguageCode.ts @@ -12,18 +12,18 @@ export type LanguageCode = | "qu" | "xh" | `a${ - | "a" - | "b" - | "e" - | "f" - | "k" - | "m" - | "n" - | "r" - | "s" - | "v" - | "y" - | "z"}` + | "a" + | "b" + | "e" + | "f" + | "k" + | "m" + | "n" + | "r" + | "s" + | "v" + | "y" + | "z"}` | `b${"a" | "e" | "g" | "i" | "m" | "n" | "o" | "r" | "s"}` | `c${"a" | "e" | "h" | "o" | "r" | "s" | "u" | "v" | "y"}` | `d${"a" | "e" | "v" | "z"}` @@ -34,21 +34,21 @@ export type LanguageCode = | `i${"a" | "d" | "e" | "g" | "i" | "k" | "o" | "s" | "t" | "u"}` | `j${"a" | "v"}` | `k${ - | "a" - | "g" - | "i" - | "j" - | "k" - | "l" - | "m" - | "n" - | "o" - | "r" - | "s" - | "u" - | "v" - | "w" - | "y"}` + | "a" + | "g" + | "i" + | "j" + | "k" + | "l" + | "m" + | "n" + | "o" + | "r" + | "s" + | "u" + | "v" + | "w" + | "y"}` | `l${"a" | "b" | "g" | "i" | "n" | "o" | "t" | "u" | "v"}` | `m${"g" | "h" | "i" | "k" | "l" | "n" | "r" | "s" | "t" | "y"}` | `n${"a" | "b" | "d" | "e" | "g" | "l" | "n" | "o" | "r" | "v" | "y"}` @@ -56,39 +56,39 @@ export type LanguageCode = | `p${"a" | "i" | "l" | "s" | "t"}` | `r${"m" | "n" | "o" | "u" | "w"}` | `s${ - | "a" - | "c" - | "d" - | "e" - | "g" - | "i" - | "k" - | "l" - | "m" - | "n" - | "o" - | "q" - | "r" - | "s" - | "t" - | "u" - | "v" - | "w"}` + | "a" + | "c" + | "d" + | "e" + | "g" + | "i" + | "k" + | "l" + | "m" + | "n" + | "o" + | "q" + | "r" + | "s" + | "t" + | "u" + | "v" + | "w"}` | `t${ - | "a" - | "e" - | "g" - | "h" - | "i" - | "k" - | "l" - | "n" - | "o" - | "r" - | "s" - | "t" - | "w" - | "y"}` + | "a" + | "e" + | "g" + | "h" + | "i" + | "k" + | "l" + | "n" + | "o" + | "r" + | "s" + | "t" + | "w" + | "y"}` | `u${"g" | "k" | "r" | "z"}` | `v${"e" | "i" | "o"}` | `w${"a" | "o"}` diff --git a/@coven/types/Last.ts b/@coven/types/Last.ts index 0fd7882..33336d8 100644 --- a/@coven/types/Last.ts +++ b/@coven/types/Last.ts @@ -13,6 +13,5 @@ import type { ReadonlyArrayLike } from "./ReadonlyArrayLike.ts"; * @see {@linkcode ReadonlyArrayLike} * @template ArrayLike `ReadonlyArrayLike` to get the last item from. */ -export type Last = InitialAndLast< - ArrayLike ->[1]; +export type Last = + InitialAndLast[1]; diff --git a/@coven/types/MinimumLengthNumberString.ts b/@coven/types/MinimumLengthNumberString.ts index 48c9ada..9481e81 100644 --- a/@coven/types/MinimumLengthNumberString.ts +++ b/@coven/types/MinimumLengthNumberString.ts @@ -20,11 +20,12 @@ export type MinimumLengthNumberString< MinimumLength extends number = 2, _Accumulator extends string = `${bigint}${bigint}`, _Tracker extends ReadonlyArray = IndexArray<2>, -> = MinimumLength extends 0 ? "" +> = + MinimumLength extends 0 ? "" : MinimumLength extends 1 ? `${Digit}` : _Tracker["length"] extends MinimumLength ? _Accumulator : MinimumLengthNumberString< - MinimumLength, - `${_Accumulator}${bigint}`, - [..._Tracker, _Tracker["length"]] - >; + MinimumLength, + `${_Accumulator}${bigint}`, + [..._Tracker, _Tracker["length"]] + >; diff --git a/@coven/types/Range.ts b/@coven/types/Range.ts index d53a0d8..13848af 100644 --- a/@coven/types/Range.ts +++ b/@coven/types/Range.ts @@ -16,8 +16,8 @@ import type { NeverFallback } from "./NeverFallback.ts"; */ export type Range = From extends To ? From - : From extends 0 ? Enumerate - : NeverFallback< + : From extends 0 ? Enumerate + : NeverFallback< Exclude, Exclude, From>>, Exclude, Exclude, To>> >; diff --git a/@coven/types/ReadonlyArrayLike.ts b/@coven/types/ReadonlyArrayLike.ts index fb3e92f..1ecf1f9 100644 --- a/@coven/types/ReadonlyArrayLike.ts +++ b/@coven/types/ReadonlyArrayLike.ts @@ -31,15 +31,14 @@ import type { Single } from "./Single.ts"; export type ReadonlyArrayLike< Item = unknown, Length extends number = number, -> = - & Readonly<{ - /** - * Amount of items in the {@linkcode ReadonlyArrayLike}. - */ - length: Length; - }> +> = Readonly<{ + /** + * Amount of items in the {@linkcode ReadonlyArrayLike}. + */ + length: Length; +}> & ReadonlyRecord< NeverFallback, Length>, number> & PropertyKey, Exclude, Length> extends Single ? Maybe - : Item + : Item >; diff --git a/@coven/types/StringJoin.ts b/@coven/types/StringJoin.ts index bec4122..0540a38 100644 --- a/@coven/types/StringJoin.ts +++ b/@coven/types/StringJoin.ts @@ -20,12 +20,13 @@ export type StringJoin< Glue extends string = "", _Accumulator extends string = `${StringableArray[0]}`, _Tracker extends ReadonlyArray = IndexArray<1>, -> = StringableArray["length"] extends 0 ? "" +> = + StringableArray["length"] extends 0 ? "" : StringableArray["length"] extends 1 ? _Accumulator : _Tracker["length"] extends StringableArray["length"] ? _Accumulator : StringJoin< - StringableArray, - Glue, - `${_Accumulator}${Glue}${StringableArray[_Tracker["length"]]}`, - [..._Tracker, _Tracker["length"]] - >; + StringableArray, + Glue, + `${_Accumulator}${Glue}${StringableArray[_Tracker["length"]]}`, + [..._Tracker, _Tracker["length"]] + >; diff --git a/@coven/types/StructuredData.ts b/@coven/types/StructuredData.ts index 9905249..bad9234 100644 --- a/@coven/types/StructuredData.ts +++ b/@coven/types/StructuredData.ts @@ -12,10 +12,10 @@ import type { Primitive } from "./Primitive.ts"; */ export type StructuredData = | Readonly<{ - /** - * @see {@linkcode StructuredData} untyped property. - */ - [property: string]: StructuredData; - }> + /** + * @see {@linkcode StructuredData} untyped property. + */ + [property: string]: StructuredData; + }> | Exclude | ReadonlyArray; diff --git a/@coven/types/Tail.ts b/@coven/types/Tail.ts index 6d63364..13b845c 100644 --- a/@coven/types/Tail.ts +++ b/@coven/types/Tail.ts @@ -16,6 +16,5 @@ import type { ReadonlyArrayLike } from "./ReadonlyArrayLike.ts"; * @see {@linkcode ReadonlyArrayLike} * @template ArrayLike Type of the array to get the tail. */ -export type Tail = HeadAndTail< - ArrayLike ->[1]; +export type Tail = + HeadAndTail[1]; diff --git a/@coven/types/ValueOf.ts b/@coven/types/ValueOf.ts index e769fe8..1491395 100644 --- a/@coven/types/ValueOf.ts +++ b/@coven/types/ValueOf.ts @@ -15,6 +15,5 @@ import type { ReadonlyArrayLike } from "./ReadonlyArrayLike.ts"; * @see {@linkcode ReadonlyArrayLike} * @template Object Object or array type. */ -export type ValueOf = Object extends ReadonlyArrayLike - ? Object[number] - : Object[keyof Object]; +export type ValueOf = + Object extends ReadonlyArrayLike ? Object[number] : Object[keyof Object]; diff --git a/@coven/utils/always.ts b/@coven/utils/always.ts index 88068c0..9c775b0 100644 --- a/@coven/utils/always.ts +++ b/@coven/utils/always.ts @@ -14,6 +14,5 @@ import { thunk } from "./thunk.ts"; * @param input Input value to always return. * @returns Function that always return the given value. */ -export const always: (input: Input) => Nullary = thunk( - identity, -); +export const always: (input: Input) => Nullary = + thunk(identity); diff --git a/@coven/utils/applyTo.ts b/@coven/utils/applyTo.ts index a64c7f1..f50116e 100644 --- a/@coven/utils/applyTo.ts +++ b/@coven/utils/applyTo.ts @@ -13,7 +13,9 @@ import type { Unary } from "@coven/types"; * @param input Value to be passed to unary function. * @returns Function that expects a function that will receive the `input`. */ -export const applyTo = ( - input: Input, -): (unary: Unary<[input: Input], Output>) => Output => -(unary) => unary(input); +export const applyTo = + ( + input: Input, + ): ((unary: Unary<[input: Input], Output>) => Output) => + (unary) => + unary(input); diff --git a/@coven/utils/createObject.ts b/@coven/utils/createObject.ts index b71d3d3..744270d 100644 --- a/@coven/utils/createObject.ts +++ b/@coven/utils/createObject.ts @@ -16,7 +16,7 @@ export const createObject = < ): Object => { const nullPrototypeObject = Object.create(null); - return source !== undefined - ? Object.assign(nullPrototypeObject, source) - : nullPrototypeObject; + return source !== undefined ? + Object.assign(nullPrototypeObject, source) + : nullPrototypeObject; }; diff --git a/@coven/utils/get.ts b/@coven/utils/get.ts index b8991ff..f820ad4 100644 --- a/@coven/utils/get.ts +++ b/@coven/utils/get.ts @@ -11,9 +11,11 @@ import type { ReadonlyRecord } from "@coven/types"; * ``` * @returns Curried function with `key` in context. */ -export const get = ( - key: Key, -): >( - object: Source, -) => Source[Key & keyof Source] => -(object) => object[key]; +export const get = + ( + key: Key, + ): (>( + object: Source, + ) => Source[Key & keyof Source]) => + (object) => + object[key]; diff --git a/@coven/utils/mutate.ts b/@coven/utils/mutate.ts index 5c4b6aa..58a389f 100644 --- a/@coven/utils/mutate.ts +++ b/@coven/utils/mutate.ts @@ -12,7 +12,9 @@ * @param update Update to apply to given target. * @returns Curried function with `update` in context. */ -export const mutate = ( - update: Update, -): (target: Target) => Target & Update => -(target) => Object.assign(target, update); +export const mutate = + ( + update: Update, + ): ((target: Target) => Target & Update) => + (target) => + Object.assign(target, update); diff --git a/@coven/utils/seededRandom.ts b/@coven/utils/seededRandom.ts index afe9e4c..76e7f79 100644 --- a/@coven/utils/seededRandom.ts +++ b/@coven/utils/seededRandom.ts @@ -48,10 +48,11 @@ const textEncoder = new TextEncoder(); * @param seed String seed used to generate the pseudo-random number. * @returns A floating-point number between 0 (inclusive) and 1 (exclusive). */ -export const seededRandom: Unary<[seed: Stringable], number> = memo((seed) => - ((textEncoder.encode(`${seed}`).reduce(fnv1aReducer, FNV_OFFSET_32) +export const seededRandom: Unary<[seed: Stringable], number> = memo( + (seed) => + ((textEncoder.encode(`${seed}`).reduce(fnv1aReducer, FNV_OFFSET_32) * LCG_MULTIPLIER - + LCG_INCREMENT) - >>> 0) - / UINT32 + + LCG_INCREMENT) + >>> 0) + / UINT32, ); diff --git a/@coven/utils/set.ts b/@coven/utils/set.ts index 7d3a585..833a49b 100644 --- a/@coven/utils/set.ts +++ b/@coven/utils/set.ts @@ -14,15 +14,15 @@ import { createObject } from "./createObject.ts"; * ``` * @returns Curried function with `key` in context. */ -export const set = ( - key: Key, -): ( - value: Value, -) => ( - object: Source, -) => Omit & Record => -(value: Value) => -(object: Source) => - createObject({ ...object, [key]: value }) as - & Omit - & Record; +export const set = + ( + key: Key, + ): (( + value: Value, + ) => ( + object: Source, + ) => Omit & Record) => + (value: Value) => + (object: Source) => + createObject({ ...object, [key]: value }) as Omit + & Record; diff --git a/@coven/utils/tap.ts b/@coven/utils/tap.ts index 7fe4ab0..87deeb2 100644 --- a/@coven/utils/tap.ts +++ b/@coven/utils/tap.ts @@ -14,10 +14,12 @@ import type { Effect, Unary } from "@coven/types"; * @param tapper Tapper function to be called with the value. * @returns Curried function with `tapper` in context. */ -export const tap = ( - tapper: Unary<[input: Input], Output>, -): >( - tapped: Tapped, -) => Unary<[input: Input], Output> => -(tapped) => -(input) => (tapper(input), tapped(input)) as Output; +export const tap = + ( + tapper: Unary<[input: Input], Output>, + ): (>( + tapped: Tapped, + ) => Unary<[input: Input], Output>) => + (tapped) => + (input) => + (tapper(input), tapped(input)) as Output; diff --git a/@coven/utils/tests/always.test.ts b/@coven/utils/tests/always.test.ts index 2c6f39d..d94489a 100644 --- a/@coven/utils/tests/always.test.ts +++ b/@coven/utils/tests/always.test.ts @@ -2,7 +2,8 @@ import { always } from "@coven/utils"; import { assertEquals } from "@std/assert"; Deno.test("When passing a string, that string is returned when calling", () => - assertEquals(always("✨")(), "✨")); + assertEquals(always("✨")(), "✨"), +); Deno.test( "When passing as a mapper function for an array it acts like fill", diff --git a/@coven/utils/tests/applyTo.test.ts b/@coven/utils/tests/applyTo.test.ts index 157cb45..5c680ce 100644 --- a/@coven/utils/tests/applyTo.test.ts +++ b/@coven/utils/tests/applyTo.test.ts @@ -5,4 +5,5 @@ const double = (value: number) => value * 2; const applyTo21 = applyTo(21); Deno.test("A number and a duplicate function returns double of number", () => - assertStrictEquals(applyTo21(double), 42)); + assertStrictEquals(applyTo21(double), 42), +); diff --git a/@coven/utils/tests/createObject.test.ts b/@coven/utils/tests/createObject.test.ts index cbea52d..771e759 100644 --- a/@coven/utils/tests/createObject.test.ts +++ b/@coven/utils/tests/createObject.test.ts @@ -5,11 +5,14 @@ const object = { "✨": "✨" } as const; Deno.test("Create empty object has no prototype", () => // deno-lint-ignore coven/no-null - assertEquals(Object.getPrototypeOf(createObject()), null)); + assertEquals(Object.getPrototypeOf(createObject()), null), +); Deno.test("Create object has no prototype", () => // deno-lint-ignore coven/no-null - assertEquals(Object.getPrototypeOf(createObject(object)), null)); + assertEquals(Object.getPrototypeOf(createObject(object)), null), +); Deno.test("Created object has all properties of original object", () => - assertEquals(createObject(object), object)); + assertEquals(createObject(object), object), +); diff --git a/@coven/utils/tests/identity.test.ts b/@coven/utils/tests/identity.test.ts index 3601fb9..e43c115 100644 --- a/@coven/utils/tests/identity.test.ts +++ b/@coven/utils/tests/identity.test.ts @@ -4,7 +4,9 @@ import { assertStrictEquals } from "@std/assert"; const anObject = { lucky: 13 }; Deno.test("Identity returns the same string it receives", () => - assertStrictEquals(identity("✨"), "✨")); + assertStrictEquals(identity("✨"), "✨"), +); Deno.test("Identity returns the same object it receives, not a copy", () => - assertStrictEquals(identity(anObject), anObject)); + assertStrictEquals(identity(anObject), anObject), +); diff --git a/@coven/utils/tests/set.test.ts b/@coven/utils/tests/set.test.ts index 70ad882..7179a41 100644 --- a/@coven/utils/tests/set.test.ts +++ b/@coven/utils/tests/set.test.ts @@ -25,4 +25,5 @@ Deno.test("Setter doesn't mutate original object", () => }, { "✨": false }, ], - )); + ), +); diff --git a/@coven/utils/tests/tap.test.ts b/@coven/utils/tests/tap.test.ts index 2f1397b..8feb329 100644 --- a/@coven/utils/tests/tap.test.ts +++ b/@coven/utils/tests/tap.test.ts @@ -8,4 +8,5 @@ const tappedTest = tap((argument: boolean) => (tapped = argument))( const EXPECTED = true; Deno.test("Tapped function returns expected value but runs tapper first", () => - assertEquals([tappedTest(EXPECTED), tapped], ["✨", EXPECTED])); + assertEquals([tappedTest(EXPECTED), tapped], ["✨", EXPECTED]), +); diff --git a/@coven/utils/tests/thunk.test.ts b/@coven/utils/tests/thunk.test.ts index 57a4426..9349277 100644 --- a/@coven/utils/tests/thunk.test.ts +++ b/@coven/utils/tests/thunk.test.ts @@ -5,4 +5,5 @@ const double = (value: number) => value * 2; const thunkDouble = thunk(double); Deno.test("Thunk for a double function returns delayed double function", () => - assertEquals(thunkDouble(21)(), 42)); + assertEquals(thunkDouble(21)(), 42), +); diff --git a/@coven/utils/thunk.ts b/@coven/utils/thunk.ts index 40985fd..0dc5db8 100644 --- a/@coven/utils/thunk.ts +++ b/@coven/utils/thunk.ts @@ -14,7 +14,9 @@ import type { Nullary, Unary } from "@coven/types"; * ``` * @returns Function that will run the given function when called. */ -export const thunk = ( - unary: Unary<[input: Input], Output>, -): Unary<[input: Input], Nullary> => -(input) => memo(() => unary(input)); +export const thunk = + ( + unary: Unary<[input: Input], Output>, + ): Unary<[input: Input], Nullary> => + (input) => + memo(() => unary(input)); diff --git a/@simulcast/core/BroadcastObject.ts b/@simulcast/core/BroadcastObject.ts index a824172..c1aece9 100644 --- a/@simulcast/core/BroadcastObject.ts +++ b/@simulcast/core/BroadcastObject.ts @@ -9,7 +9,7 @@ import type { EventTypeDictionary } from "./EventTypeDictionary.ts"; * Object containing `emit` and `on` methods with a shared event dictionary. */ export type BroadcastObject = Readonly< - & { + { /** * Emit events for the current broadcast registry. * @@ -32,17 +32,14 @@ export type BroadcastObject = Readonly< * Broadcast registry. */ registry: EventRegistry; - } - & { + } & { /** * Dynamically generated `emit`. */ - [Event in keyof Events as `emit${Capitalize}`]: - EventHandler< - Events[Event] - >; - } - & { + [Event in keyof Events as `emit${Capitalize}`]: EventHandler< + Events[Event] + >; + } & { /** * Dynamically generated `on`. */ diff --git a/@simulcast/core/emit.ts b/@simulcast/core/emit.ts index f880075..f8d9d1a 100644 --- a/@simulcast/core/emit.ts +++ b/@simulcast/core/emit.ts @@ -24,9 +24,9 @@ import type { EventTypeDictionary } from "./EventTypeDictionary.ts"; */ export const emit = ( eventRegistry: EventRegistry, -): ( +): (( event: Event, -) => EventHandler => +) => EventHandler) => memo((event: Event) => { const getEventHandlers = get(event) as ( eventRegistry: EventRegistry, @@ -36,9 +36,8 @@ export const emit = ( return ((data) => { if (hasEventHandlers(eventRegistry)) { const applyToData = applyTo(data); - const applyEachHandlerToData = forEach< - EventHandler - >(applyToData); + const applyEachHandlerToData = + forEach>(applyToData); const eventHandlers = getEventHandlers(eventRegistry); applyEachHandlerToData(eventHandlers); diff --git a/@simulcast/core/on.ts b/@simulcast/core/on.ts index 3675ae2..fc98091 100644 --- a/@simulcast/core/on.ts +++ b/@simulcast/core/on.ts @@ -32,9 +32,9 @@ import type { EventTypeDictionary } from "./EventTypeDictionary.ts"; */ export const on = ( eventRegistry: EventRegistry, -): ( +): (( event: Event, -) => (handler: EventHandler) => Effect => +) => (handler: EventHandler) => Effect) => memo((event: Event) => { const getEventHandlers = get(event) as ( eventRegistry: EventRegistry, @@ -50,9 +50,9 @@ export const on = ( ); const eventHandlers = getEventHandlers(eventRegistry); const setNewHandlers = setEventHandlers( - hasEventHandlers(eventRegistry) - ? appendHandler(eventHandlers) - : handlerIterable, + hasEventHandlers(eventRegistry) ? + appendHandler(eventHandlers) + : handlerIterable, ); const commitUpdate = mutate(setNewHandlers(eventRegistry)); diff --git a/@simulcast/core/tests/broadcast.test.ts b/@simulcast/core/tests/broadcast.test.ts index 7d0506c..2cb112a 100644 --- a/@simulcast/core/tests/broadcast.test.ts +++ b/@simulcast/core/tests/broadcast.test.ts @@ -15,10 +15,12 @@ Deno.test("Emit with handlers calls the handlers", () => { }); Deno.test("Generated and manual emit are the same", () => - assertStrictEquals(emitTest, emit("test"))); + assertStrictEquals(emitTest, emit("test")), +); Deno.test("Generated and manual on are the same", () => - assertStrictEquals(onTest, on("test"))); + assertStrictEquals(onTest, on("test")), +); Deno.test("Custom emit with custom handlers calls the handlers", () => { let called = false; diff --git a/@simulcast/core/tests/emit.test.ts b/@simulcast/core/tests/emit.test.ts index 1f0c975..1538ef7 100644 --- a/@simulcast/core/tests/emit.test.ts +++ b/@simulcast/core/tests/emit.test.ts @@ -21,10 +21,12 @@ Deno.test("Emit without handlers does nothing", () => TEST_EVENT, )(), undefined, - )); + ), +); Deno.test("Emit without an event does nothing", () => assertStrictEquals( emit(EMPTY_OBJECT)(TEST_EVENT)(), undefined, - )); + ), +); diff --git a/@simulcast/preact/README.md b/@simulcast/preact/README.md index 15e0c28..ad180a0 100644 --- a/@simulcast/preact/README.md +++ b/@simulcast/preact/README.md @@ -23,10 +23,7 @@ const Component = () => { onClick(console.log); return ( - ); diff --git a/@simulcast/preact/UseBroadcastObject.ts b/@simulcast/preact/UseBroadcastObject.ts index 81b16e0..f2e6954 100644 --- a/@simulcast/preact/UseBroadcastObject.ts +++ b/@simulcast/preact/UseBroadcastObject.ts @@ -9,8 +9,7 @@ import type { UseBroadcastOn } from "./UseBroadcastOn.ts"; * Object containing `emit` and `on` methods with a shared event dictionary. */ export type UseBroadcastObject = Readonly< - & Omit, `on${string}`> - & { + Omit, `on${string}`> & { /** * Like `on` but with unmount lifecycle cleanup. * @@ -19,8 +18,7 @@ export type UseBroadcastObject = Readonly< * @param dependencies Underlying effect dependencies to trigger a cleanup of the handler. */ on: UseBroadcastOn; - } - & { + } & { /** * @param handler Function to run when event is emitted. * @param dependencies Passed directly to the underlying effect. diff --git a/@simulcast/preact/tests/useBroadcast.test.tsx b/@simulcast/preact/tests/useBroadcast.test.tsx index 46b99a4..af6066c 100644 --- a/@simulcast/preact/tests/useBroadcast.test.tsx +++ b/@simulcast/preact/tests/useBroadcast.test.tsx @@ -10,11 +10,7 @@ const CountComponent = (properties: ComponentProps<"button">) => { const [count, setCount] = useState(0); return ( - ); @@ -37,11 +33,7 @@ const BroadcastComponent = ({ onClick(() => state.calledTimes++); return ( - ); @@ -58,18 +50,15 @@ Deno.test( }>(); render( - ( - <> - - - - ), + <> + + + , ); const addButton = screen.getByTitle("Add"); - const broadcastButton = screen.getByTitle( - "Broadcast", - ); + const broadcastButton = + screen.getByTitle("Broadcast"); await userEvent.click(addButton); // Click button that will re-render once await userEvent.click(addButton); // Click button that will re-render twice @@ -92,14 +81,9 @@ Deno.test("Broadcast's on handler is removed when unmounted", async () => { return ( <> - {visible - ? ( - - ) - : undefined} + {visible ? + + : undefined} { const toggleButton = screen.getByTitle("Toggle"); const broadcastButton = screen.getByTitle("Broadcast"); - const alwaysVisibleBroadcastButton = screen.getByTitle< - HTMLButtonElement - >("Always visible Broadcast"); + const alwaysVisibleBroadcastButton = screen.getByTitle( + "Always visible Broadcast", + ); // Click broadcast button that will be removed from the DOM await userEvent.click(broadcastButton); diff --git a/@simulcast/react/README.md b/@simulcast/react/README.md index f0d3cf6..7b4160d 100644 --- a/@simulcast/react/README.md +++ b/@simulcast/react/README.md @@ -23,10 +23,7 @@ const Component = () => { onClick(console.log); return ( - ); diff --git a/@simulcast/react/tests/useBroadcast.test.tsx b/@simulcast/react/tests/useBroadcast.test.tsx index 1df57b8..1f0a339 100644 --- a/@simulcast/react/tests/useBroadcast.test.tsx +++ b/@simulcast/react/tests/useBroadcast.test.tsx @@ -9,11 +9,7 @@ const CountComponent = (properties: ComponentProps<"button">) => { const [count, setCount] = useState(0); return ( - ); @@ -34,11 +30,7 @@ const BroadcastComponent = ({ onClick(() => state.calledTimes++); return ( - ); @@ -55,18 +47,15 @@ Deno.test( }>(); render( - ( - <> - - - - ), + <> + + + , ); const addButton = screen.getByTitle("Add"); - const broadcastButton = screen.getByTitle( - "Broadcast", - ); + const broadcastButton = + screen.getByTitle("Broadcast"); await userEvent.click(addButton); // Click button that will re-render once await userEvent.click(addButton); // Click button that will re-render twice @@ -89,14 +78,9 @@ Deno.test("Broadcast's on handler is removed when unmounted", async () => { return ( <> - {visible - ? ( - - ) - : undefined} + {visible ? + + : undefined} { const toggleButton = screen.getByTitle("Toggle"); const broadcastButton = screen.getByTitle("Broadcast"); - const alwaysVisibleBroadcastButton = screen.getByTitle< - HTMLButtonElement - >("Always visible Broadcast"); + const alwaysVisibleBroadcastButton = screen.getByTitle( + "Always visible Broadcast", + ); // Click broadcast button that will be removed from the DOM diff --git a/@simulcast/vue/README.md b/@simulcast/vue/README.md index 44ba2bb..53de622 100644 --- a/@simulcast/vue/README.md +++ b/@simulcast/vue/README.md @@ -20,12 +20,7 @@ ``` diff --git a/@simulcast/vue/UseBroadcastObject.ts b/@simulcast/vue/UseBroadcastObject.ts index f8e1dbf..0e53a52 100644 --- a/@simulcast/vue/UseBroadcastObject.ts +++ b/@simulcast/vue/UseBroadcastObject.ts @@ -9,8 +9,7 @@ import type { UseBroadcastOn } from "./UseBroadcastOn.ts"; * Object containing `emit` and `on` methods with a shared event dictionary. */ export type UseBroadcastObject = Readonly< - & Omit, `on${string}`> - & { + Omit, `on${string}`> & { /** * Like `on` but with unmount lifecycle cleanup. * @@ -18,8 +17,7 @@ export type UseBroadcastObject = Readonly< * @param handler Event handler. */ on: UseBroadcastOn; - } - & { + } & { /** * @param handler Function to run when event is emitted. */ diff --git a/@simulcast/vue/tests/useBroadcast.test.ts b/@simulcast/vue/tests/useBroadcast.test.ts index c05af8a..6b25407 100644 --- a/@simulcast/vue/tests/useBroadcast.test.ts +++ b/@simulcast/vue/tests/useBroadcast.test.ts @@ -71,9 +71,8 @@ Deno.test( ); const addButton = wrapper.find("button.add"); - const broadcastButton = wrapper.find( - "button.broadcast", - ); + const broadcastButton = + wrapper.find("button.broadcast"); await addButton.trigger("click"); // Click button that will re-render once await addButton.trigger("click"); // Click button that will re-render twice diff --git a/@simulcast/vue/useBroadcastProxyHandler.ts b/@simulcast/vue/useBroadcastProxyHandler.ts index 10a5524..16c2c35 100644 --- a/@simulcast/vue/useBroadcastProxyHandler.ts +++ b/@simulcast/vue/useBroadcastProxyHandler.ts @@ -24,7 +24,7 @@ export const useBroadcastProxyHandler: Readonly<{ const on = Reflect.get(broadcast, "on"); const event = `${name.slice(0, 1).toLowerCase()}${name.slice(1)}`; const setHandler = setProperty((handler: EventHandler) => - on(event, handler) + on(event, handler), )(broadcast); const commitHandler = mutate(setHandler); diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 4594b8b..9720533 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -92,43 +92,43 @@ and the community as a whole. Depending on the severity of a violation, lower rungs on the ladder may be skipped. 1. Warning - 1. Event: A violation involving a single incident or series of incidents. - 2. Consequence: A private, written warning from the Community Moderators. - 3. Repair: Examples of repair include a private written apology, - acknowledgement of responsibility, and seeking clarification on - expectations. + 1. Event: A violation involving a single incident or series of incidents. + 2. Consequence: A private, written warning from the Community Moderators. + 3. Repair: Examples of repair include a private written apology, + acknowledgement of responsibility, and seeking clarification on + expectations. 2. Temporarily Limited Activities - 1. Event: A repeated incidence of a violation that previously resulted in a - warning, or the first incidence of a more serious violation. - 2. Consequence: A private, written warning with a time-limited cooldown - period designed to underscore the seriousness of the situation and give - the community members involved time to process the incident. The cooldown - period may be limited to particular communication channels or interactions - with particular community members. - 3. Repair: Examples of repair may include making an apology, using the - cooldown period to reflect on actions and impact, and being thoughtful - about re-entering community spaces after the period is over. + 1. Event: A repeated incidence of a violation that previously resulted in a + warning, or the first incidence of a more serious violation. + 2. Consequence: A private, written warning with a time-limited cooldown + period designed to underscore the seriousness of the situation and give + the community members involved time to process the incident. The cooldown + period may be limited to particular communication channels or + interactions with particular community members. + 3. Repair: Examples of repair may include making an apology, using the + cooldown period to reflect on actions and impact, and being thoughtful + about re-entering community spaces after the period is over. 3. Temporary Suspension - 1. Event: A pattern of repeated violation which the Community Moderators have - tried to address with warnings, or a single serious violation. - 2. Consequence: A private written warning with conditions for return from - suspension. In general, temporary suspensions give the person being - suspended time to reflect upon their behavior and possible corrective - actions. - 3. Repair: Examples of repair include respecting the spirit of the - suspension, meeting the specified conditions for return, and being - thoughtful about how to reintegrate with the community when the suspension - is lifted. + 1. Event: A pattern of repeated violation which the Community Moderators + have tried to address with warnings, or a single serious violation. + 2. Consequence: A private written warning with conditions for return from + suspension. In general, temporary suspensions give the person being + suspended time to reflect upon their behavior and possible corrective + actions. + 3. Repair: Examples of repair include respecting the spirit of the + suspension, meeting the specified conditions for return, and being + thoughtful about how to reintegrate with the community when the + suspension is lifted. 4. Permanent Ban - 1. Event: A pattern of repeated code of conduct violations that other steps - on the ladder have failed to resolve, or a violation so serious that the - Community Moderators determine there is no way to keep the community safe - with this person as a member. - 2. Consequence: Access to all community spaces, tools, and communication - channels is removed. In general, permanent bans should be rarely used, - should have strong reasoning behind them, and should only be resorted to - if working through other remedies has failed to change the behavior. - 3. Repair: There is no possible repair in cases of this severity. + 1. Event: A pattern of repeated code of conduct violations that other steps + on the ladder have failed to resolve, or a violation so serious that the + Community Moderators determine there is no way to keep the community safe + with this person as a member. + 2. Consequence: Access to all community spaces, tools, and communication + channels is removed. In general, permanent bans should be rarely used, + should have strong reasoning behind them, and should only be resorted to + if working through other remedies has failed to change the behavior. + 3. Repair: There is no possible repair in cases of this severity. This enforcement ladder is intended as a guideline. It does not limit the ability of Community Managers to use their discretion and judgment, in keeping @@ -144,16 +144,16 @@ representative at an online or offline event. ## Attribution -This Code of Conduct is adapted from the -[Contributor Covenant, version 3.0][v3.0]. +This Code of Conduct is adapted from the [Contributor Covenant, version +3.0][v3.0]. Contributor Covenant is stewarded by the Organization for Ethical Source and licensed under [CC BY-SA 4.0][creativecommons]. For answers to common questions about Contributor Covenant, see the [FAQ][FAQ]. Translations are provided at [Contributor Covenant's site][translations]. The -enforcement ladder was inspired by the work of -[Mozilla’s code of conduct team][MozillaCoC]. +enforcement ladder was inspired by the work of [Mozilla’s code of conduct +team][MozillaCoC]. [contact]: mailto:contact@coven.engineering [creativecommons]: https://creativecommons.org/licenses/by-sa/4.0/ diff --git a/README.md b/README.md index 214b443..6440370 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,11 @@ libraries: - 🛠️ [`@coven/utils`](https://coven.to/utils) — General utilities. - 📡 [`@simulcast/core`](https://simulcast.coven.to/core) — Cross-framework communication. - - 📡 [`@simulcast/angular`](https://simulcast.coven.to/angular) — Angular - service for `@simulcast/core`. - - 📡 [`@simulcast/preact`](https://simulcast.coven.to/preact) — Preact hook - for `@simulcast/core`. - - 📡 [`@simulcast/react`](https://simulcast.coven.to/react) — React hook for - `@simulcast/core`. - - 📡 [`@simulcast/vue`](https://simulcast.coven.to/vue) — Vue composable for - `@simulcast/core`. + - 📡 [`@simulcast/angular`](https://simulcast.coven.to/angular) — Angular + service for `@simulcast/core`. + - 📡 [`@simulcast/preact`](https://simulcast.coven.to/preact) — Preact hook + for `@simulcast/core`. + - 📡 [`@simulcast/react`](https://simulcast.coven.to/react) — React hook for + `@simulcast/core`. + - 📡 [`@simulcast/vue`](https://simulcast.coven.to/vue) — Vue composable for + `@simulcast/core`. diff --git a/deno.json b/deno.json index a83b54f..d9b8260 100644 --- a/deno.json +++ b/deno.json @@ -73,11 +73,12 @@ "nodeModulesDir": "auto", "tasks": { "format": { - "command": "deno run --allow-env=TMPDIR --ignore-env --allow-read=.,$TMPDIR/.prettier-cache --allow-write=.,$TMPDIR/.prettier-cache --allow-sys=cpus --no-prompt prettier --log-level=warn --write './**/*.{json,md,ts,tsx}'", + "TMPDIR=. deno run --allow-env=TMPDIR --allow-read=. --allow-sys=cpus --allow-write=. --ignore-env --log-level=warn --no-prompt prettier --write './**/*.{json,md,ts,tsx}'": "", + "command": "TMPDIR=. deno run --allow-env=TMPDIR --allow-read=. --allow-sys=cpus --allow-write=. --ignore-env --no-prompt prettier --log-level=warn --write './**/*.{json,md,ts,tsx}'", "description": "Format code using Prettier" }, "format-check": { - "command": "deno run --allow-env=TMPDIR --ignore-env --allow-read=.,$TMPDIR/.prettier-cache --allow-sys=cpus --no-prompt prettier --check './**/*.{json,md,ts,tsx}'", + "command": "TMPDIR=. deno run --allow-env=TMPDIR --allow-read=. --allow-sys=cpus --ignore-env --no-prompt prettier --check './**/*.{json,md,ts,tsx}'", "description": "Check formatting using Prettier" }, "lint-docs": { diff --git a/lint/no.ts b/lint/no.ts index 2ccc262..cbd19b5 100644 --- a/lint/no.ts +++ b/lint/no.ts @@ -12,15 +12,16 @@ type FindContext< export const no = ( visitor: Visitor, message: string, - condition?: ( - data: { context: Deno.lint.RuleContext; node: FindContext }, - ) => boolean, + condition?: (data: { + context: Deno.lint.RuleContext; + node: FindContext; + }) => boolean, ): Deno.lint.Rule => ({ create: (context): Deno.lint.LintVisitor => ({ [visitor]: (node: FindContext): void => { - (condition?.({ context, node }) ?? true) - ? context.report({ message, node }) - : undefined; + (condition?.({ context, node }) ?? true) ? + context.report({ message, node }) + : undefined; }, }), });