darkfo icon indicating copy to clipboard operation
darkfo copied to clipboard

Work towards using ES6

Open darkf opened this issue 9 years ago • 3 comments

ES6 is becoming more and more supported, and it offers some very nice features (const, let, destructuring, Map, Set, etc.)

TypeScript transpiles a lot of these, but the codebase doesn't use much of them (in particular I recall wrapping some blocks in lambdas to mimic let.)

const should be defaulted to when making bindings we won't change, and let otherwise.

We may also use for(let x of xs) ... for loops over arrays, and Object.assign for cloning/mass-assigning objects.

darkf avatar Jul 10 '16 16:07 darkf

Arrow functions are some of the most useful for this. I ported worldmap.ts to ES6. The other files still remain.

darkf avatar Feb 02 '17 16:02 darkf

Like I said in #101:

A lot of the callback hell spaghetti can be replaced with promises (which as a huge benefit makes our asynchronous code composable, and will replace monsters like the image loading stuff -- we can use Promise.all instead).

darkf avatar Nov 27 '17 18:11 darkf

We might also want to target ES6 natively (since it's supported by a large majority of modern browsers) in TypeScript ("target": "ES6"} and use ES6 libs.)

darkf avatar Dec 08 '17 06:12 darkf