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
<div id="root"></div> | |
<script src="//unpkg.com/vue/dist/vue.js"></script> | |
<script> | |
window.app = new Vue({ | |
el: "#root", | |
functional: true, | |
render(h) { | |
return h('span', 'Hello λλλ') | |
} |
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 newWaitGroup(state = 0) { | |
const cbs = [] | |
const wg = {} | |
function invoke() { | |
let cb | |
while ((cb = cbs.shift())) { | |
if (typeof cb != "function") { | |
throw new TypeError( | |
"A callback function should be passed to WaitGroup.wait()" | |
) |
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 processConsecutive(list, func) { | |
let len = list.length | |
let i = 0 | |
return new Promise(resolve => { | |
const iterate = item => { | |
func(item, () => { | |
i++ | |
if (i < len) { |
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
type Result<T> = | |
| { | |
ok: true | |
value: T | |
} | |
| { | |
ok: false | |
error: any | |
} |
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 interface Logger { | |
Log(...args: any[]): void; | |
Info(...args: any[]): void; | |
Error(...args: any[]): void; | |
} | |
export enum LogLevel { | |
None = 0, | |
Log = 1 << 0, |
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 async function wrapErr<T>(p: Promise<T>): Promise<[any, T | undefined]> { | |
try { | |
return [undefined, await p]; | |
} catch (err) { | |
return [err, undefined]; | |
} | |
} | |
let [err, value] = await wrapErr(somePromiseFunc()); | |
if (err) { |
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
" Specify a directory for plugins | |
" - For Neovim: ~/.local/share/nvim/plugged | |
" - Avoid using standard Vim directory names like 'plugin' | |
call plug#begin('~/.vim/plugged') | |
Plug 'sheerun/vim-polyglot' | |
Plug 'itchyny/lightline.vim' | |
Plug 'joshdick/onedark.vim' | |
call plug#end() |
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 { EventEmitter } from "events"; | |
/** | |
* FactoryFunc returns a Promise | |
* that resolves with type T. | |
*/ | |
export type FactoryFunc<T> = () => Promise<T>; | |
/** | |
* DestructorFunc takes a type T | |
* and returns a promise when it has been destroyed. |
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 { EventEmitter } from "events" | |
export class WaitGroup extends EventEmitter { | |
public state: number | |
constructor(initialState: number = 0) { | |
if (initialState < 0) { | |
throw new RangeError() | |
} | |
super() |
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 type Currency = string | |
/** | |
* @link https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#product-data | |
*/ | |
export interface ECommerceProductData { | |
/** | |
* The product ID or SKU (e.g. P67890). *Either this field or name must be set. | |
*/ | |
id: string |