View get_timezone_offset.js
This file contains 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
export function getTimezoneOffset(date, timeZone) { | |
const parts = new Intl.DateTimeFormat('en-US', { | |
timeZone, | |
hour12: false, | |
year: 'numeric', month: 'numeric', day: 'numeric', | |
hour: 'numeric', minute: 'numeric', second: 'numeric' | |
}).format(date).split(/[\/\s:]/); | |
// The year string contains a comma, like "2016,", so we strip it using parseInt | |
const year = parseInt(parts[2], 10); | |
// The month is rendered in human readable terms, which are betweeen 1-12, but the API requires 0-11 |
View gist:689bc36a4cf5d8994d15
This file contains 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
class QueueItem { | |
constructor(value) { | |
this.value = value; | |
this.next = void 0; | |
} | |
} | |
class Queue { | |
constructor() { | |
this.first = void 0; |
View gist:dfc6c067f1442fa8fa23
This file contains 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
interface LoadRequest { | |
name: string; | |
address?: string; | |
source?: string; | |
metadata: Object; | |
} | |
interface Eventual<T> = T | Promise<T>; | |
interface ModuleInstantiator { |
View CancellablePromise.all.js
This file contains 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
CancellablePromise.all = function (values) { | |
var CancellablePromise = this; | |
var child; | |
var children = []; | |
return new CancellablePromise(function (resolve, reject) { | |
if (!A.Lang.isArray(values)) { | |
reject(new TypeError('CancellablePromise.all expects an array of values or promises')); | |
return; | |
} |
View CancellablePromise.all.js
This file contains 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
CancellablePromise.all = function (values) { | |
var CancellablePromise = this; | |
var child; | |
var children = []; | |
return new CancellablePromise(function (resolve, reject) { | |
if (!A.Lang.isArray(values)) { | |
reject(new TypeError('CancellablePromise.all expects an array of values or promises')); | |
return; | |
} |
View gist:9772321
This file contains 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 (global) { | |
"use strict"; | |
function Queue(capacity) { | |
this.capacity = this.snap(capacity); | |
this.length = 0; | |
this.front = 0; | |
this.initialize(); | |
} |
View gist:9413718
This file contains 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
PromisePolyfill.async = (function () { | |
"use strict"; | |
function Queue(capacity) { | |
this.capacity = this.snap(capacity); | |
this.length = 0; | |
this.front = 0; | |
this.initialize(); | |
} |
View gist:8849263
This file contains 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 { readFile } from 'fs'; | |
import { createServer } from 'http'; | |
createServer(async function (req, res) { | |
try { | |
var content = await readFile('foo.html'); | |
res.end(content); | |
} catch (e) { | |
res.end('ouch!'); | |
} |
View gist:8425869
This file contains 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
YUI.add('require', function (Y) { | |
return function (name) { | |
return Y.Env._exported[name]; | |
} | |
}, '@VERSION@', { | |
es: true | |
}); | |
define(name, dependencies, factory) { | |
var defDeps = ['require', 'exports', 'module'], |
View gist:8287117
This file contains 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 assign(dest, source) { | |
for (var prop in source) { | |
if (source.hasOwnProperty(prop)) { | |
dest[prop] = source[prop]; | |
} | |
} | |
return dest; | |
} | |
function createStateClass(superclass, props) { |
NewerOlder