|
I’m not sure which would be easier, creating types for some of our bs internal packages or just rewriting them into typescript and getting the types for free.
|
# ? Jun 30, 2023 23:03 |
|
|
# ? Jun 8, 2024 06:48 |
|
The framework I would like to find would be based on the standard APIs so it's usable on different runtimes. Also, there will be a lot of proxying and not a lot of routing, so being able to do something likecode:
|
# ? Jul 1, 2023 07:14 |
|
You could try my framework, it does it's best to let you use just native req/res node thingys.
|
# ? Jul 9, 2023 18:27 |
|
hello thread I've never been in before I'm trying to make a test using a textbook publisher's online testmaker website thing. There's thousands of questions in their test bank, and various filters to find specifically which questions you want to add. So you filter it down to specific chapters or type of questions or whatever, and there's still like 90 possible questions to add. Then, you have to click the Add Question button to add the question to your test. My problem is that the multimillion-dollar textbook publisher failed to make an ADD ALL button, and I don't want to hit the Add Question button 90 some times (per test). And after clicking Add Question, the next question down moves slightly, so it's really annoying. I did some googling and found this https://medium.com/swlh/how-to-automate-clicks-using-javascript-4855f0f42b60, which helps. So I'm at... code:
How do I make a code to click all the goddamn buttons on this site that are named "__input__button__addbutton__X" where X is like 0 to maybe 200. Thank you ahead of time.
|
# ? Jul 11, 2023 02:18 |
|
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String How to concatenate strings: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_operators#string_operators
|
# ? Jul 11, 2023 02:26 |
|
You could also use template strings which use the backtick ` char and ${ your variable or expression goes here } ... so something like,code:
|
# ? Jul 11, 2023 02:44 |
|
Speaking of backend frameworks this looks pretty good https://hono.dev/
|
# ? Jul 15, 2023 13:59 |
|
I looked at this and don't understand the built-in authentication. It's a single fixed login?
|
# ? Jul 15, 2023 18:27 |
|
Combat Pretzel posted:I looked at this and don't understand the built-in authentication. It's a single fixed login? I think it's just HTTP Basic Auth
|
# ? Jul 15, 2023 19:20 |
|
Yeah, but the examples just supply static login data. I'd expect a callback or something to look up things, e.g. in a database. I just looked up the source code, at least you can supply an array of logins. The bearer auth just accepts a single token to check against. So yeah, again...
|
# ? Jul 15, 2023 19:28 |
|
i just use fastify
|
# ? Jul 15, 2023 19:30 |
|
Combat Pretzel posted:Yeah, but the examples just supply static login data. I'd expect a callback or something to look up things, e.g. in a database. I think it's just middleware and you BYO storage engine?
|
# ? Jul 16, 2023 01:29 |
|
FML I'm doing JavaScript work again. Okay so I have this fullCalendar thing inside a div that needs to be normally hidden, but when you click a button it becomes un-hidden. But fullCalendar apparently does something to detect width or height of its container, and I guess when it initializes, one of those is 0. There are up to 6 calendars on a page. I think I have two options here:
Am I missing anything? All of these suck. Maybe the last one isn't so bad. cruft fucked around with this message at 23:43 on Jul 19, 2023 |
# ? Jul 19, 2023 23:41 |
|
I'm not sure I understand, you can add new fullCalendars and sometimes it initializes at 0 width/height? Can you fix that initialization? Is something happening that causes these dimensions to change after page load, where fullCalendar needs to fit into each individual div which may or may not be different? When you add a calendar it expands something and changes other dimensions? It kind of sounds like you might want to fix those things first if you can. Hide/unhide handlers should just do hide/unhide things without other complicated calculations imo. Needing to put in mutation observers seems unnecessary unless you're building on top of something you can't change in which case yeah you do have a few options but it depends on what exactly is happening. edit: are the dimensions fixed? Like can you just use css? AlphaKeny1 fucked around with this message at 08:56 on Jul 20, 2023 |
# ? Jul 20, 2023 08:43 |
|
I just did the third option with .xpand events and moved on. FullCalendar must be doing some weirdness with displayed size or something, I don't know. But if it's initialized inside a hidden div and then the div becomes unhidden, the calendar is trash until you resize the window or trigger a redraw by switching dates. I left a lot of sassy comments though, no need to worry about that.
|
# ? Jul 20, 2023 13:25 |
|
Lately I've been getting Typescript and React tutorials in my Youtube feed, and watching them, they multiply even more. Watching these, I'm always learning about new things, since I'm learning/making this poo poo up as I go at work. I came across the unknown type. These tutorials all tell me, I should use them in data fetching scenarios. I have some database abstraction layer I could put them in. But then I get told about type guards. In all the examples, they show simple types to check. However, when I fetch data from a database, and I get a 20 columns wide and 2000 rows long table, I really can't be assed to check all these fields in a type guard, because that's a performance loss at some point. How do you all do this? For instance just check the first row? Blindly cast to object or some (array of some) type?
|
# ? Jul 30, 2023 10:54 |
|
Combat Pretzel posted:Lately I've been getting Typescript and React tutorials in my Youtube feed, and watching them, they multiply even more. Watching these, I'm always learning about new things, since I'm learning/making this poo poo up as I go at work. You basically have two options here: 1. Do runtime schema validation with something like Zod or the new kid on the block Valibot. This has a runtime cost but it gives you confirmation that your types are what you think they are. 2. Create a type or interface called like Item (or whatever is being represented in the database) and then cast your data as Array<Item>. This is basically telling the compiler "I know better than you, and I know that this data is an Array of Items." It has no runtime cost but also does no actual runtime validation. If you know for sure that your database schema is being enforced elsewhere then option 2 is probably fine. If your database potentially has bad data in it and you want to fail early in those scenarios, option 1 is better. You can also just set up option 2 with a realistic representation of what will be in your database, i.e. mark fields as optional/nullable even if they're not "supposed" to be. That will move your type checking code downstream a little bit (i.e. having to check if "name" is present or not) but that might be better than just erroring out if you do runtime validation and the DB returns a lovely row. Depends entirely on how you want to manage receiving bad data in your app. Personally I would probably be very strict with user input but more lenient with data coming from the DB.
|
# ? Jul 30, 2023 14:23 |
|
I’m not sure what the benefit of unknown is vs passing a generic type of what you expect your API to return.
|
# ? Jul 30, 2023 15:35 |
|
If you cast as unknown aren't you gonna just get type errors when you try to access anything?
|
# ? Jul 30, 2023 16:18 |
Yeah, unknown it's for cases when you honestly are not sure what's going to be and you don't want to use any or it's not worth it to type every possible case for a very generic function that will work for most things (like functions that process arrays and don't care about their contents, so unknown[] works).
|
|
# ? Jul 30, 2023 16:36 |
|
I wouldn’t use unknown for a data source I control. Use it for 3rd party apis and data sources, not your database layer that you control.
|
# ? Jul 30, 2023 18:14 |
|
necrotic posted:I wouldn’t use unknown You can type even the 3rd party stuff by loosely defining only the stuff you use.
|
# ? Jul 30, 2023 22:30 |
|
Sure, and if I don’t care about those parts I wouldn’t type them. I’m mostly saying using unknown for first party isn’t necessary, but may be beneficial for third party (or just plain old user input, like if you offer an API for others to call)
|
# ? Jul 30, 2023 22:35 |
|
Curious if anyone knows why the implementation of sets in JavaScript feels so bad? Is this the result of having to move a proposal through W3C? Just one example is intersection: Python Intersection code:
code:
|
# ? Aug 18, 2023 19:07 |
|
There’s a TC-39 proposal to make set suck less https://github.com/tc39/proposal-set-methods W3C isn’t involved in JavaScript, the ECMA group handles JavaScript. The current Set was added back in ES6, which was the first major update to JavaScript in _years_. Why they added very a limited implementation I can't say (TC-39 wasn't around, and I'm not sure where to find any discussions prior to then). edit: found it, not a lot of discussion and its on a now defunct site. Thanks, wayback machine! https://web.archive.org/web/20170105121945/http://wiki.ecmascript.org/doku.php?id=harmony:simple_maps_and_sets necrotic fucked around with this message at 19:35 on Aug 18, 2023 |
# ? Aug 18, 2023 19:30 |
|
In all likelihood it just wasn't on the radar. Focus was on making it a very basic iterator like Map. All of the methods there are either specific to basic Set functionality (has, add, clear, delete) or came with it being an iterator (forEach, entries, keys, values) Arrays in JS don't have intersection either so there wasn't any sort of parity to try to keep there. Fwiw "[...x]" re-casts your entire set as an array in memory. Iterate through the Set itself and conditionally add to a new Set if this is something you're actually wanting to do in your code.
|
# ? Aug 18, 2023 19:47 |
|
Speaking of TC39 things, the goddamn IETF needs to get off their asses to finalize their timezones poo poo, so that Temporal can be finished.
|
# ? Aug 18, 2023 22:05 |
|
Ban time zones and ship it. Easy
|
# ? Aug 18, 2023 22:09 |
|
necrotic posted:Ban time zones and ship it. Easy I am willing to eat dinner at 11pm and go to bed at 5am if it means no more time zones. Hell that's what the Spanish do already.
|
# ? Aug 19, 2023 05:25 |
|
necrotic posted:Ban time zones and ship it. Easy prom candy posted:I am willing to eat dinner at 11pm and go to bed at 5am if it means no more time zones. Hell that's what the Spanish do already.
|
# ? Aug 19, 2023 23:21 |
|
On an AWS lambda with 10gb of memory, I'm hitting the NodeJS heap limit trying to stream a 7mb file and output a 3.5mb file. Running some garbage collection logs on my unit tests, but can't see anything unusual to indicate a memory leak. Even removing the streams and just loading data (smaller local files) into memory seems to make little difference. Any advice on how to find where this is going wrong?
|
# ? Aug 22, 2023 14:25 |
|
Have you configured the heap limit? https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes The crash report should mention how much was used when it shut down.
|
# ? Aug 22, 2023 17:28 |
|
I have to do some work on a windows machine, and I cannot do the work on WSL, it has to be on windows proper. Anyone have a recommendations for things like what terminal to use, what package manager to use (something similar to brew would be nice) etc for setting up a coding environment on windows. On mac everything feels great but on windows it all feels terrible. Will still use vscode. But obviously terminal/powershell sucks and I don't even know how to easily use things like nvm etc.
|
# ? Sep 10, 2023 05:29 |
|
there's "nvm for windows"
|
# ? Sep 10, 2023 10:06 |
|
Yeah I grabbed that. Turns out Windows terminal works decently well and nvm for Windows and git for Windows gets me enough of the way there. Now I just need to figure out some system to quickly switch my keyboard, mouse and main monitor between my two laptops
|
# ? Sep 11, 2023 01:40 |
|
Combat Pretzel posted:Speaking of TC39 things, the goddamn IETF needs to get off their asses to finalize their timezones poo poo, so that Temporal can be finished. OMG yes so hard hhrrrrrrrrrrgh I'm maintaining a site that displays schedules for an international conference; JavaScript's complete lack of standardized time zone handling is a frickin' nightmare.
|
# ? Sep 13, 2023 15:21 |
|
just installed our node_modules with bun instead of npm and it was 1.7 seconds vs. 14 are you loving kidding me?
|
# ? Sep 13, 2023 20:47 |
|
teen phone cutie posted:just installed our node_modules with bun instead of npm and it was 1.7 seconds vs. 14 yeah bun is very exciting
|
# ? Sep 13, 2023 20:48 |
|
these are the type of software projects that make me feel like i need to be doing something else with my life. this is 1000x cooler than anything i'll ever work on
|
# ? Sep 13, 2023 20:48 |
|
|
# ? Jun 8, 2024 06:48 |
|
teen phone cutie posted:just installed our node_modules with bun instead of npm and it was 1.7 seconds vs. 14 Wonder where they are getting the speed from. I guess part of it is just not being written in node.
|
# ? Sep 13, 2023 20:53 |