y’all have no idea how much I would rather be able to write:
any(not isPrimitive(value) for value in someDict.values())
instead of:
Object.entries(someObject).some(([_key, value]) => !isPrimitive(value))
I’m trying to write a function that can pretty-print any type in javascript and it is Not Going Well. this language’s type system is actually horrifying. some object fields are hidden and can only be seen by certain functions and not others. null is an object, except typescript disagrees. JSON.stringify() silently ignores any field it doesn’t know how to deal with, and I can’t find any documentation for how it chooses which fields to discard, or any way to find out if it would discard a field if I were to use it
@kasdeya this isnt gonna make it thaaaat much better but you could do
Object.values(someObject).some(value => !isPrimitive(value))
(especially since i think the python version of values is a lazy iterator that stops on first match and the javascript one isn’t)
“may your ancestors spend a hundred years trying to pretty-print things in TypeScript”
I give up lol this sucks. I was just trying to see what the window object in Bitburner has in it but nooo
Fist, write your code. Then, write a compiler/interpreter for the code.