Generate Related Posts for Your Astro Blog with Vector Search
Learn how to add a related posts feature to a blog built with JavaScript framework Astro using Astra DB and OpenAI vector embeddings.
Node.js is reducing friction when using ES modules by making it easier to get the current module directory name
cross-posted from: https://programming.dev/post/11927506
> Many times when I’ve tried to write some code in Node.js using ES modules I’ve found myself reaching for __dirname and then looking up how to replace it. Now Node.js, Deno and Bun support import.meta.dirname. Check out the article for more detail.
Node.js is reducing friction when using ES modules by making it easier to get the current module directory name
Many times when I’ve tried to write some code in Node.js using ES modules I’ve found myself reaching for __dirname and then looking up how to replace it. Now Node.js, Deno and Bun support import.meta.dirname. Check out the article for more detail.
Learn how you can create a custom text-to-image generation model using JavaScript, SDXL and Replicate without needing a machine learning background or needing specialized hardware.
The JavaScript Set was introduced to the language in the ES2015 spec, but it has always seemed incomplete. That's about to change with the addition of functions like intersection, union and difference.
We share the biggest three issues we faced and the lessons we learned as we upgraded SonarQube to React 18.
Nesting ternary operators makes code more complex and less clear. Let's investigate other ways to write conditional expressions.
That’s brilliant!
JavaScript's regex engine isn't the only one to have these problems. There certainly are other implementations, like Re2 and Rust's implementation, that don't have this issue. But they also lack some of the features of the JS implementation too.
While this article is about JavaScript specifically, these issues certainly exist in other regex engines too.
A deep investigation into regular expression denial of service (ReDoS) vulnerabilities in JavaScript
Ah, I didn’t realise there was a regex channel here. Thanks!
A deep investigation into regular expression denial of service (ReDoS) vulnerabilities in JavaScript
The only real way to validate an email address is send it an email and see if it arrives! I'm sure many of us have fallen to the urge to validate an email with a regex though, and yes, it's just too dangerous! I definitely like the simplicity of checking for an @
.
I think regular expressions are actually very tempting to use because they seem hard. I feel like I go through this XKCD comic every time the opportunity to use a regex comes up. But string functions often have the answer. I hope, if this article achieves anything, it just stops people using regex to trim whitespace!
A deep investigation into regular expression denial of service (ReDoS) vulnerabilities in JavaScript
Many popular npm packages depend on 6-8x more packages than they need to. Most of these are unnecessary polyfills and it's one of the key reasons node_modules folders are so large. The eslint ecosystem seems to be most affected by this.
One of the most common mistakes in configuring TypeScript.
Click bait title, but this post goes into depth about using tsconfig.json correctly and across different layers of your project.
At some point in the distant past, certain Node.js projects adopted the convention of using the NODE_ENV environment variable to denote how the project was being run. For example:
TypeScript already understands JavaScript, but you can get more out of it when you add types to your JavaScript with JSDoc or TypeScript declaration files
This is a follow up to my previous article on how to get more TypeScript benefits in your JavaScript. This goes into how to add types using JSDoc or TypeScript declaration files.
Grouping items in an array is one of those things you've probably done a load of times. Each time you would have written a grouping function by hand or...
Let's dive into what you can do to get more and more of TypeScript's benefits in your JavaScript projects.
Node.js 20.6.0 includes built-in support for .env files
With the recent release of version 20.6.0, Node.js now has built-in support for .env files. You can now load environment variables from a .env file into...
What is SAST, what does deeper SAST mean, and how does this apply to your JavaScript and TypeScript applications?
I’m writing books about TypeScript and I do workshops and trainings online and in-house. Every time I meet a new group of developers there are some TypeScript facts that they need to be confronted with:
Generating pagination links is not as straightforward as it may seem. So, while rebuilding my own site with Astro, I released a <Pagination /> component on...
I think you're absolutely right about the difficulty for developers inadvertently getting the legacy assert behaviour. Though I hope if they do that, they at least recognise that they can use the strict
methods.
The early module had both non-strict and strict methods, even from that early time, so the original author recognised the need for using ===
, but I guess wanted to be flexible and allow for ==
usage too. Perhaps this was a bad decision, but it was made in version 0.1.21, so I would guess there was a lot of fast work going on with Node at the time and maybe not everything was thought through in as much depth as it could be. It's possible that one day the strict module may take over the place of the existing assert module, but that would be quite the breaking change!