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
const repository = Symbol('repository') | |
class Dict { | |
constructor(props) { | |
if (typeof props !== 'object') { | |
throw new Error( | |
`Props must be an object, you passed ${typeof props} ${props}.` | |
) | |
} | |
Object.freeze(props) |
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
/* withAttr.jsx */ | |
import React from 'react' | |
const withAttr = (Component) => ({attrs, ...props}) => <Component {...attrs} {...props} /> | |
export default withAttr | |
/* example.jsx */ | |
import React from 'react' |
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 definitions for workbox-sw 3.2 | |
// Project: https://github.com/GoogleChrome/workbox | |
// Definitions by: Frederik Wessberg <https://github.com/wessberg> | |
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | |
// TypeScript Version: 2.6 | |
/** | |
* ===== BroadcastCacheUpdate ===== | |
*/ |
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
<style> | |
.container { | |
display: flex; | |
flex-direction: row; | |
height: 1000px; | |
} | |
.item { | |
flex: 1; | |
} | |
</style> |
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 { useState, useEffect } from 'preact/hooks' | |
// or | |
import { useState, useEffect } from 'react' | |
import { Store } from 'unistore' | |
// or | |
import { Store } from 'redux' | |
const extract = (state: any, key: any) => { | |
if (!key) return state |
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 chalk from 'chalk'; | |
export const initChalk = ({ error = chalk.redBright, warn = chalk.yellowBright } = {}) => { | |
// disable coloring e.g. when piped like `2> err.log` | |
if (typeof process !== 'undefined' && !process.stderr.isTTY) { | |
return; | |
} | |
if (error) { | |
const defaultError = console.error.bind(console); |
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
const express = require('express') | |
const sleep = (ms) => new Promise((res, rej) => setTimeout(res, ms)) | |
const sleepSync = (ms) => { | |
const start = new Date() | |
while (new Date() - start < ms) {} | |
} | |
const server = express() |
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
const run = () => console.log("loop") || requestIdleCallback(run) | |
run() |
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
// https://github.com/v8/v8/blob/master/test/mjsunit/mjsunit.js#L162-L178 | |
const statuses = { | |
IsFunction: 1 << 0, | |
NeverOptimize: 1 << 1, | |
AlwaysOptimize: 1 << 2, | |
MaybeDeopted: 1 << 3, | |
Optimized: 1 << 4, | |
TurboFanned: 1 << 5, | |
Interpreted: 1 << 6, |
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
race() | |
function race() { | |
let count = 1 | |
function finish(message) { | |
console.log(`${count++}. ${message}`) | |
} | |
setTimeout(() => finish('timeout'), 0) |
OlderNewer