Today I learned about...
node
Back to all tags
rss feed generator
TIL about feed
, an npm package that allows you to quickly generate an RSS feed for your website!
I used it to generate an RSS feed for my blog and my TIL feeds! It’s pretty simple and super easy to plug into your existing project.
Node Modules Inspector
TIL about the node-modules-inspector
— a package that allows you to visualize your node_modules folder,
inspect your dependencies, and so much more 🤯! I’m a big fan of the visualizations, since I’m more of a
visual kinda person. You can use it in your own project with this simple command: npx node-modules-inspector
.
Better node objects logging!
Sick of seeing truncated Objects
in Node? I got you bro (well Matt Pocock has
got you).
let deepNesting = {
level1: {
level2: {
level3: {
level4: {
level5: {
name: 'Moderately Nested Object',
value: 42,
attributes: {
created: '2023-10-01',
modified: '2023-10-15',
tags: ['demo', 'test', 'nested'],
metadata: {
author: 'Jane Doe',
version: '1.0',
license: 'MIT',
},
},
items: [
{
id: 1,
description: 'First item',
status: 'active',
},
{
id: 2,
description: 'Second item',
status: 'inactive',
},
],
},
},
},
},
},
}
// logs: { level1: { level2: { level3: [Object] } } }
console.log(deepNesting)
// You get the whole object!
console.dir(deepNesting, { depth: Infinity })
Matt is the man!
node require cache
TIL that commonjs
has a require
cache. Basically, if you require a module
once in the file, it gets cached and if you attempt to require the module a
second time, EVEN IF THE CONTENT HAS CHANGED, you’ll get the cached version.
Usually this isn’t a problem but it bit me in the butt when I moved my remix app over to be using express. I had to call this function inside of my server code when remix finished rebundling.
function clearRequireCache() {
Object.keys(require.cache).forEach(function (key) {
delete require.cache[key]
})
}
Promise Based Node Functions
TIL during a basic async node training video, that the node core api exposes
promisified (I think that’s a word) functions. For example fs
provides a
promise based API.