Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungRefreshed repository pull requests page generally available(22.09.2026 um 03:25 Uhr)
Sichere ProgrammierungThe Joy of Learning the Basics Again(22.09.2026 um 03:28 Uhr)
Sichere ProgrammierungZero-Code OpenTelemetry Tracing for Dagster(22.09.2026 um 03:39 Uhr)
Linux Tipps & Hardening`prime-all`(22.09.2026 um 02:28 Uhr)
IT Security Toolsopensoho v0.15.2(22.09.2026 um 03:33 Uhr)
IT Security NachrichtenUS Proposes AI Incident Alert System in Talks With China, Bessent Says(22.09.2026 um 04:01 Uhr)
Sichere ProgrammierungRefreshed repository pull requests page generally available(22.09.2026 um 03:25 Uhr)
Sichere ProgrammierungThe Joy of Learning the Basics Again(22.09.2026 um 03:28 Uhr)
Sichere ProgrammierungZero-Code OpenTelemetry Tracing for Dagster(22.09.2026 um 03:39 Uhr)
Linux Tipps & Hardening`prime-all`(22.09.2026 um 02:28 Uhr)
IT Security Toolsopensoho v0.15.2(22.09.2026 um 03:33 Uhr)
IT Security NachrichtenUS Proposes AI Incident Alert System in Talks With China, Bessent Says(22.09.2026 um 04:01 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

arrayToDict function in tRPC source code

In this article, we analyze arrayToDict function found in tRPC source code. // https://github.com/trpc/trpc/pull/669 function arrayToDict(array: unknown[]) { const dict: Record<number, unknown> = {}; for (let index = 0; index…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

In this article, we analyze arrayToDict function found in tRPC source code.




// https://github.com/trpc/trpc/pull/669
function arrayToDict(array: unknown[]) {
const dict: Record<number, unknown> = {};
for (let index = 0; index < array.length; index++) {
const element = array[index];
dict[index] = element;
}
return dict;
}






This function is straight forward. dict is an object initialized above the for loop. In this for loop, array[index] is assigned to element and dict is an object that array indices as keys and values being array items based on index.



Although this function is simple, a lot was discussed in PR: https://github.com/trpc/trpc/pull/669 before this solution was presented to KATT (Creator of tRPC).



This pull request was about — fix: batching with zod .optional() input.



PR’s description:


- JSON.stringify([undefined]) === [null]


- this causes issues with .optional() zod schemas as it expects an object or undefined, not null


- fixed by ugly hack that runs validator twice when it fails if the raw input was === null.


- fixed by @simonedelmann’s idea



I would recommend going through this pull request conversation to give you an insight on how decisions are made. This conversation shows how ideas are bounced around and also talk about what could break based on an idea, if it’s just an edge-case and they finally choose to go with arrayToDict idea.



In this pull request, you also find All Contributors Github app that gives


attribution to contributor based on an idea. This is what All Contributors is about — Recognize all contributors, not just the ones who push code. With All Contributes, even if you present an idea without writing any code, you could make them a contributor with a comment:






@all-contributors add @username for reviews




and @all-contributors adds tagged user as a contributor.






About us:



At Thinkthroo, we study large open source projects and provide architectural guides. We have developed resubale Components, built with tailwind, that you can use in your project. We offer Next.js, React and Node development services.



Book a meeting with us to discuss your project.



Image description



Image description






References:




  1. https://github.com/trpc/trpc/blob/next/packages/client/src/links/internals/httpUtils.ts#L57


  2. https://github.com/trpc/trpc/pull/669


Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten arrayToDict function in tRPC source code

Thematisch verwandte Begriffe: arrayToDict, function, tRPC, source · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-49449 | Joplin is an open source note-taking and to-do application that organise…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick