npm install --save-dev gist:8ce270954c48a4092b5dc62a0866792e
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 imageLoad(imageUrl) { | |
return new Promise((resolve, reject) => { | |
const image = new Image(); | |
image.crossOrigin = 'anonymous'; | |
image.onload = () => resolve(image); | |
image.onerror = err => reject(err); | |
image.src = imageUrl; | |
}); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 default class TidalWebComponent extends HTMLElement { | |
static css (strings) { | |
const text = strings.raw.join(); | |
const sheet = new CSSStyleSheet(); | |
sheet.replace(text); | |
return sheet; | |
} | |
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
/** | |
* Converts a snake-case string to camelCase | |
* | |
* @param {string} str kebab-cased string | |
* @returns {string} camelCased string | |
*/ | |
export function kebabToCamelCase(str) { | |
return str.replace(/(-)([a-z])/g, g => g[1].toUpperCase()); | |
} |
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 TemplateStore { | |
constructor (node) { | |
if (!(node instanceof HTMLElement)) { | |
throw new Error('DOM Node for template storage is not set up. Please pass in an HTMLElement to the constructor.'); | |
} | |
this.parentDOMNode = node; | |
} | |
/** |
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
'use latest'; | |
import express from 'express'; | |
import request from 'request'; | |
import { fromExpress } from 'webtask-tools'; | |
import bodyParser from 'body-parser'; | |
const app = express(); | |
app.use(bodyParser.json()); |
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 default function durationToMinutes (durationString) { | |
return durationString | |
.match(/\d+\w/g) | |
.map(u => ([parseInt(u.match(/\d+/g), 10), u.split(/\d+/g)[1]])) | |
.map(a => { | |
switch (a[1]) { | |
case 'D': return a[0] * 1440; | |
case 'H': return a[0] * 60; | |
case 'M': return a[0]; | |
case 'S': return a[0] / 60; |
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
'use latest'; | |
import express from 'express'; | |
import compression from 'compression'; | |
const app = express(); | |
if (process.env.NODE_ENV === 'production') { | |
app.use(compression()); | |
} |