A month ago, Evan You (of Vue.js and VoidZero fame) gave his annual address. Less Vue-focused than usual (though Vapor Mode is βalmost readyβ), the talk focuses on Vite-ecosystem updates covering Vite 8, Vite+, and Void.
Evan You / Vue.js Amsterdam
Please open Telegram to view this post
VIEW IN TELEGRAM
β€5π2π₯1
CHALLENGE
const partial = (fn, ...presetArgs) => {
return function partiallyApplied(...laterArgs) {
return fn(...presetArgs, ...laterArgs);
};
};
const calculateTax = (taxRate, discount, price) => {
const discounted = price - (price * discount) / 100;
return parseFloat((discounted + (discounted * taxRate) / 100).toFixed(2));
};
const withVAT = partial(calculateTax, 20);
const withVATandDiscount = partial(withVAT, 15);
console.log(withVAT(0, 100));
console.log(withVATandDiscount(200));
console.log(partial(calculateTax, 10, 5)(50));
What is the output?
Anonymous Quiz
34%
120 204 52.25
44%
120 170 47.5
18%
100 204 52.25
5%
120 204 47.5
β€3
The Bun runtime has had a great run of releases, including last weekβs v1.3.12 with built-in browser automation. Now, bun test gets numerous enhancements with --isolate, --parallel, --shard and --changed options for test env isolation, parallelization, and to run only test files affected by recent changes. The runtime now uses 5% less memory, bun install gets faster, and more.
Jarred Sumner
Please open Telegram to view this post
VIEW IN TELEGRAM
π₯3β€2π2
CHALLENGE
const values = [0.1 + 0.2, NaN, Infinity, -0, 42.6789];
const results = values.map((v, i) => {
if (i === 0) return v.toFixed(2);
if (i === 1) return Number.isFinite(v) + " " + Number.isNaN(v);
if (i === 2) return Number.isFinite(v) + " " + isFinite(v);
if (i === 3) return Object.is(v, 0) + " " + Object.is(v, -0);
if (i === 4) return v.toPrecision(4);
});
console.log(results.join(" | "));
β€3π2π₯1
β’ git history offers a new, easy way to edit commit messages or interactively split a commit into two.
β’ You can now define hooks in config files (whether in a repo, at user level, or even system level) rather than just in
.git/hooks. You can also run multiple hooks for the same event in this way.Please open Telegram to view this post
VIEW IN TELEGRAM
β€5π₯3
CHALLENGE
async function* paginate(items, pageSize) {
for (let i = 0; i < items.length; i += pageSize) {
const page = items.slice(i, i + pageSize);
yield await Promise.resolve(page);
}
}
async function* transform(source, fn) {
for await (const chunk of source) {
yield fn(chunk);
}
}
async function run() {
const data = [10, 20, 30, 40, 50, 60];
const pages = paginate(data, 2);
const mapped = transform(pages, (page) => page.map((x) => x * 2));
const results = [];
for await (const page of mapped) {
results.push(page.reduce((a, b) => a + b, 0));
}
console.log(results);
}
run();β€2π2
What is the output?
Anonymous Quiz
37%
[ 20, 40, 60, 80, 100, 120 ]
23%
[ 30, 70, 110 ]
32%
[ 60, 140, 220 ]
8%
[ 10, 20, 30, 40, 50, 60 ]
Yes, another one! Whatβs noteworthy is it comes from the developer of mise, a tool that makes managing numerous languages so much easier. aubeβs selling points are raw performance and being a drop-in replacement. Its defaults are also security-focused.
Jeff Dickey
Please open Telegram to view this post
VIEW IN TELEGRAM
β€2π₯2π1
CHALLENGE
class ValidationError extends Error {
constructor(message, field) {
super(message);
this.name = "ValidationError";
this.field = field;
}
}
class NetworkError extends ValidationError {
constructor(message, field, statusCode) {
super(message, field);
this.name = "NetworkError";
this.statusCode = statusCode;
}
}
const err = new NetworkError("Not Found", "endpoint", 404);
console.log([
err instanceof NetworkError,
err instanceof ValidationError,
err instanceof Error,
err instanceof TypeError,
].join(", "));
π2β€1
What is the output?
Anonymous Quiz
28%
true, true, false, false
26%
true, false, true, false
43%
true, true, true, false
3%
false, true, true, false
Build composable parsers for CLIs with type safety, type inference, and built-in shell completion support, plus config file integration and man page generation from the same definitions. v1.0 is the first stable release and Hong compares it to Commander.js and explains why you'd use Optique.
Hong Minhee
Please open Telegram to view this post
VIEW IN TELEGRAM
β€4π₯1
CHALLENGE
function* counter(start, end) {
for (let i = start; i <= end; i++) {
yield i;
}
}
function* pipeline() {
const first = yield* counter(1, 3);
console.log("Counter done:", first);
yield "bridge";
const second = yield* counter(7, 9);
console.log("Counter done:", second);
}
const gen = pipeline();
const results = [];
let next = gen.next();
while (!next.done) {
results.push(next.value);
next = gen.next();
}
console.log(results);β€3π1
What is the output?
Anonymous Quiz
25%
[1, 2, 3, 'bridge', 7, 8, 9] Counter done: undefined Counter done: undefined
33%
[1, 2, 3, 'bridge', 7, 8, 9] Counter done: 3 Counter done: 9
32%
Counter done: undefined Counter done: undefined [ 1, 2, 3, 'bridge', 7, 8, 9 ]
10%
Counter done: 3 Counter done: 9 [1, 2, 3, 'bridge', 7, 8, 9]
π₯3π2β€1
CHALLENGE
const config = {
host: "localhost",
port: 3000,
db: {
name: "mydb",
maxConnections: 10
}
};
Object.freeze(config);
config.port = 9999;
config.db.maxConnections = 99;
config.newProp = "surprise";
delete config.host;
const sealed = Object.seal({ x: 1, y: 2 });
sealed.x = 100;
sealed.z = 999;
delete sealed.y;
console.log(config.port, config.db.maxConnections, config.host);
console.log(sealed.x, sealed.y, sealed.z);
What is the output?
Anonymous Quiz
28%
3000 10 localhost
19%
9999 10 undefined
26%
9999 99 undefined
28%
3000 99 localhost 100 2 undefined
β€3
CHALLENGE
async function fetchData(id) {
if (id < 0) throw new Error("Invalid ID");
return { id, value: id * 10 };
}
async function process() {
const results = await Promise.allSettled([
fetchData(1),
fetchData(-1),
fetchData(3),
]);
results.forEach(({ status, value, reason }) => {
if (status === "fulfilled") {
console.log(`fulfilled: ${value.id} -> ${value.value}`);
} else {
console.log(`rejected: ${reason.message}`);
}
});
}
process();
β€3π1π€1
If you donβt read the specs or endless posts about new language features, this is a great way to catch up. Most of the features are supported in Node, like Promise.try, Set union/intersection/difference, Array.fromAsync, and using, with others soon to land, like Math.sumPrecise and Map.getOrInsert (in Node 26).
Neciu Dan
Please open Telegram to view this post
VIEW IN TELEGRAM
β€4π1π₯1π€©1