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 fs = require('fs').promises; | |
const path = require('path'); | |
async function main() { | |
const cache = {}; | |
await readdir('.', cache); | |
console.log(JSON.stringify(cache)); | |
} | |
async function readdir(dir, cache) { |
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
class Scheduler { | |
add(promiseCreator) { | |
if (!Array.isArray(this._runnings)) { | |
this._runnings = []; | |
} | |
if (!Array.isArray(this._pendings)) { | |
this._pendings = []; | |
} | |
if (!this._tick) { | |
this._tick = function (idx) { |
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
async function doRequest({ type }: { type: string }, { no }: { no: number }) { | |
} | |
type Unpacked<T> = T extends Promise<infer P> ? P : T; | |
function wrapper<T extends (...args: any[]) => any>(fn: T) { | |
return async function(...args: Parameters<T>): Promise<Unpacked<ReturnType<T>>> { | |
return await fn.apply(null, args); | |
}; | |
} |
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
find . -name '*.apk' -print0 | xargs -0 -i -n1 bash -c ' | |
aapt dump badging ${0} | tac | grep --label=${0} --max-count 1 -HoP "(?<=application-label-zh-CN:).+|(?<=application-label:).+" | |
' {} |
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 { promisify } from 'util'; | |
const sleep = promisify(setTimeout); | |
class WorkQueue { | |
#gen; | |
constructor() { | |
const gen = WorkQueue.#processor(); | |
gen.next(); // ignore first call | |
this.#gen = gen; |
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
/** | |
* @return string | |
**/ | |
export default function Hello() { | |
return "Hello"; | |
} |
OlderNewer