Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 23 additions & 30 deletions @coven/compare/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
![Coven Engineering Compare](https://raw.githubusercontent.com/covenengineering/libraries/main/@coven/compare/logo.svg)
![Coven Engineering Compare][logo]

[![JSR](https://jsr.io/badges/@coven/compare)](https://coven.to/compare)
[![JSR Score](https://jsr.io/badges/@coven/compare/score)](https://coven.to/compare/score)
[![Coverage Status](https://img.shields.io/codecov/c/github/covenengineering/libraries?color=%23083344&component=coven__compare&label=Codecov&labelColor=%23F01F7A&logo=Codecov&logoColor=%23fff)](https://app.codecov.io/github/covenengineering/libraries?components[0]=Coven%20Engineering%20Compare)
[![JSR][jsr-version-badge]][jsr-link] [![JSR Score][jsr-score-badge]][jsr-score]
[![Coverage Status][coverage-badge]][coverage]

⚖️ Minimalist diffing.

Expand All @@ -15,9 +14,9 @@ the differences between said values. The yielded differences are represented by
- **Update:** When `left` and `right` values are different.
- **Delete:** When `left` value exists and `right` value is missing.

Like all [Coven Engineering](https://coven.engineering) libraries, it has 100%
test coverage and it's built in top of modern tech compatible with all
JavaScript runtimes.
Like all [Coven Engineering][coven-engineering] libraries, it has 100% test
coverage and it's built in top of modern tech compatible with all JavaScript
runtimes.

## Examples

Expand Down Expand Up @@ -61,12 +60,7 @@ compare({ example: 13 })({ example: 42 });
The yielded update will have values yielded from its `path`:

```typescript
({
kind: "UPDATE",
left: 13,
right: 42,
path: ["example"],
});
({ kind: "UPDATE", left: 13, right: 42, path: ["example"] });
```

### Object delete
Expand All @@ -82,11 +76,7 @@ compare({ example: 13 })({});
Yields this:

```typescript
({
kind: "DELETE",
left: 13,
path: ["example"],
});
({ kind: "DELETE", left: 13, path: ["example"] });
```

### Object create
Expand All @@ -102,11 +92,7 @@ compare({})({ example: 42 });
Yields this:

```typescript
({
kind: "CREATE",
right: 42,
path: ["example"],
});
({ kind: "CREATE", right: 42, path: ["example"] });
```

### Multiple differences
Expand All @@ -117,10 +103,7 @@ differences:
```typescript
import { compare } from "@coven/compare";

compare({
original: "old",
updated: "old",
})({
compare({ original: "old", updated: "old" })({
created: "new",
updated: "new",
});
Expand All @@ -134,6 +117,16 @@ That yields all 3 kind of differences:
({ kind: "CREATE", right: "new", path: ["created"] });
```

## Other links

- [Coverage](https://app.codecov.io/github/covenengineering/libraries).
<!-- Links -->

[coven-engineering]: https://coven.engineering
[coverage]:
https://app.codecov.io/github/covenengineering/libraries%3Fcomponents%5B0%5D%3DCoven%2520Engineering%2520Compare
[coverage-badge]:
https://img.shields.io/codecov/c/github/covenengineering/libraries?color=%23083344&component=coven__compare&label=Codecov&labelColor=%23F01F7A&logo=Codecov&logoColor=%23fff
[jsr-link]: https://coven.to/compare
[jsr-score]: https://coven.to/compare/score
[jsr-score-badge]: https://jsr.io/badges/@coven/compare/score
[jsr-version-badge]: https://jsr.io/badges/@coven/compare
[logo]:
https://raw.githubusercontent.com/covenengineering/libraries/main/@coven/compare/logo.svg
28 changes: 13 additions & 15 deletions @coven/compare/compareIterables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import type { CurriedComparison } from "./CurriedComparison.ts";
import type { Difference } from "./Difference.ts";
import { pathPrepend } from "./pathPrepend.ts";

const nextValue = <Item>(iteratorObject: IteratorObject<Item>) => {
const result = iteratorObject.next();

return result.done ? SIGIL : result.value;
};

/**
* Deep-compare iterables.
*
Expand Down Expand Up @@ -39,26 +45,18 @@ export const compareIterables =
(right) =>
iteratorFunctionToIterableIterator(function* (): Generator<Difference> {
const leftIterator = getIterator(left);
const rightIterator = getIterator(right);
const rigthIterator = getIterator(right);

// deno-lint-ignore coven/no-for
for (
let index = 0,
{ done: leftDone = false, value: leftValue } =
leftIterator.next(),
{ done: rightDone = false, value: rightValue } =
rightIterator.next();
!(leftDone && rightDone);
leftValue = nextValue(leftIterator),
rightValue = nextValue(rigthIterator);
leftValue !== SIGIL || rightValue !== SIGIL;
index += 1,
{ done: leftDone = false, value: leftValue } =
leftIterator.next(),
{ done: rightDone = false, value: rightValue } =
rightIterator.next()
leftValue = nextValue(leftIterator),
rightValue = nextValue(rigthIterator)
) {
yield* map(pathPrepend(index))(
compare(leftDone ? SIGIL : leftValue)(
rightDone ? SIGIL : rightValue,
),
);
yield* map(pathPrepend(index))(compare(leftValue)(rightValue));
}
});
2 changes: 1 addition & 1 deletion @coven/compare/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"$schema": "https://raw.githubusercontent.com/denoland/deno/main/cli/schemas/config-file.v1.json",
"exports": "./mod.ts",
"name": "@coven/compare",
"version": "0.9.8"
"version": "0.9.9"
}
29 changes: 4 additions & 25 deletions @coven/compare/tests/compare.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ Deno.test("Comparing same object yields nothing", () =>

Deno.test("Comparing different string yields `UpdateDifference`", () =>
assertEquals(flat(compare("magic")("cat")), [
{
kind: UPDATE_KIND,
left: "magic",
path: [],
right: "cat",
},
{ kind: UPDATE_KIND, left: "magic", path: [], right: "cat" },
]),
);

Expand All @@ -41,12 +36,7 @@ Deno.test("Comparing equal arrays yields nothing", () =>

Deno.test("Comparing different arrays yields `UpdateDifference`", () =>
assertEquals(flat(compare(["magic"])(["cat"])), [
{
kind: UPDATE_KIND,
left: "magic",
path: [0],
right: "cat",
},
{ kind: UPDATE_KIND, left: "magic", path: [0], right: "cat" },
]),
);

Expand Down Expand Up @@ -104,13 +94,7 @@ Deno.test("Comparing array with less items yields `DeleteDifference`", () =>
{ [property1]: "magic" },
]),
),
[
{
kind: DELETE_KIND,
left: { [property2]: "cat" },
path: [1],
},
],
[{ kind: DELETE_KIND, left: { [property2]: "cat" }, path: [1] }],
),
);

Expand Down Expand Up @@ -220,12 +204,7 @@ Deno.test(

Deno.test("Comparing 0 with -0 should yield `UpdateDifference`", () =>
assertEquals(flat(compare(-0)(0)), [
{
kind: UPDATE_KIND,
left: -0,
path: [],
right: 0,
},
{ kind: UPDATE_KIND, left: -0, path: [], right: 0 },
]),
);

Expand Down
16 changes: 2 additions & 14 deletions @coven/compare/tests/pathPrepend.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,7 @@ Deno.test("Prepend key to existing path", () =>

Deno.test("Prepend key to missing path yields prepended key", () =>
assertEquals(
flat([
prepend13({
kind: DELETE_KIND,
left: "✨",
path: [].values(),
}),
]),
[
{
kind: DELETE_KIND,
left: "✨",
path: [13],
},
],
flat([prepend13({ kind: DELETE_KIND, left: "✨", path: [].values() })]),
[{ kind: DELETE_KIND, left: "✨", path: [13] }],
),
);
31 changes: 20 additions & 11 deletions @coven/constants/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
![Coven Engineering Constants](https://raw.githubusercontent.com/covenengineering/libraries/main/@coven/constants/logo.svg)
![Coven Engineering Constants][logo]

[![JSR](https://jsr.io/badges/@coven/constants)](https://coven.to/constants)
[![JSR Score](https://jsr.io/badges/@coven/constants/score)](https://coven.to/constants/score)
[![Coverage Status](https://img.shields.io/codecov/c/github/covenengineering/libraries?color=%23083344&component=coven__constants&label=Codecov&labelColor=%23F01F7A&logo=Codecov&logoColor=%23fff)](https://app.codecov.io/github/covenengineering/libraries?components[0]=Coven%20Engineering%20Constants)
[![JSR][jsr-version-badge]][jsr-link] [![JSR Score][jsr-score-badge]][jsr-score]
[![Coverage Status][coverage-badge]][coverage]

🧱 Common constants.

This library provides constants commonly used for initial and default values as
immutable structures to avoid accidental mutations.

Like all [Coven Engineering](https://coven.engineering) libraries, it has 100%
test coverage and it's built in top of modern tech compatible with all
JavaScript runtimes. The tests for this library only make sure trying to do
mutations throws.
Like all [Coven Engineering][coven-engineering] libraries, it has 100% test
coverage and it's built in top of modern tech compatible with all JavaScript
runtimes. The tests for this library only make sure trying to do mutations
throws.

## Exported constants

Expand All @@ -31,6 +30,16 @@ console.log(EMPTY_OBJECT); // {}
console.log(SIGIL); // Symbol("⛧")
```

## Other links

- [Coverage](https://app.codecov.io/github/covenengineering/libraries).
<!-- Links -->

[coven-engineering]: https://coven.engineering
[coverage]:
https://app.codecov.io/github/covenengineering/libraries%3Fcomponents%5B0%5D%3DCoven%2520Engineering%2520Constants
[coverage-badge]:
https://img.shields.io/codecov/c/github/covenengineering/libraries?color=%23083344&component=coven__constants&label=Codecov&labelColor=%23F01F7A&logo=Codecov&logoColor=%23fff
[jsr-link]: https://coven.to/constants
[jsr-score]: https://coven.to/constants/score
[jsr-score-badge]: https://jsr.io/badges/@coven/constants/score
[jsr-version-badge]: https://jsr.io/badges/@coven/constants
[logo]:
https://raw.githubusercontent.com/covenengineering/libraries/main/@coven/constants/logo.svg
2 changes: 1 addition & 1 deletion @coven/constants/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"$schema": "https://raw.githubusercontent.com/denoland/deno/main/cli/schemas/config-file.v1.json",
"exports": "./mod.ts",
"name": "@coven/constants",
"version": "0.9.8"
"version": "0.9.9"
}
36 changes: 23 additions & 13 deletions @coven/cron/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
![Coven Engineering Cron](https://raw.githubusercontent.com/covenengineering/libraries/main/@coven/cron/logo.svg)
![Coven Engineering Cron][logo]

[![JSR](https://jsr.io/badges/@coven/cron)](https://coven.to/cron)
[![JSR Score](https://jsr.io/badges/@coven/cron/score)](https://coven.to/cron/score)
[![Coverage Status](https://img.shields.io/codecov/c/github/covenengineering/libraries?color=%23083344&component=coven__cron&label=Codecov&labelColor=%23F01F7A&logo=Codecov&logoColor=%23fff)](https://app.codecov.io/github/covenengineering/libraries?components[0]=Coven%20Engineering%20Cron)
[![JSR][jsr-version-badge]][jsr-link] [![JSR Score][jsr-score-badge]][jsr-score]
[![Coverage Status][coverage-badge]][coverage]

⏳ Fantastic cron parser and constructor.

This library is the fastest, smallest and safest cron expression parser out
there. This is because it uses a regular expression (built with
[`@coven/expression`](https://coven.to/expression)) to parse strings into a
consumable object, and the parse back is done by really quick curried functions
and generators.
[`@coven/expression`][coven-expression]) to parse strings into a consumable
object, and the parse back is done by really quick curried functions and
generators.

It also includes a `nextDate` util that given a `Date` and a valid cron
expression, will return the next matching date. It does validations beforehand
so no "Invalid Date" errors are returned.

Like all [Coven Engineering](https://coven.engineering) libraries, it has 100%
test coverage and it's built in top of modern tech compatible with all
JavaScript runtimes.
Like all [Coven Engineering][coven-engineering] libraries, it has 100% test
coverage and it's built in top of modern tech compatible with all JavaScript
runtimes.

Only known limitation is it only accepts valid standard unix cron expressions,
so cron quartz is not supported.
Expand Down Expand Up @@ -112,6 +111,17 @@ take(2)(nextISODates("1989-10-13T10:15:42.123Z")("* * * * *"));
// ["1989-10-13T10:16:00.000Z", "1989-10-13T10:17:00.000Z"]
```

## Other links

- [Coverage](https://app.codecov.io/github/covenengineering/libraries).
<!-- Links -->

[coven-expression]: https://coven.to/expression
[coven-engineering]: https://coven.engineering
[coverage]:
https://app.codecov.io/github/covenengineering/libraries%3Fcomponents%5B0%5D%3DCoven%2520Engineering%2520Cron
[coverage-badge]:
https://img.shields.io/codecov/c/github/covenengineering/libraries?color=%23083344&component=coven__cron&label=Codecov&labelColor=%23F01F7A&logo=Codecov&logoColor=%23fff
[jsr-link]: https://coven.to/cron
[jsr-score]: https://coven.to/cron/score
[jsr-score-badge]: https://jsr.io/badges/@coven/cron/score
[jsr-version-badge]: https://jsr.io/badges/@coven/cron
[logo]:
https://raw.githubusercontent.com/covenengineering/libraries/main/@coven/cron/logo.svg
2 changes: 1 addition & 1 deletion @coven/cron/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"$schema": "https://raw.githubusercontent.com/denoland/deno/main/cli/schemas/config-file.v1.json",
"exports": "./mod.ts",
"name": "@coven/cron",
"version": "0.9.8"
"version": "0.9.9"
}
8 changes: 1 addition & 7 deletions @coven/cron/tests/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,7 @@ Deno.test(
Deno.test("all fields set return object with all properties set", () =>
assertStrictEquals(
parse("13 13 13 10 5"),
memo({
dayOfMonth: 13,
dayOfWeek: 5,
hour: 13,
minute: 13,
month: 10,
}),
memo({ dayOfMonth: 13, dayOfWeek: 5, hour: 13, minute: 13, month: 10 }),
),
);

Expand Down
Loading