# <b>Required.</b>
schema: lib/type-defs.graphqls
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
/** | |
* This Gist shares a snippet of caching solution for Oktokit.js | |
* In essense this defines a custom fetch function that wraps native fetch with caching, | |
* where it stores cache in filesystem with path ./cache/<md5 of url>.json. | |
* Inspired by https://github.com/octokit/octokit.js/issues/215. | |
*/ | |
import crypto from 'crypto' | |
import { existsSync } from 'node:fs' | |
import { writeFile, readFile } from 'node:fs/promises' | |
import { Octokit } from '@octokit/core' |
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 fetch from 'node-fetch' | |
import crypto from 'crypto' | |
import {strictEqual, deepStrictEqual} from 'assert' | |
function md5(string: string) { | |
return crypto.createHash('md5').update(string, 'utf8').digest("hex"); | |
} | |
export async function main() { | |
const url = new URL(`https://ws.audioscrobbler.com/2.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
const a = Array.from(Array(1000_000)).map((_, i) => i); | |
const b = Array.from(Array(1000_000)).map((_, i) => i); | |
const times = 1000; | |
console.time("spread"); | |
for (let i = 0; i < times; i++) { | |
const c = [...a, ...b]; | |
c.length; | |
} |
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
#!/bin/sh | |
if [ $GIT_PREFIX != "frontend*" ]; then | |
exit 0 | |
fi | |
. "$(dirname "$0")/_/husky.sh" | |
cd frontend || exit | |
yarn lint-staged |
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
declare module 'gensync' { | |
interface GensyncFn<Ps = any, R = any> { | |
(...args: Ps): Generator<unknown, R>; | |
sync: (...args: Ps) => R; | |
async: (...args: Ps) => Promise<R>; | |
} | |
function gensync<F extends (...args: any) => any>(obj: { | |
sync: F; | |
errback?: any; | |
async?: 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
import { readFileSync, writeFileSync, unlinkSync, promises } from "fs"; | |
import pMap from "p-map"; | |
const { readFile, writeFile, unlink } = promises; | |
const testCount = 10_000; | |
main().catch(err => (console.error(err), process.exit(1))); | |
async function main() { |
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 mysql, { Connection } from "mysql"; | |
import { DB_HOST, DB_PASSWORD } from "./env"; | |
const databaseName = "xxx"; | |
const databaseUser = "xxx"; | |
const databasePort = 1234; | |
export const getConn: () => Connection = (() => { | |
let conn: Connection; | |
process.on("exit", () => { |
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 { createReadStream, existsSync, readFileSync, promises } from "fs"; | |
import assert from 'assert' | |
const {readFile} = promises; | |
const filepath = | |
'__tests__/.__fixtures/hmr/__generated__/src/viewer.graphql.tsx'; | |
const len = 1000; | |
const leadingStringOfGeneratedContent = '/* '; | |
const hexHashLength = 40; |
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
# Allow multiple schema files | |
schema: | |
- 'src/schema/**/*.graphqls' | |
- '!src/schema/schema.graphqls' | |
# `schemaEntrypoint`: Generates bound GraphQL schema, from which users will import: | |
# - typeDefs for GraphQL server | |
# - schema types for resolver implementation | |
# Required if: | |
# - `schema` is local file path(s) |
NewerOlder