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
export default (str) => str.split("-").map((text, i) => i === 0 ? text : text.substr(0, 1).toUpperCase() + text.substr(1)).join(""); |
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
module.exports = { | |
module: { | |
rules: [{ | |
test: /\.ts?$/, | |
exclude: [/node_modules/], | |
enforce: "pre", | |
use: { | |
loader: "eslint-loader", | |
options: { | |
fix: true, |
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
const VIDEO_ID = "video_id"; | |
const API_KEY = "your_api_key"; | |
async function getVideoData() { | |
const url = `https://www.googleapis.com/youtube/v3/videos?part=liveStreamingDetails&id=${VIDEO_ID}&key=${API_KEY}`; | |
try { | |
const response = await fetch(url, { | |
method: 'GET', | |
}); | |
const result = await response.json(); |
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
const workerCode = ` | |
onmessage = function(e) { | |
console.log('worker thread: onmessage'); | |
console.log(e) | |
} | |
`; | |
const workerScript = URL.createObjectURL( | |
new window.Blob([workerCode], { type: "application/javascript" }) | |
); |
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 { map } from "lodash" | |
export default ({ frames, container }) => { | |
const sprite = new PIXI.AnimatedSprite( | |
map(frames, frame => { | |
const texture = PIXI.Texture.from(frame) | |
return texture | |
}) | |
) |
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
/* | |
* # usage | |
* const tweenSequence = thisFunc([tween1, tween2, ... more tweens]); | |
* tweenSquence.update(time); | |
*/ | |
import { forEach, every } from "lodash" | |
export default (...tweens) => { | |
return { |
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
/* | |
* # usage | |
* const pool = randomSampleInCache(array, 5); | |
* const elem = pool.pick(); | |
* | |
* TODO: clamp cacheNum in [0 ... list.length] | |
*/ | |
import { difference, sample, range } from "lodash" |
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
// families: array | |
// urls: array | |
export async function customWebFontLoader({ families, urls }) { | |
return new Promise((resolve, reject) => { | |
WebFont.load({ | |
custom: { | |
families, | |
urls, | |
}, | |
active: () => { |
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
/* | |
* original is skylerspark's easing functions. | |
* ref: https://gist.github.com/gre/1650294#gistcomment-3141432 | |
*/ | |
// no easing, no acceleration | |
export const linear = t => { | |
return t | |
} | |
// accelerating from zero velocity |
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
// # arg | |
// sequence: array | |
// [ | |
// { time: number, exec: function }, | |
// { time: number, exec: function }, | |
// ... | |
// ] | |
// | |
// # usage | |
// const sampleTimeline = timeline(sequence); |