Skip to content

Commit 6bf3526

Browse files
committed
chore: run deno fmt
1 parent 6de3657 commit 6bf3526

2 files changed

Lines changed: 34 additions & 19 deletions

File tree

effect.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ export function left<B, S = unknown>(
302302
* import * as Eff from "./effect.ts";
303303
* import * as E from "./either.ts";
304304
*
305-
* const processNumber: Eff.Effect<number, never, number> = (n: number) =>
305+
* const processNumber: Eff.Effect<number, never, number> = (n: number) =>
306306
* Promise.resolve([E.right(n * 2), n]);
307307
* const processString = Eff.premap((s: string) => parseInt(s))(processNumber);
308308
*
@@ -458,7 +458,7 @@ export function apply<A, B, S3, S2>(
458458
* import { pipe } from "./fn.ts";
459459
*
460460
* const divide = (a: number) => (b: number) =>
461-
* b === 0
461+
* b === 0
462462
* ? Eff.left("Division by zero")
463463
* : Eff.right(a / b);
464464
*

testing/effect.test.ts

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Deno.test("Effect apply with left value", async () => {
157157
const applied = pipe(
158158
effectFn,
159159
Effect.apply(effectValue),
160-
)
160+
);
161161
const result = await applied("state");
162162
assertEquals(result, [E.left("value error"), "state"]);
163163
});
@@ -355,9 +355,7 @@ Deno.test("Effect complex stateful computation", async () => {
355355
: Effect.left("Negative number")
356356
),
357357
Effect.flatmap((result: number) =>
358-
result > 20
359-
? Effect.wrap(result)
360-
: Effect.left("Result too small")
358+
result > 20 ? Effect.wrap(result) : Effect.left("Result too small")
361359
),
362360
);
363361

@@ -414,7 +412,7 @@ Deno.test("Effect state threading", async () => {
414412
Deno.test("Effect tryCatch with successful execution", async () => {
415413
const safeFunction = Effect.tryCatch(
416414
(n: number) => n * 2,
417-
(error, args) => `Error with args ${args}: ${error}`
415+
(error, args) => `Error with args ${args}: ${error}`,
418416
);
419417

420418
const result = await safeFunction(21)("state");
@@ -424,7 +422,7 @@ Deno.test("Effect tryCatch with successful execution", async () => {
424422
Deno.test("Effect tryCatch with Promise successful execution", async () => {
425423
const safeFunction = Effect.tryCatch(
426424
(n: number) => Promise.resolve(n * 2),
427-
(error, args) => `Error with args ${args}: ${error}`
425+
(error, args) => `Error with args ${args}: ${error}`,
428426
);
429427

430428
const result = await safeFunction(21)("state");
@@ -437,28 +435,34 @@ Deno.test("Effect tryCatch with error", async () => {
437435
if (n < 0) throw new Error("Negative number");
438436
return n * 2;
439437
},
440-
(error, args) => `Caught error with args [${args}]: ${error}`
438+
(error, args) => `Caught error with args [${args}]: ${error}`,
441439
);
442440

443441
const result = await throwingFunction(-5)("state");
444-
assertEquals(result, [E.left("Caught error with args [-5]: Error: Negative number"), "state"]);
442+
assertEquals(result, [
443+
E.left("Caught error with args [-5]: Error: Negative number"),
444+
"state",
445+
]);
445446
});
446447

447448
Deno.test("Effect tryCatch with Promise that rejects", async () => {
448449
const rejectingFunction = Effect.tryCatch(
449450
(n: number) => Promise.reject(`Promise rejected with ${n}`),
450-
(error, args) => `Caught promise rejection with args [${args}]: ${error}`
451+
(error, args) => `Caught promise rejection with args [${args}]: ${error}`,
451452
);
452453

453454
const result = await rejectingFunction(10)("state");
454-
assertEquals(result, [E.left("Caught promise rejection with args [10]: Promise rejected with 10"), "state"]);
455+
assertEquals(result, [
456+
E.left("Caught promise rejection with args [10]: Promise rejected with 10"),
457+
"state",
458+
]);
455459
});
456460

457461
Deno.test("Effect recover with left value", async () => {
458462
const effect = Effect.left<string, number>("original error");
459463
const recovered = pipe(
460464
effect,
461-
Effect.recover((error: string) => Effect.wrap(`Recovered from: ${error}`))
465+
Effect.recover((error: string) => Effect.wrap(`Recovered from: ${error}`)),
462466
);
463467

464468
const result = await recovered(42);
@@ -469,7 +473,7 @@ Deno.test("Effect recover with right value (no recovery needed)", async () => {
469473
const effect = Effect.wrap(42);
470474
const recovered = pipe(
471475
effect,
472-
Effect.recover((error: string) => Effect.wrap(`Recovered from: ${error}`))
476+
Effect.recover((error: string) => Effect.wrap(`Recovered from: ${error}`)),
473477
);
474478

475479
const result = await recovered("state");
@@ -480,11 +484,16 @@ Deno.test("Effect recover with recovery function that fails", async () => {
480484
const effect = Effect.left("original error");
481485
const recovered = pipe(
482486
effect,
483-
Effect.recover((error: string) => Effect.left(`Recovery failed for: ${error}`))
487+
Effect.recover((error: string) =>
488+
Effect.left(`Recovery failed for: ${error}`)
489+
),
484490
);
485491

486492
const result = await recovered("state");
487-
assertEquals(result, [E.left("Recovery failed for: original error"), "state"]);
493+
assertEquals(result, [
494+
E.left("Recovery failed for: original error"),
495+
"state",
496+
]);
488497
});
489498

490499
Deno.test("Effect alt with first effect succeeding", async () => {
@@ -497,7 +506,9 @@ Deno.test("Effect alt with first effect succeeding", async () => {
497506
});
498507

499508
Deno.test("Effect alt with first effect failing", async () => {
500-
const first: Effect.Effect<string, string, number> = Effect.left("first error");
509+
const first: Effect.Effect<string, string, number> = Effect.left(
510+
"first error",
511+
);
501512
const second: Effect.Effect<string, string, number> = Effect.wrap(42);
502513
const alternative = Effect.alt(second)(first);
503514

@@ -506,8 +517,12 @@ Deno.test("Effect alt with first effect failing", async () => {
506517
});
507518

508519
Deno.test("Effect alt with both effects failing", async () => {
509-
const first: Effect.Effect<string, string, number> = Effect.left("first error");
510-
const second: Effect.Effect<string, string, number> = Effect.left("second error");
520+
const first: Effect.Effect<string, string, number> = Effect.left(
521+
"first error",
522+
);
523+
const second: Effect.Effect<string, string, number> = Effect.left(
524+
"second error",
525+
);
511526
const alternative = Effect.alt(second)(first);
512527

513528
const result = await alternative("original");

0 commit comments

Comments
 (0)