Skip to content

Instantly share code, notes, and snippets.

View murraco's full-sized avatar

Mauricio Urraco murraco

  • Earth
View GitHub Profile
@murraco
murraco / main.js
Last active June 19, 2020 14:44
Custom Code Challenge from Logement 3D: getClosestPointInsidePolygon
interface Point {
x: number;
y: number;
}
function getClosestPointInsidePolygon(poly: Point[], c: Point): Point {
const fixPrecision = (x: number) => Number(x.toPrecision(12));
let min: number = Number.MAX_SAFE_INTEGER;
let minP: Point = { x: Number.MAX_SAFE_INTEGER, y: Number.MAX_SAFE_INTEGER };
@murraco
murraco / main.js
Last active March 30, 2021 17:43
Hard Code Challenge: https://www.codingame.com/training/hard/bender-episode-2 | Mauricio Urraco
const rooms = {};
const roomMaxValue = [];
const N = parseInt(readline());
for (let i = 0; i < N; i++) {
const room = readline();
// Destructure room information
const [id, money, door1, door2] = room.split(' ');
// Add values to the rooms data structure
rooms[id] = { money, door1, door2 };

JavaScript Bundlers

Shared Dependencies

We can start by setting up our package.json file by adding Babel, which will be used, in some capacity, by each of the three tester build tools:

  • babel-loader
  • babel-plugin-external-helpers
  • babel-preset-env
  • babel-preset-stage-0

JavaScript Modules

  1. How do I make the tree shakeable?
  2. What JS module systems should I target (CommonJS, AMD, ES6).
  3. Should I transpile the source?
  4. Should I bundle the source?
  5. What files should I publish?

Let's try to address all the above questions now.

JavaScript ES6 Features

Introduction

ECMAScript 2015, also known as ES6 or ES2015, is a fundamental version of the ECMAScript standard.

The most important changes in ES2015 include: