Skip to content

Instantly share code, notes, and snippets.

View Leglaw's full-sized avatar

Craig Hess Leglaw

  • Shamrock Trading Corporation
  • Overland Park, KS
View GitHub Profile
@Leglaw
Leglaw / await-vs-promise-all-concurrency.js
Last active May 25, 2023 13:40
Await vs Promise.all concurrency comparison
async function runTask(seconds, msg) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(`RESULT: ${msg}`);
}, seconds * 1000);
});
}
async function testPromiseAll() {
return Promise.all([
@Leglaw
Leglaw / Enum.es6.js
Created November 14, 2015 06:21 — forked from xmlking/Enum.es6.js
JavaScript Enums with ES6, Type Checking and Immutability
export class EnumSymbol {
sym = Symbol.for(name);
value: number;
description: string;
constructor(name: string, {value, description}) {
if(!Object.is(value, undefined)) this.value = value;
if(description) this.description = description;
@Leglaw
Leglaw / dbgWatch.js
Last active September 22, 2015 21:56
Display latest value of a variable instead of flooding your console with log entries with this handy script. Call dbgWatch with 2 parameters: variable name, variable value, and it places it in a fixed-position div on the page. You can move the div around as needed.
/***************************************************
* Debugging
***************************************************/
(function() {
var body = document.getElementsByTagName('body')[0],
divWatch = document.createElement('div');
cssText = "font-family: 'Lucida Console', monospace;" +
"font-size: 12px;" +
"line-height: 1em;" +
"white-space: nowrap;" +