-
Lots of type inference
-
Null/undefined checking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (import) => { | |
| assert = import('assert'); | |
| console = import('console'); | |
| range = (n) => { | |
| res = []; | |
| i = 0; | |
| while (i < n) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createElement(str) { | |
| const container = document.createElement('div'); | |
| container.innerHTML = str.trim(); | |
| return container.firstChild; | |
| } | |
| function range(n) { | |
| return (new Array(n)).fill(0).map((x, i) => i); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const rows = Array.prototype.slice.apply( | |
| document.querySelectorAll('.js-file-line') | |
| ); | |
| const code = rows | |
| .map(el => | |
| el.innerHTML | |
| .replace(/<[^>]*>/g, '') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function loadScript(src) { | |
| const script = document.createElement('script'); | |
| script.src = src; | |
| document.body.appendChild(script); | |
| return new Promise(resolve => | |
| script.addEventListener('load', resolve) | |
| ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| function resolvePromises(val) { | |
| if (Array.isArray(val)) { | |
| return Promise.all(val.map(resolvePromises)); | |
| } | |
| if (typeof val === 'object' && typeof val.then !== 'function') { | |
| return Promise.all(Object.keys(val).map(key => { | |
| return resolvePromises(val[key]).then(value => ({key, value})) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.count = 0; | |
| setInterval(() => window.count++, 20); | |
| Promise.prototype.actualThen = Promise.prototype.then; | |
| Promise.prototype.then = (function() { | |
| let currCount = window.count; | |
| let repeats = 0; | |
| let stoppedPromiseChains = []; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const RTCPeerConnection = window.RTCPeerConnection || window.webkitRTCPeerConnection; | |
| function doWebrtcVideo() { | |
| return new Promise((resolve, reject) => { | |
| function setupPeerConnection(channel) { | |
| const pc = new RTCPeerConnection({ | |
| iceServers: [{ | |
| urls: ['stun:stun.l.google.com:19302'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Firefox: | |
| host | |
| peerreflexive | |
| serverreflexive | |
| relayed | |
| Chrome: | |
| local -> host/peerreflexive | |
| prflx -> peerreflexive | |
| stun -> serverreflexive |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| // readysetjs config: {"autoRun": true} | |
| // Tip: If you set autoRun to false, you can execute | |
| // with Ctrl+Enter or Cmd+Enter. | |
| const createElement = (innerHTML) => { | |
| const wrapper = document.createElement('div'); | |
| wrapper.innerHTML = innerHTML; |