The don't, and they won't The function is called only once and then this key is accessed immediately. Both parts are written by same person, so I really have no idea why it ended up this way. I'm currently in process of rewriting this thing from the scratch and this part was the tip of an iceberg for me (I stomped over downloading whole objects from s3 just to get their names, functions which while purpose was comparing the string, the docstring in that was 4x bigger than the actual func)
TRWTF is using javascript when typescript is an option
I like not having to transpile my code when I'm hacking together extensions. Plus, if you have a good working knowledge of the good parts, it's not that bad.
JavaScript is a much more ergonomic language for quickly prototyping small bits of functionality. I find it better to hack something together in JavaScript, and then bring it into Typescript once I have something that mostly works. Most of the time, type inferencing means that I don't have to add that many annotations, either.
Functional programming (as in, the kind that gets into monads and currying) can also be really clunky and hard to read in Typescript, if you have a lot of generics and function arguments.
I usually play around with Firebase Firestore. Typically, to make query or transaction, I need to pass this kind of instance, a map of a single key and value.
49
u/w8eight Dec 20 '21 edited Dec 20 '21
For the guy transcribing the images:
191
u/fillif3 Dec 20 '21
Is this really a bad code? They can later add more keys to dictionary. This function can be used, for instance, in constructor.
26
u/RedditAcc-92975 Dec 20 '21
This is probably due to an external API which requires this specific structure. Seen this kind of mess before.
30
u/Tim3303 Please don't tell Murdo that I transcribed this Dec 20 '21
Image Transcription: Code
[Dark theme, four space indent.]
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
11
u/FishWash Dec 20 '21
Uses a dictionary for O(1) access time
4
u/EdgarDrake Dec 20 '21
I usually play around with Firebase Firestore. Typically, to make query or transaction, I need to pass this kind of instance, a map of a single key and value.
0
u/[deleted] Dec 20 '21
[deleted] — view deleted comment