Skip to content

Instantly share code, notes, and snippets.

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) {
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) {
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);
};
}
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:).+"
' {}
@zbinlin
zbinlin / work-queue.mjs
Created July 11, 2021 06:02
Work Queue
import { promisify } from 'util';
const sleep = promisify(setTimeout);
class WorkQueue {
#gen;
constructor() {
const gen = WorkQueue.#processor();
gen.next(); // ignore first call
this.#gen = gen;
/**
* @return string
**/
export default function Hello() {
return "Hello";
}