I hereby claim:
- I am whitelizard on github.
- I am whitelizard (https://keybase.io/whitelizard) on keybase.
- I have a public key ASDQQj8ThUyAUGANASXBwYlA-tT0kJ4sMe5qFwRZSvs8-Ao
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
const triggerPromise = () => { | |
let resolve; | |
const promise = new Promise(r => (resolve = r)); | |
return [promise, resolve]; | |
}; |
// item and items are predefined | |
const parent = items[item.parent]; | |
const types = parent.types; | |
const name = parent.name; |
const parentId = item.parent; | |
const parent = parentId ? (items[parentId] || {}) : {}; | |
const types = parent.types || []; | |
const name = parent.name || 'Noname'; |
const { parent: parentId } = item; | |
const { [parentId]: { types = [], name = 'Noname' } = {} } = items; |
class Circle { | |
constructor(pos = [0, 0], r = 0) { | |
this.pos = pos; | |
this.radius = r; | |
this.hitCount = 0; | |
} | |
get r() { | |
return this.radius; | |
} |
const c1 = new Circle([2.5, 0], 1.5); | |
const c2 = new Circle([-2, 0], 2); | |
c1.area(); // -> 7.0685834705770345 | |
c2.area(); // -> 12.566370614359172 | |
c1.intersect(c2); // -> false | |
c1.hits; // -> 0 | |
c1.pos[0] = 1; |
const c1 = new Circle([2.5, 0], 1.5); | |
const c2 = new Circle([-2, 0], 2); | |
c1.area(); // -> 7.0685834705770345 | |
c2.area(); // -> 12.566370614359172 | |
c1.intersect(c2); // -> false | |
c1.getHits(); // -> 0 | |
c1.pos[0] = 1; |
const c1 = makeCircle([2.5, 0], 1.5); | |
const c2 = makeCircle([-2, 0], 2); | |
c1.area(); // -> 7.0685834705770345 | |
c2.area(); // -> 12.566370614359172 | |
c1.intersect(c2); // -> false | |
c1.getHits(); // -> 0 | |
c1.pos[0] = 1; |
const reducer = (state, action) => { | |
const actions = { | |
move: ({ id, payload }) => ({ ...state, [id]: setPos(state[id], payload) }), | |
hit: ({ id1, id2 }) => ({ | |
...state, | |
[id1]: incHits(state[id1]), | |
[id2]: incHits(state[id2]), | |
}), | |
}; | |
return actions[action.type](action); |