-
-
Notifications
You must be signed in to change notification settings - Fork 599
/
proof.ci.js
39 lines (36 loc) · 1007 Bytes
/
proof.ci.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/* eslint-disable no-unused-vars */
import { Person } from '../person';
import { Name } from '../name';
import { Born } from '../born';
import { Address } from '../address';
import { Lens } from '../lens';
// Implement the nameLens with the getter and setter
export const nameLens = new Lens(
(person) => person.name,
(person, name) => new Person(name, person.born, person.address),
);
// Implement the bornAtLens with the getter and setter
export const bornAtLens = new Lens(
(person) => person.born.bornAt,
(person, bornAt) =>
new Person(
person.name,
new Born(bornAt, person.born.bornOn),
person.address,
),
);
// Implement the streetLens with the getter and setter
export const streetLens = new Lens(
(person) => person.address.street,
(person, street) =>
new Person(
person.name,
person.born,
new Address(
person.address.houseNumber,
street,
person.address.place,
person.address.country,
),
),
);