-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy patha-calculated.js
More file actions
24 lines (18 loc) · 539 Bytes
/
Copy patha-calculated.js
File metadata and controls
24 lines (18 loc) · 539 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'use strict';
const { Transaction } = require('./9-separate.js');
// Usage
const data = { name: 'Marcus Aurelius', born: 121, city: 'Rome' };
const cities = {
'Roman Empire': ['Rome'],
};
const [obj, transaction] = Transaction.start(data, {
age() {
const currentYear = new Date().getFullYear();
const bornYear = new Date(this.born.toString()).getFullYear();
return currentYear - bornYear;
},
country() {
// implementation cann access cities index
},
});
console.dir({ age: obj.age, country: obj.country });