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 Shape { | |
name: string; | |
} | |
interface Square extends Shape { | |
length: number; | |
} | |
interface Circle extends Shape { | |
radius: number; |
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://noticias.uol.com.br/eleicoes/2022/apuracao/2turno/votos-por-estado/presidente/ | |
function compute() { | |
const states = document.querySelectorAll('.president-by-state') | |
const estimates = {}; | |
let computedVotes = 0, minComputePercentPerState = 100, minComputePercentState; | |
for (const state of states) { | |
const stateName = state.querySelector('.president-by-state-label').innerText; | |
const stateVoters = Number(state.querySelector('.voters').innerText.replace(/\D/g, '')); | |
const computedPercent = parseFloat(state.querySelector('.president-by-state-apuration .percentage').innerText.replace(',', '.')); |
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
// Copyright (c) 2023 Vendah Atividades de Internet LTDA. All rights reserved. | |
// | |
// This work is licensed under the terms of the MIT license. | |
// Get a copy at https://opensource.org/licenses/MIT. | |
export async function runWithLimitedConcurrency<T>(concurrency: number, jobs: (() => Promise<T>)[]): Promise<T[]> { | |
const setsOfJobs = batchify(jobs, Math.ceil(jobs.length / concurrency)); | |
const promises: Promise<T[]>[] = []; | |
for (const [setIndex, setOfJobs] of setsOfJobs.entries()) { | |
const instrumentedSetOfJobs = setOfJobs.map((job, jobIndex) => () => { |
OlderNewer