3
3

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.

14

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.

6
24
9
32
[-] philnash@programming.dev 2 points 1 year ago

That’s brilliant!

[-] philnash@programming.dev 5 points 1 year ago

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.

[-] philnash@programming.dev 6 points 1 year ago

While this article is about JavaScript specifically, these issues certainly exist in other regex engines too.

1
[-] philnash@programming.dev 4 points 1 year ago

Ah, I didn’t realise there was a regex channel here. Thanks!

105
[-] philnash@programming.dev 3 points 1 year ago

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!

16
22
3
submitted 1 year ago* (last edited 1 year ago) by philnash@programming.dev to c/typescript@programming.dev

Click bait title, but this post goes into depth about using tsconfig.json correctly and across different layers of your project.

view more: next ›

philnash

joined 1 year ago