Chapter 14 of 22Part III: Cybersecurity and Privacy
The Invisible Digital Enemy
6 Verified Book Snippets
Every .js file below is byte-identical (SHA-256 verified) to the printed code in Volume 1. Runnable blocks execute inside an isolated sandboxed iframe and Web Worker with a 2-second timeout and zero network access.
Dependencies: None (standard ES2022 JavaScript). Defines pure JavaScript functions or data; runs cleanly in the sandbox (call console.log in a test harness to inspect values).
function step(states, links, blocked = []) {
const next = [...states];
for (const [a, b] of links) {
if (blocked.includes(a) || blocked.includes(b)) continue;
if (states[a] === 'I' && states[b] === 'S') next[b] = 'I';
if (states[b] === 'I' && states[a] === 'S') next[a] = 'I';
}
return next;
}
Dependencies: None (standard ES2022 JavaScript). Defines pure JavaScript functions or data; runs cleanly in the sandbox (call console.log in a test harness to inspect values).
Dependencies: None (standard ES2022 JavaScript). Defines pure JavaScript functions or data; runs cleanly in the sandbox (call console.log in a test harness to inspect values).