TGViewer
HowProgrammingWorks - JavaScript and Node.js Programming HowProgrammingWorks - JavaScript and Node.js Programming @howprogrammingworks · 6.51K subscribers
Post #1795 3.17K
🧩 This and much more will be covered in Patterns 2025 course

const getTomorrowDate = () => {
const timeout = 86400000;
return new Promise((resolve) => {
setTimeout(() => resolve(new Date()), timeout)
});
};


// ⚡️ Electricity over IP, as defined in RFC 3251: https://datatracker.ietf.org/doc/html/rfc3251
const socket = new WebSocket('wss://lamp.local:3251');

socket.onopen = () => {
socket.send(JSON.stringify({ voltage: 230, frequency: 50 }));
};

socket.onmessage = (e) => {
const { voltage, frequency } = JSON.parse(e.data);
console.log(`⚡️ Transferred: ${voltage}V @ ${frequency}Hz`);
};


const Coin = (v) => ({ map: (f) => Coin(f(v)) });
const flip = () => crypto.getRandomValues(new Uint8Array(1))[0];
Coin(flip()).map((r) => (r & 1 ? '🪙' : '💩')).map(console.log);


const findMeaningOfLife = () => {
const offset = 0;
const delay = Infinity;
return new Promise((resolve) => {
setTimeout(() => resolve(42 + offset), delay);
});
};


['🥚', '🥚',  '🐓', '🥚', '🥚', '🥚'].toSorted()


class Coming {
constructor() {
return new Promise((resolve) =>
setTimeout(() => {
resolve(this);
}, DAY_OF_JUDGMENT - Date.now())
);
}
}

const secondComing = await new Coming();


((<F extends () => void>(Function: F = {} as F) => Function())());


class Future {
constructor() {
const { name: key } = this.constructor;
const value = void [].length;
throw new Error(`${key} is ${value}`);
}
}

new Future();
  • 🤣 14
  • 👍 7
  • 🔥 1
  • 😢 1
More from @howprogrammingworks
  1. Oct 4, 2026Объем текста и объем кода должны заставлять нас не махнуть рукой, а заставлять ии делать м…
  2. Oct 3, 2026https://youtu.be/I5ILntVSjkQ
  3. Oct 2, 2026Dashboard with real-time monitoring Released in reslop v0.2.6 https://github.com/tshemsedi…
  4. Oct 2, 2026video post
  5. Oct 1, 2026Что AI научился делать действительно хорошо, так это максимально отсрочить катастрофу в пр…
  6. Sep 30, 2026Тут пример, как я сделал рефакторинг reslop при помощи - Opus 5.5 как старшая модель - Gro…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →