The Node.js® Website

doc: update examples (#6367)

Co-authored-by: Claudio W <cwunder@gnome.org>

authored by Geoffrey Booth Claudio W and committed by GitHub 19cd9f9a accacc18

+4 -4
+4 -4
pages/en/new-design/index.mdx
··· 65 }); 66 67 test('that throws as 1 is not equal 2', () => { 68 - // throws an exception because 1!=2 69 assert.strictEqual(1, 2); 70 }); 71 ``` ··· 99 ``` 100 101 ```js displayName="Work with Threads" 102 - import { Worker, isMainThread } from 'node:worker_threads'; 103 - import { workerData, parentPort } from 'node:worker_threads'; 104 105 if (isMainThread) { 106 const data = 'some data'; 107 const worker = new Worker(import.meta.filename, { workerData: data }); 108 - worker.on('message', m => console.log('Reply from Thread:', m)); 109 } else { 110 const source = workerData; 111 parentPort.postMessage(btoa(source.toUpperCase()));
··· 65 }); 66 67 test('that throws as 1 is not equal 2', () => { 68 + // throws an exception because 1 != 2 69 assert.strictEqual(1, 2); 70 }); 71 ``` ··· 99 ``` 100 101 ```js displayName="Work with Threads" 102 + import { Worker, isMainThread, 103 + workerData, parentPort } from 'node:worker_threads'; 104 105 if (isMainThread) { 106 const data = 'some data'; 107 const worker = new Worker(import.meta.filename, { workerData: data }); 108 + worker.on('message', msg => console.log('Reply from Thread:', msg)); 109 } else { 110 const source = workerData; 111 parentPort.postMessage(btoa(source.toUpperCase()));