Skip to content

Commit

Permalink
πŸ”– 0.3.0 of everything
Browse files Browse the repository at this point in the history
  • Loading branch information
loucyx committed Oct 21, 2024
1 parent 7981dd0 commit 3913a17
Show file tree
Hide file tree
Showing 254 changed files with 835 additions and 894 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ jobs:
- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: 2.0.0
deno-version: 2.0.2

- name: Lint
- name: Lint code
run: deno lint

- name: Lint docs
run: deno run lint-docs

- name: Format
run: deno fmt --check
run: deno run format-check

- name: Test
run: deno test --coverage
run: deno run test-coverage

- name: Generate Coverage
run: deno coverage --lcov coverage/ > coverage.lcov
Expand Down
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
"source.organizeImports": "explicit"
},
"editor.defaultFormatter": "denoland.vscode-deno",
"editor.formatOnSave": true
"editor.formatOnSave": true,
"[yaml]": {
"editor.insertSpaces": true,
"editor.tabSize": 4,
"editor.autoIndent": "advanced",
"diffEditor.ignoreTrimWhitespace": false
}
}
Binary file removed @coven/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion @coven/compare/CreateDifference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { WithPropertyPath } from "./WithPropertyPath.ts";
*
* @example Object that satisfies a creation difference
* ```typescript
* const createDifference = ({
* ({
* kind: "CREATE",
* right: "created value",
* path: ["property", "path"].values()
Expand Down
2 changes: 1 addition & 1 deletion @coven/compare/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![JSR](https://jsr.io/badges/@coven/compare)](https://jsr.io/@coven/compare)
[![JSR Score](https://jsr.io/badges/@coven/compare/score)](https://jsr.io/@coven/compare/score)

πŸͺž Minimalistic deep comparison.
βš–οΈ Minimalist diffing.

This library takes 2 values (a `left` and a `right`) and returns an iterator
with all the differences between said values. The differences are represented by
Expand Down
19 changes: 3 additions & 16 deletions @coven/compare/compare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,15 @@ const alwaysFalse = always(false);
*
* @example Using compare with strings
* ```typescript
* import { flat } from "@coven/compare";
* import { assertEquals } from "@std/assert";
*
* const witchCompare = compare("πŸ§™β€β™€οΈ");
*
* assertEquals(flat(witchCompare("πŸ§™β€β™€οΈ")), []);
* assertEquals(
* flat(witchCompare("πŸŽƒ")),
* [{ kind: "UPDATE", left: "πŸ§™β€β™€οΈ", right: "πŸŽƒ", path: [] }]
* );
* witchCompare("πŸ§™β€β™€οΈ"); // Yields nothing
* witchCompare("πŸŽƒ"); // Yields { kind: "UPDATE", left: "πŸ§™β€β™€οΈ", right: "πŸŽƒ", path: [] }
* ```
* @example Using compare with objects
* ```typescript
* import { flat } from "@coven/compare";
* import { assertEquals } from "@std/assert";
*
* const witchObjectCompare = compare({ witch: "πŸ§™β€β™€οΈ" });
*
* assertEquals(
* flat(witchObjectCompare({ witch: "πŸŽƒ" })),
* [{ kind: "UPDATE", left: "πŸ§™β€β™€οΈ", right: "πŸŽƒ", path: ["witch"] }],
* );
* witchObjectCompare({ witch: "πŸŽƒ" }); // Yields { kind: "UPDATE", left: "πŸ§™β€β™€οΈ", right: "πŸŽƒ", path: ["witch"] }
* ```
* @see {@linkcode CurriedComparison}
* @see {@linkcode compareObjects}
Expand Down
13 changes: 2 additions & 11 deletions @coven/compare/compareIterables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,10 @@ import { pathPrepend } from "./pathPrepend.ts";
*
* @example Compare 2 arrays of numbers
* ```typescript
* import { flat } from "@coven/compare";
* import { assertEquals } from "@std/assert";
*
* const compare1342 = compareIterables([13, 42]);
*
* assertEquals(
* flat(compare1342([13, 42])),
* [],
* );
* assertEquals(
* flat(compare1342([13, 665])),
* [{ kind: "UPDATE", left: 42, right: 665, path: [1] }]
* );
* compare1342([13, 42]); // Yields nothing
* compare1342([13, 665]); // Yields { kind: "UPDATE", left: 42, right: 665, path: [1] }
* ```
* @see {@linkcode compare}
* @param left Original iterable.
Expand Down
8 changes: 1 addition & 7 deletions @coven/compare/compareObjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@ import type { Difference } from "./Difference.ts";
*
* @example Compare 2 objects with the same property but different value
* ```typescript
* import { flat } from "@coven/compare";
* import { assertEquals } from "@std/assert";
*
* const compareWitch = compareObjects({ witch: "πŸ§™β€β™€οΈ" });
* assertEquals(
* flat(compareWitch({ witch: "πŸŽƒ" })),
* [{ kind: "UPDATE", left: "πŸ§™β€β™€οΈ", right: "πŸŽƒ", path: ["witch"] }]
* );
* compareWitch({ witch: "πŸŽƒ" }); // Yields { kind: "UPDATE", left: "πŸ§™β€β™€οΈ", right: "πŸŽƒ", path: ["witch"] }
* ```
* @see {@linkcode compareIterables}
* @see {@linkcode compareProperties}
Expand Down
9 changes: 1 addition & 8 deletions @coven/compare/compareProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,8 @@ import { pathPrepend } from "./pathPrepend.ts";
*
* @example Compare objects
* ```typescript
* import { flat } from "@coven/compare";
* import { assertEquals } from "@std/assert";
*
* const compareWitch = compareProperties({ witch: "πŸ§™β€β™€οΈ" });
*
* assertEquals(
* flat(compareWitch({ witch: "πŸŽƒ" })),
* [{ kind: "UPDATE", left: "πŸ§™β€β™€οΈ", right: "πŸŽƒ", path: ["witch"] }],
* );
* compareWitch({ witch: "πŸŽƒ" }); // Yields { kind: "UPDATE", left: "πŸ§™β€β™€οΈ", right: "πŸŽƒ", path: ["witch"] }
* ```
* @see {@linkcode compare}
* @see {@linkcode getKeys}
Expand Down
2 changes: 1 addition & 1 deletion @coven/compare/deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@coven/compare",
"version": "0.2.0",
"version": "0.3.0",
"exports": "./mod.ts"
}
34 changes: 8 additions & 26 deletions @coven/compare/differentiate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,44 +26,26 @@ const differenceBase = { path: toIterable(EMPTY_ARRAY) };
*
* @example Missing right value
* ```typescript
* import { MISSING_VALUE, flat } from "@coven/compare";
* import { assertEquals } from "@std/assert";
* import { MISSING_VALUE } from "@coven/compare";
*
* assertEquals(
* flat(differentiate("πŸ§™β€β™€οΈ")(MISSING_VALUE)),
* [{ kind: "DELETE", left: "πŸ§™β€β™€οΈ", path: [] }]
* );
* differentiate("πŸ§™β€β™€οΈ")(MISSING_VALUE); // Yields { kind: "DELETE", left: "πŸ§™β€β™€οΈ", path: [] }
* ```
* @example Missing left value
* ```typescript
* import { MISSING_VALUE, flat } from "@coven/compare";
* import { assertEquals } from "@std/assert";
* import { MISSING_VALUE } from "@coven/compare";
*
* assertEquals(
* flat(differentiate(MISSING_VALUE)("πŸŽƒ")),
* [{ kind: "CREATE", right: "πŸŽƒ", path: [] }]
* );
* differentiate(MISSING_VALUE)("πŸŽƒ"); // Yields { kind: "CREATE", right: "πŸŽƒ", path: [] }
* ```
* @example Both values set
* ```typescript
* import { flat } from "@coven/compare";
* import { assertEquals } from "@std/assert";
*
* assertEquals(
* flat(differentiate("πŸ§™β€β™€οΈ")("πŸŽƒ")),
* [{ kind: "UPDATE", left: "πŸ§™β€β™€οΈ", right: "πŸŽƒ", path: [] }]
* );
* differentiate("πŸ§™β€β™€οΈ")("πŸ§™β€β™€οΈ"); // yields []
* differentiate("πŸ§™β€β™€οΈ")("πŸŽƒ"); // Yields { kind: "UPDATE", left: "πŸ§™β€β™€οΈ", right: "πŸŽƒ", path: [] }
* differentiate("πŸ§™β€β™€οΈ")("πŸ§™β€β™€οΈ"); // Yields nothing
* ```
* @example Both values missing
* ```typescript
* import { MISSING_VALUE, flat } from "@coven/compare";
* import { assertEquals } from "@std/assert";
* import { MISSING_VALUE } from "@coven/compare";
*
* assertEquals(
* flat(differentiate(MISSING_VALUE)(MISSING_VALUE)),
* []
* );
* differentiate(MISSING_VALUE)(MISSING_VALUE); // Yields nothing
* ```
* @see {@linkcode Difference}
* @param left Left/Original value.
Expand Down
10 changes: 3 additions & 7 deletions @coven/compare/flat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ import { flatPathMap } from "./flatPathMap.ts";
* @example Flatting a creation Difference
* ```typescript
* import type { Difference } from "@coven/compare";
* import { assertEquals } from "@std/assert";
*
* assertEquals(flat([{
* flat([{
* kind: "CREATE",
* path: ["property", "path"].values(),
* right: "created value",
* }].values() as Iterable<Difference>), [{
* kind: "CREATE",
* path: ["property", "path"],
* right: "created value",
* }])
* }].values() as Iterable<Difference>);
* // [{ kind: "CREATE", path: ["property", "path"], right: "created value" }]
* ```
* @see {@linkcode Difference}
* @see {@linkcode FlatDifference}
Expand Down
5 changes: 2 additions & 3 deletions @coven/compare/getKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ const isFunctionConstructor = is(Function);
*
* @example Get keys of a plain object
* ```typescript
* import { assertEquals } from "@std/assert";
*
* assertEquals([...getKeys({})], []);
* getKeys({}); // Yields nothing
* getKeys({ coven: "engineering" }); // Yields "coven"
* ```
* @param object Object to get the keys from.
* @yields Object keys.
Expand Down
12 changes: 2 additions & 10 deletions @coven/compare/pathPrepend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,11 @@ import { setPath } from "./setPath.ts";
*
* @example Prepend string to path
* ```typescript
* import { flat } from "@coven/compare";
* import { assertEquals } from "@std/assert";
*
* assertEquals(flat([
* pathPrepend("coven")({
* pathPrepend("coven")({
* kind: "DELETE",
* left: 13,
* path: ["engineering"].values()
* })]), [{
* kind: "DELETE",
* left: 13,
* path: ["coven", "engineering"]
* }]);
* }); // Yields { kind: "DELETE", left: 13, path: ["coven", "engineering"] }
* ```
* @param prepend Property to prepend.
* @returns Curried generator with `prepend` in context.
Expand Down
7 changes: 5 additions & 2 deletions @coven/constants/EMPTY_ARRAY.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/**
* Empty read-only array. The array is read-only in runtime by `Object.freeze`,
* so trying to do mutations will throw.
* Empty read-only array.
*
* > [!IMPORTANT]
* > The array is read-only in runtime by `Object.freeze`, so trying to do
* > mutations will throw.
*
* @see [Object.freeze](https://mdn.io/Oject.freeze)
*/
Expand Down
7 changes: 5 additions & 2 deletions @coven/constants/EMPTY_OBJECT.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/**
* Empty read-only `null` prototype object. The object is read-only in runtime
* by `Object.freeze`, so trying to do mutations will throw.
* Empty read-only `null` prototype object.
*
* > [!IMPORTANT]
* > The object is read-only in runtime by `Object.freeze`, so trying to do
* > mutations will throw.
*
* @see [Object.create](https://mdn.io/Object.create)
* @see [Object.freeze](https://mdn.io/Object.freeze)
Expand Down
4 changes: 3 additions & 1 deletion @coven/constants/EMPTY_STRING.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/**
* Empty string. This one exists to have something more readable than `""`.
* Empty string.
*
* This one exists to have something more readable than `""`.
*/
export const EMPTY_STRING = "";
11 changes: 4 additions & 7 deletions @coven/constants/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,13 @@
[![JSR](https://jsr.io/badges/@coven/constants)](https://jsr.io/@coven/constants)
[![JSR Score](https://jsr.io/badges/@coven/constants/score)](https://jsr.io/@coven/constants/score)

πŸ“– Shared constants scrolls.
🧱 Common constants.

## Constants

- `EMPTY_ARRAY`: Empty read-only array. The array is read-only in runtime by
`Object.freeze`, so trying to do mutations will throw.
- `EMPTY_OBJECT`: Empty read-only `null` prototype object. The object is
read-only in runtime by `Object.freeze`, so trying to do mutations will throw.
- `EMPTY_STRING`: Empty string. This one exists to have something more readable
than `""`.
- `EMPTY_ARRAY`: Empty read-only array.
- `EMPTY_OBJECT`: Empty read-only `null` prototype object.
- `EMPTY_STRING`: Empty string.

## Example

Expand Down
2 changes: 1 addition & 1 deletion @coven/constants/deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@coven/constants",
"version": "0.1.0",
"version": "0.3.0",
"exports": "./mod.ts"
}
4 changes: 2 additions & 2 deletions @coven/cron/CronObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { MonthValue } from "./MonthValue.ts";
/**
* Object that represents the 5 cron expression fields.
*
* @see {@link Field}
* @see {@link MonthValue}
* @see {@linkcode Field}
* @see {@linkcode MonthValue}
*/
export type CronObject = {
readonly dayOfMonth: Field<DayOfMonth>;
Expand Down
8 changes: 4 additions & 4 deletions @coven/cron/Field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import type { ListField } from "./ListField.ts";
import type { ValueOrRangeField } from "./ValueOrRangeField.ts";

/**
* Union of {@link AllToken}, {@link ValueOrRangeField} and {@link ListField}
* Union of {@linkcode AllToken}, {@linkcode ValueOrRangeField} and {@linkcode ListField}
* that represents a field in a cron expression.
*
* @see {@link AllToken}
* @see {@link ValueOrRangeField}
* @see {@link ListField}
* @see {@linkcode AllToken}
* @see {@linkcode ValueOrRangeField}
* @see {@linkcode ListField}
*/
export type Field<Value extends number> =
| AllToken
Expand Down
8 changes: 4 additions & 4 deletions @coven/cron/FieldString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import type { ListString } from "./ListString.ts";
import type { ValueOrRangeString } from "./ValueOrRangeString.ts";

/**
* Union of {@link AllToken}, {@link ValueOrRangeString} and {@link ListString}
* Union of {@linkcode AllToken}, {@linkcode ValueOrRangeString} and {@linkcode ListString}
* that represents a field in a cron expression.
*
* @see {@link AllToken}
* @see {@link ValueOrRangeString}
* @see {@link ListString}
* @see {@linkcode AllToken}
* @see {@linkcode ValueOrRangeString}
* @see {@linkcode ListString}
*/
export type FieldString = AllToken | ListString | ValueOrRangeString;
2 changes: 1 addition & 1 deletion @coven/cron/ListField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ValueOrRangeField } from "./ValueOrRangeField.ts";
/**
* Type that represents a list of values for a cron object field.
*
* @see {@link ValueOrRangeField}
* @see {@linkcode ValueOrRangeField}
*/
export type ListField<Value extends number> = ReadonlyArray<
ValueOrRangeField<Value>
Expand Down
2 changes: 1 addition & 1 deletion @coven/cron/ListString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ValueOrRangeString } from "./ValueOrRangeString.ts";
/**
* Type that represents a list of values for a cron string field.
*
* @see {@link ValueOrRangeString}
* @see {@linkcode ValueOrRangeString}
*/
export type ListString =
`${string}${ListExpressionSeparatorToken}${ValueOrRangeString}`;
Loading

0 comments on commit 3913a17

Please sign in to comment.