(credit: @tomo_e さん)
- Sho Miyamoto / @webseals
- 新卒 2 年目
- ウェブチーム
| 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) |
| /* withAttr.jsx */ | |
| import React from 'react' | |
| const withAttr = (Component) => ({attrs, ...props}) => <Component {...attrs} {...props} /> | |
| export default withAttr | |
| /* example.jsx */ | |
| import React from 'react' |
| // 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 ===== | |
| */ |
| <style> | |
| .container { | |
| display: flex; | |
| flex-direction: row; | |
| height: 1000px; | |
| } | |
| .item { | |
| flex: 1; | |
| } | |
| </style> |
| 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 |
| 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); |
| // 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, |
| 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() |
| const run = () => console.log("loop") || requestIdleCallback(run) | |
| run() |