JavaScript
31.4K subscribers
1.18K photos
10 videos
33 files
858 links
A resourceful newsletter featuring the latest and most important news, articles, books and updates in the world of #javascript πŸš€ Don't miss our Quizzes!

Let's chat: @nairihar
Download Telegram
CHALLENGE


const createModule = (() => {
const privateCache = new WeakMap();

return function(name) {
const state = { name, version: 1, active: true };
privateCache.set(state, { accessCount: 0 });

return {
getInfo() {
const meta = privateCache.get(state);
meta.accessCount++;
return `${state.name}@v${state.version}`;
},
getAccessCount() {
return privateCache.get(state).accessCount;
},
upgrade() {
state.version++;
return this;
}
};
};
})();

const mod = createModule("auth");
mod.upgrade().upgrade();
console.log(mod.getInfo());
console.log(mod.getAccessCount());
❀2πŸ‘1
❀3πŸ‘2
πŸ€– Mark Erikson's Agent Setup, Workflow, and Tools

Mark, well known for maintaining Redux and creating Redux Toolkit, goes deep into his daily development workflow, including his use of OpenCode (an open source JavaScript-powered coding agent), how he manages his knowledge base, tasks, and more.

Mark Erikson
Please open Telegram to view this post
VIEW IN TELEGRAM
❀6πŸ‘3πŸ”₯2
CHALLENGE


const str = "JavaScript is Awesome!";

const result = str
.split(" ")
.map((word, i) =>
i % 2 === 0
? word.toUpperCase()
: word.toLowerCase()
)
.join("-");

const reversed = result
.split("")
.reduce((acc, char) => char + acc, "");

console.log(reversed);
πŸ”₯2❀1
πŸ‘€ Orval: Generate Type-Safe Clients from OpenAPI/Swagger Specs

Given a valid OpenAPI v3 or Swagger v2 spec, generate models, requests, hooks, and mocks for React, Vue, Svelte, Solid, and Hono apps, or even plain fetch.

Victor Bury
Please open Telegram to view this post
VIEW IN TELEGRAM
❀4πŸ‘2πŸ”₯1
CHALLENGE

const delay = (ms, val) => new Promise(res => setTimeout(res, ms, val));

async function* asyncGen() {
yield await delay(10, "alpha");
yield await delay(10, "beta");
yield await delay(10, "gamma");
}

async function run() {
const results = [];

const gen = asyncGen();
const [first, , third] = await Promise.all([
gen.next(),
gen.next(),
gen.next()
]);

results.push(first.value, third.value);

const p1 = Promise.resolve("x").then(v => v + "1");
const p2 = Promise.reject("err").catch(e => e + "2");

results.push(...(await Promise.all([p1, p2])));
console.log(results);
}

run();
❀7πŸ‘3
✌️ Andrea Giammarchi proposes JSONRegistry (above), an alternative to JSON that lets you define a registry for serializing and reviving custom/branded types.
Please open Telegram to view this post
VIEW IN TELEGRAM
❀5πŸ‘1πŸ”₯1
CHALLENGE


const tag = (strings, ...values) => {
return strings.reduce((result, str, i) => {
const value = values[i - 1];
const transformed =
typeof value === "number" ? `[${value ** 2}]` : `{${value}}`;
return result + transformed + str;
});
};

const name = "Sofia";
const score = 4;
const level = "gold";

const output = tag`Player: ${name}, Score: ${score}, Rank: ${level}`;
console.log(output);
πŸ”₯3❀2πŸ‘2
🀟 A Fresh Chapter and New Look for Express

For a while, Node’s long-standing web framework, Express.js, was looking a bit stale and projects like Fastify were beginning to carry the torch, but a major reboot that began in 2024 brought Express back to the fore. Now Express’s brand, website, and docs have time-travelled to 2026 too.

Sebastian Beltran
Please open Telegram to view this post
VIEW IN TELEGRAM
❀7πŸ‘3🀩3
CHALLENGE

const prefix = "get";
const suffix = "Name";

const registry = {
[`${prefix}Full${suffix}`]: function () {
return `${this.first} ${this.last}`;
},
[`${prefix}Short${suffix}`]: function () {
return this.first[0] + ". " + this.last;
},
};

const person = {
first: "Leonardo",
last: "Fibonacci",
...registry,
};

const key = ["Full", "Short"][1];
console.log(person[`${prefix}${key}${suffix}`]());
❀1πŸ‘1
❀3πŸ”₯1
🀟 An Official Codemod to Migrate from Axios to fetch

A codemod (used via npx codemod) that transforms code using Axios to leverage the WHATWG Fetch API, which is now natively available in Node.js. For some reason they don’t link to it in the post, but it’s here if you want to try it out (and here’s the underlying code).

Augustin Mauroy
Please open Telegram to view this post
VIEW IN TELEGRAM
❀5πŸ‘3🀩1🀣1
CHALLENGE


const config = {
db: { host: "localhost", port: 5432 },
cache: { ttl: 300 },
};

Object.freeze(config);

config.debug = true;
config.db.port = 9999;
config.cache = { ttl: 600 };

const sealed = Object.seal({ version: "1.0", meta: { build: 42 } });

sealed.version = "2.0";
sealed.author = "devteam";
sealed.meta.build = 99;

console.log(
config.debug,
config.db.port,
config.cache.ttl,
sealed.version,
sealed.author,
sealed.meta.build
);
❀5
😱 Bun's Zig-to-Rust porting saga continues, but what about Node...? The Rust-based rewrite of Bun has been merged, though there are questions over the quality of the AI-ported code. Matteo Collina and Luca Maraschi got together to πŸ˜‰ discuss the story and speculate whether Node could follow...
Please open Telegram to view this post
VIEW IN TELEGRAM
πŸ”₯6πŸ‘4❀2🀣2πŸ€”1
CHALLENGE


const flags = {
READ: 0b0001,
WRITE: 0b0010,
EXECUTE: 0b0100,
DELETE: 0b1000,
};

const userPermissions = flags.READ | flags.WRITE | flags.EXECUTE;
const adminPermissions = userPermissions | flags.DELETE;

const canDelete = (adminPermissions & flags.DELETE) !== 0;
const canExecute = (userPermissions & flags.EXECUTE) !== 0;
const readOnly = userPermissions ^ flags.WRITE;

console.log(canDelete, canExecute, readOnly, adminPermissions >> 1);
❀2πŸ‘1πŸ”₯1
πŸ‘4❀3
CHALLENGE


const team = {
name: "Alpha",
members: ["Carlos", "Diana", "Eve"],

listMembers() {
return this.members.map(function (member) {
return `${this.name}: ${member}`;
});
},

listMembersArrow() {
return this.members.map((member) => {
return `${this.name}: ${member}`;
});
},
};

console.log(team.listMembers()[0]);
console.log(team.listMembersArrow()[0]);
❀7πŸ”₯3πŸ‘1