Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

84
Visualizações
Appending strings to JSON Files

consider the following code snippet:

let proposals = JSON.parse(fs.readFileSync(proposalsFile, "utf8"))
proposals[network.config.chainId!.toString()].push(proposalId.toString())
fs.writeFileSync(proposalsFile, JSON.stringify(proposals))

The initial proposalFile contains the following: { '31337': [] }

I don't understand what is happening in the second line above. How can the index of the array proposals[] be of type String, if indeed it is an array?

What is the meaning of the ! in ChainId!?

Subsequent executions of this script will result in strings getting appended in the proposalFile:

{"31337":["21810620491323861737494108894072031792136914678422989467418569109597477706871","21810620491323861737494108894072031792136914678422989467418569109597477706871"]}

I understand why this is done, I don't understand how the code snippet results in the above JSON file? The original context of this snippet can be found here: https://github.com/PatrickAlphaC/dao-template/blob/main/scripts/propose.ts

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda