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
/* | |
* 改自 https://github.com/sindresorhus/p-limit | |
*/ | |
export function limitPromiseConcurrency<Result = any>(concurrency: number) { | |
type FnType = () => Promise<Result> | |
type ResolveFn = (r: Result) => void | |
type RejectFn = (r: any) => void | |
if (concurrency <= 0) { |
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
interface Options { | |
fontFamily?: string; | |
fontSize?: number; | |
} | |
export default function text2image(text: string, opts?: Options) { | |
const { fontFamily = "serif", fontSize = 14 } = opts || {}; | |
// high ratio, high dpi | |
const ratio = Math.max(window.devicePixelRatio || 4, 4); | |
const canvas = document.createElement("canvas"); |
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
Hi! |
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
<template> | |
<div> | |
<input type="password" :style="{ position: 'absolute', top: '-99999px' }"> // this line prevent chrome autocomplete below | |
<input :type="computedType" autocomplete="off"> | |
<span | |
v-if="type==='password'" | |
:class="['eye', eyeStatus?'eye-open':'eye-close']" | |
@click="toggleEyeStatus" | |
></span> | |
</div> |
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
var threadLimit chan struct{} | |
var threadOnce sync.Once | |
func acquireThread() { | |
threadOnce.Do(func() { | |
threadLimit = make(chan struct{}, concurrentThreadsLimit()) | |
}) | |
threadLimit <- struct{}{} | |
} |