Skip to content

Commit 2bc1b3b

Browse files
totto2727claude
andcommitted
chore: bump version to 2.1.0
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 78c3b2c commit 2bc1b3b

File tree

3 files changed

+55
-30
lines changed

3 files changed

+55
-30
lines changed

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"precommit": "deno task fix && deno task build && deno task test",
5656
"test": "deno test **/*.test.ts"
5757
},
58-
"version": "2.0.0",
58+
"version": "2.1.0",
5959
"lint": {
6060
"rules": {
6161
"exclude": ["no-import-prefix"]

effect/id.test.ts

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,56 @@
11
import { expect } from "../test.ts";
22
import { Array, Effect } from "../effect.ts";
3-
import { createCUIDSeed, CUID, CUIDTestLive } from "./id.ts";
3+
import {
4+
createCUIDSeed,
5+
CUID,
6+
CUIDProductionLive,
7+
CUIDTestLive,
8+
} from "./id.ts";
9+
10+
Deno.test("CUIDProductionLive", () => {
11+
Effect.gen(function* () {
12+
const makeCUID = yield* CUID;
13+
14+
expect(makeCUID()).not.toBe(makeCUID());
15+
}).pipe(Effect.provide(CUIDProductionLive), Effect.runSync);
16+
});
417

518
Deno.test("CUIDTestLive", async (t) => {
619
await t.step("Fixed", () => {
7-
const actual = CUID.pipe(
20+
Effect.gen(function* () {
21+
const makeCUID = yield* CUID;
22+
23+
expect(makeCUID()).toBe("gk1pfmhav2vkvudlk25qrot8");
24+
}).pipe(
825
Effect.provide(CUIDTestLive),
926
Effect.provide(createCUIDSeed("test")),
1027
Effect.runSync,
1128
);
12-
expect(actual).toBe("gk1pfmhav2vkvudlk25qrot8");
1329
});
1430

1531
await t.step("Snapshot", () => {
16-
const makeCUID = CUID.pipe(
32+
Effect.gen(function* () {
33+
const makeCUID = yield* CUID;
34+
const actual = Array.makeBy(10, () => makeCUID());
35+
36+
expect(actual).toEqual(
37+
[
38+
"gk1pfmhav2vkvudlk25qrot8",
39+
"dk3p231wqtob3kin8dt7p6sv",
40+
"p1o29mevenep5ehytgf7slsz",
41+
"cl2ag2azhfpn6gvbjiol9wrv",
42+
"fw2odl6k7umbv8kpyf1pl4vj",
43+
"gu480f94gvmqfx44ugeeaed7",
44+
"u8pozhspgav0zp048uvqw7im",
45+
"ci2whviybacarg4p69xnzdlg",
46+
"eh42helbpmmlw7jmco41rpcy",
47+
"dl1dsmlxhq6tba02sofl2apd",
48+
],
49+
);
50+
}).pipe(
1751
Effect.provide(CUIDTestLive),
1852
Effect.provide(createCUIDSeed("test")),
19-
);
20-
const actual = Array.makeBy(10, () => makeCUID.pipe(Effect.runSync));
21-
expect(actual).toEqual(
22-
[
23-
"gk1pfmhav2vkvudlk25qrot8",
24-
"dk3p231wqtob3kin8dt7p6sv",
25-
"p1o29mevenep5ehytgf7slsz",
26-
"cl2ag2azhfpn6gvbjiol9wrv",
27-
"fw2odl6k7umbv8kpyf1pl4vj",
28-
"gu480f94gvmqfx44ugeeaed7",
29-
"u8pozhspgav0zp048uvqw7im",
30-
"ci2whviybacarg4p69xnzdlg",
31-
"eh42helbpmmlw7jmco41rpcy",
32-
"dl1dsmlxhq6tba02sofl2apd",
33-
],
53+
Effect.runSync,
3454
);
3555
});
3656
});

effect/id.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export {
1616
const CUIDTagClass: Context.TagClass<
1717
CUID,
1818
"CUID",
19-
typeof Cuid.Type
19+
() => typeof Cuid.Type
2020
> = Context.Tag("CUID")();
2121

2222
export class CUID extends CUIDTagClass {}
@@ -25,9 +25,12 @@ export const CUIDProductionLive: Layer.Layer<
2525
CUID,
2626
never,
2727
never
28-
> = Layer.succeed(
28+
> = Layer.effect(
2929
CUID,
30-
Cuid.make(createId()),
30+
// deno-lint-ignore require-yield
31+
Effect.gen(function* () {
32+
return () => Cuid.make(createId());
33+
}),
3134
);
3235

3336
const CUIDSeedTagClass: Context.TagClass<
@@ -46,13 +49,15 @@ export const CUIDTestLive: Layer.Layer<CUID, never, CUIDSeed> = Layer.effect(
4649
CUID,
4750
Effect.gen(function* () {
4851
const seed = yield* CUIDSeed;
49-
const [r, ...rArray] = Array.makeBy(20, () => seed.int32());
50-
return decode(
51-
`${base26.encode([r])}${base36.encode(rArray)}`.substring(0, 24).padEnd(
52-
24,
53-
"0",
54-
),
55-
);
52+
return () => {
53+
const [r, ...rArray] = Array.makeBy(20, () => seed.int32());
54+
return decode(
55+
`${base26.encode([r])}${base36.encode(rArray)}`.substring(0, 24).padEnd(
56+
24,
57+
"0",
58+
),
59+
);
60+
};
5661
}),
5762
);
5863

0 commit comments

Comments
 (0)