Skip to content

Instantly share code, notes, and snippets.

View ZowieTao's full-sized avatar
🥷
Developing

Zowie ZowieTao

🥷
Developing
View GitHub Profile
@ZowieTao
ZowieTao / concur-request
Created November 3, 2023 00:44
The `concurRequest` function allows concurrent HTTP requests to multiple URLs, returning the results in the original order. It improves efficiency by fetching data from multiple endpoints simultaneously.
/**
* concur request and return result sortby.
*
* @param {string[]} urlList - The url which be will requested.
* @param {number} capacity - The max number of concurRequest.
* @returns {Promise<any[]>}.
*/
function concurRequest(urlList, capacity) {
return new Promise((resolve) => {
if (urlList.length === 0) {
const Swiper = () => {
const [currentIndex, setCurrentIndex] = useState(0)
// eslint-disable-next-line no-unused-vars
const [_, forceUpdate] = useState<boolean>(true)
const slides = useMemo(() => {
const content0 = (
<div className="flex w-full border rounded-xl aspect-[7/4] overflow-hidden">
<div className="w-[232px]">side0</div>