- Coding
-
Implement DOMStore
DOMStore
has(node) // node: DOMNode
get(node) // node: DOMNode
set(node, value), // node: DOMNode, value: any
const store = new DOMStore();
const a = document.createElement(‘div’);
const b = document.querySelector(‘.b’);
store.set(a, 3);
store.set(b, ‘x’);
store.has(a); // true
store.has(b); // true
store.get(a); // 3
store.get(b); // ‘x’ -
Implement test Framework
// Test framework
it() // it(name, test function)
expect() // expect(value) → { toBe(value) { … } }
toBe()
// example test
it(‘should be an equal number’, () => { //
expect(1).toBe(1);
});
// This logs to the console:
// “Success: should be an equal number”
it(‘should be an equal number’, () => {
expect(2).toBe(2);
expect(2).toBe(2);
expect(1).toBe(2);
});
// This logs to the console:
// “Failure: should be an equal number”
- coding
- Implement memorize, various follow-ups leading to frustration
- Implement debounce
- Implement throttle, follow-ups, variations, requiring a delay even for the first execution
- System design, a feed with automatically updating comment lists
Struggling a bit in system design, need to improve.