|
If you're reaaaally lazy you could do your database something like this demo of a blog/forum https://mongodb-sync.glitch.me/ Source code: https://glitch.com/edit/#!/mongodb-sync After finding that one I've even adapted it to make a little programming website that hosts submitted JavaScript classes MongoDB is a database where you don't have to mess with SQL; you could just store all your key values in a big JSON object turned into a string Happy Thread fucked around with this message at 22:09 on Mar 14, 2019 |
# ? Mar 14, 2019 22:07 |
|
|
# ? May 16, 2024 03:13 |
|
I'd definitely recommend Firebase over Mongo, for a couple reasons. One being cost (depending on scale, but this sounds small), another being operational overhead.
|
# ? Mar 14, 2019 22:40 |
|
What they did for that demo for MongoDB is they just signed up for a free account on mlab.com, which I did too and can confirm it's easy and easy to configure to store big dictionaries of JSON data. There were barely any steps involved. Their free service is also pretty slow (I think I did a stress test once and it wouldn't move more than like a megabyte per minute, with latency).
|
# ? Mar 14, 2019 23:23 |
|
Using firebase you can just toss your site up on a static host (including firebase, which has a static site hosting option). The mongo approach requires running your own backend for the mongo access.
|
# ? Mar 15, 2019 00:29 |
|
necrotic posted:Using firebase you can just toss your site up on a static host (including firebase, which has a static site hosting option). The mongo approach requires running your own backend for the mongo access.
|
# ? Mar 15, 2019 01:29 |
|
firestore has immediately mind-trapped me into obsessing over minimizing document gets even though realistically the 50k limit isn't anywhere near a problem yet
|
# ? Mar 15, 2019 02:26 |
|
This might be overkill because really I'm only looking to read from my database
|
# ? Mar 15, 2019 02:40 |
|
Just your friendly reminder that most people wanting to use mongo and the like should really be using a relational database.
|
# ? Mar 15, 2019 16:15 |
|
I have a relatively very simple library, it has one dependency. I'd like to add one or two simple tests to it but I'd like to do so without requiring loving 200 additional modules. I've looked at every single test lib I can find, is there anything pretty basic and simple out there? Should I just, essentially, write some asserts into a js file in order to avoid madness?
|
# ? Mar 16, 2019 14:29 |
|
Yeah, you could just use nodejs assert.
|
# ? Mar 16, 2019 14:37 |
|
I think I'm happy with this.JavaScript code:
Nolgthorn fucked around with this message at 15:41 on Mar 16, 2019 |
# ? Mar 16, 2019 15:36 |
|
JavaScript code:
JavaScript code:
|
# ? Mar 16, 2019 22:20 |
|
Testing libraries basic purpose is to make tests easier to run, read, write, and maintain at the cost of learning the testing library's rules and the installation of more modules. Some of the best unit tests I've seen have been just using the languages native assertion facilities.
|
# ? Mar 16, 2019 22:58 |
|
Fruit Smoothies posted:
I suggest removing the async from new Promise(async (done,fail) => {. Honestly I don't have a clue what exactly it would do in that context but I'm reasonably sure it's not meant to be there. Actually I think you might be able to get away with eliminating that whole wrapping Promise and just writing this.list.push(func());?
|
# ? Mar 16, 2019 23:07 |
|
Doom Mathematic posted:Actually I think you might be able to get away with eliminating that whole wrapping Promise and just writing this.list.push(func());? That is much simpler, but it doesn't solve the underlying issue sadly. It waits for the first promise, but not subsequent ones.
|
# ? Mar 16, 2019 23:17 |
|
Is the only way to add to the list from this add method? Either way, the wrapping promise is redundant. An async function itself is a promise so you're doubling up for no reason. The out of order execution is a different issue. I am not near a computer to really look at it, but will look later if you havent figured it out.
|
# ? Mar 16, 2019 23:49 |
|
Edit: Stil having issues
|
# ? Mar 17, 2019 01:00 |
|
Are you calling this as await obj.add or just plain obj.add? The latter won't work here, calling an async function spawns a new promise and if you do not wait on that promise it may not be invoked before the next time you call obj.add.
|
# ? Mar 17, 2019 16:08 |
|
necrotic posted:Are you calling this as await obj.add or just plain obj.add? The latter won't work here, calling an async function spawns a new promise and if you do not wait on that promise it may not be invoked before the next time you call obj.add. I'm not awaiting because add() is typically an event-emitted callback. I have given up and I'm now using an npm package called easy-promise-queue. Thanks though
|
# ? Mar 17, 2019 17:29 |
|
Fruit Smoothies posted:I'm not awaiting because add() is typically an event-emitted callback. I have given up and I'm now using an npm package called easy-promise-queue. Thanks though Using a library is probably a good choice. For your learning, this approach works if you can't await the call to add: code:
|
# ? Mar 17, 2019 17:36 |
|
Why do JavaScript's ES Modules sort their contents alphabetically when you import them? Why would anyone want that? I'm trying to show the user the contents of their code, but this behavior scrambles up the file. There's no way to recover the original order. So instead I have to do this gross thing where everything declared in the module is assigned to both the module's scope and some extra JS object, since those do preserve insertion order of key/value entries. This is so odd to me because I can't think of why anyone would want to access a bunch of code definitions alphabetically. Does the Module tree shaking algorithm actually look at every definition imported, and compare for redundancy against all previous definitions from all modules in a big lookup table, and so the alphabetical sorting speeds up that lookup or something? Did I defeat that by just exporting everything in one object to unpack later, and will that matter?
|
# ? Mar 17, 2019 19:46 |
|
Sounds to me like you're using a big stew of holy hell there's a lot of libraries that I'm using, and one of them has strange behaviour or is interacting with some other library that is causing strange behaviour. Because if all you are doing is reading the file to look at the code there is no reason why anything would be any different from exactly the way it was written.
|
# ? Mar 17, 2019 19:50 |
|
Quite the contrary, I import no libraries and just a couple files that I wrote. Those files are full of es6 class definitions. I'm using Chrome if it's engine dependent but this should be fairly easy behavior for anyone to reproduce. When I use an es6 "import" statement and place a breakpoint the line right after, all those class definitions in the "Module" type object returned are immediately in alphabetical order. Try it. As a workaround I'm instead having to do stuff like this to export classes from my "tiny graphics" setup file. That is, wrapping them in an extra object called "tiny": code:
code:
The definitions' order matters since the earlier ones in the file are more basic and fundamental to the codebase, and thus are the ones I want to ease the user into first in the generated tutorial. Happy Thread fucked around with this message at 20:23 on Mar 17, 2019 |
# ? Mar 17, 2019 20:00 |
|
I have no idea what you are trying to do but from a cursory glance you are defining a const, then defining a class with the same variable name. And you're assigning it to a variable in an object and then you're exporting the object within another object and then destructing the object in order to import it. So that what?
|
# ? Mar 17, 2019 21:51 |
|
Dumb Lowtax posted:Why do JavaScript's ES Modules sort their contents alphabetically when you import them? Why would anyone want that? I'm trying to show the user the contents of their code, but this behavior scrambles up the file. There's no way to recover the original order. So instead I have to do this gross thing where everything declared in the module is assigned to both the module's scope and some extra JS object, since those do preserve insertion order of key/value entries. I don't understand. Where does this actually cause you trouble? How are you viewing these? There is no inherent ordering to modules members OR to objects. (though that is actually changing, but not something I would depend upon. ES incorporated the de-facto browser behavior for object keys and uses insertion order...unless your keys are integers!) If you're dependent upon the ordering to your module members or to your objects, then really you're dependent upon a specific implementation and version of your JS interpreter. It's pretty common for user interfaces to use lexicographic ordering for displaying lists of stuff that has no inherent order since that usually makes more sense then some pseudo random order that will change the next time some underlying implementation-dependent code changes. I think most people would find lexicographic order the most useful. Thermopyle fucked around with this message at 22:40 on Mar 17, 2019 |
# ? Mar 17, 2019 22:30 |
|
Nolgthorn posted:So that what? I'm saying that the code is that way because I can't just export my class definitions individually. I have to keep them in BOTH module scope and in an extra object. Module scope so they can see and extend each other, extra object so that their ordering is preserved. That seems to be the only workaround. In all current major JavaScript engines, objects maintain their contents in order of insertion. This is not likely to change soon and I'm not worried about depending on it for something aesthetic. An ES Module by comparison does not work that way. Of you attempt to iterate over it you get the members back in alphabetical order. Thermopyle posted:I don't understand. Where does this actually cause you trouble? How are you viewing these? I am iterating through all my class definitions in a certain file to list them out on the HTML page. It's an educational programming site where each little sub-program is mostly made out of a few class definitions, and I want to show those by printing them out. It makes the most sense to show them in the order they were declared in the file, because that is the intended order of understanding them. It makes sense to ease my users into that codebase starting with the math helper classes and then the geometry helper classes and then the graphics classes and more high level stuff. Not in some other order.
|
# ? Mar 17, 2019 22:45 |
|
Dumb Lowtax posted:In all current major JavaScript engines, objects maintain their contents in order of insertion. This is not exactly true. Integer-ish keys will be first and they will be sorted in ascending order. String keys will then come next and they will be insertion order. Functions next in insertion order. Then symbols come last and they will be in insertion order. And then, of course, that ordering is only guaranteed for some methods of iteration on an objects keys and not others, but I can't remember the details on that. edit: And more to your original point, I don't think there's any standard on how modules should be iterated so someone at Chrome Headquarters just made a reasonable choice to do it lexicographically I guess. Thermopyle fucked around with this message at 22:57 on Mar 17, 2019 |
# ? Mar 17, 2019 22:54 |
|
Right, I'm not talking about integer keys of course. Besides that easy to find exception what I said holds true; these are class definitions with names, not integers, and I wouldn't pack them into an array with some integer keys too. Iterating with for....of iterates in the same order as my file, and has had the result that I want. I've been doing it this way successfully, I was wondering why they made this use case so difficult. We're talking about Modules, so they're full of code definitions. Alphabetical reordering of *code definitions* does not make much sense to me since code is placed into a file in a meaningful order. I think they should have used insertion order for Modules unless there is some benefit to tree shaking that I'm not aware of. Happy Thread fucked around with this message at 23:06 on Mar 17, 2019 |
# ? Mar 17, 2019 23:03 |
|
Isn’t your use case extraordinarily rare?
|
# ? Mar 17, 2019 23:08 |
|
I think it affects everyone who uses es6 modules. They get back a data structure that's supposed to be full of code definitions but it's in a strange non-code order. Even my use case doesn't seem that uncommon, it's just using some introspection into its own source code to print it out
|
# ? Mar 17, 2019 23:11 |
|
So to be clear, you're doing something likeJavaScript code:
JavaScript code:
Are there other programming languages/module systems where the source order of the named exports is significant?
|
# ? Mar 18, 2019 00:13 |
|
I very genuinely do not mean to "you're doing it wrong" but this:Dumb Lowtax posted:I am iterating through all my class definitions in a certain file to list them out on the HTML page. is not what the es6 module API was designed for.
|
# ? Mar 18, 2019 01:16 |
|
If I were trying to render html based on some code in a file, I'd read the file and try to parse it myself. Ie, I'd look for class definitions, I'd even have line numbers if I did it that way so that's what I recommend.
|
# ? Mar 18, 2019 01:23 |
|
Dumb Lowtax posted:I think it affects everyone who uses es6 modules. It doesn't. Most people just import {thing, otherthing} from 'things'; because we don't care about anything else in the module and the reason I know thing and otherthing are in things is that I looked it up in the documentation. Or read the source since a lot of documentation is poo poo in JS-land.
|
# ? Mar 18, 2019 01:52 |
evilfunkyogi posted:I very genuinely do not mean to "you're doing it wrong" but this: Yeah, if you want people to look at code why not just give them the code? Have them browse it in an IDE or on github or whatever.
|
|
# ? Mar 18, 2019 11:06 |
|
Osmosisch posted:Yeah, if you want people to look at code why not just give them the code? Have them browse it in an IDE or on github or whatever.
|
# ? Mar 18, 2019 13:55 |
|
Do they all do it in definition order, or ABC order? I thought ABC order was basically the standard for any doc generation.
|
# ? Mar 18, 2019 15:11 |
mystes posted:I guess you had better tell that to every language that has a way to generate html documentation/code listings? Documentation is not what's being discussed. If a language has the feature of generating html listings, more power to it. I'd call that wasted effort in the current ecosystem, but whatever. It's also not what Dumb Lowtax is asking about, unless I've completely misunderstood what's going on here (always entirely possible).
|
|
# ? Mar 18, 2019 15:12 |
|
Cross posting this from the modern-front end developer thread. I'm pretty new at all of this and am still learning. I have 8 hours at work everyday to listen to podcasts and was wondering if there are any that one of you can recommend to me for a beginner. Just to help supplement what I'm learning on my own/through this bootcamp. Maybe ways of thinking, or algorithms, or ways to code cleanly. I'm not sure exactly what I'm even looking for is part of the problem.
|
# ? Mar 18, 2019 16:28 |
|
|
# ? May 16, 2024 03:13 |
|
Syntax is pretty good: https://syntax.fm/
|
# ? Mar 18, 2019 19:46 |