What an AI crawler reads
Skip to contentRun JavaScript EverywhereNode.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.Get Node.js®Get Node.js®Get security supportfor EOL Node.js versionsNode.js is proudly supported by the partners above and more. Create an HTTP ServerWrite TestsRead and Hash a FileStreams PipelineWork with Threads// server.mjs import { createServer } from 'node:http'; const server = createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello World!\n'); }); // starts a simple http server locally on port 3000 server.listen(3000, '127.0.0.1', () => { console.log('Listening on 127.0.0.1:3000'); }); // run with `node server.mjs`JavaScriptCopy to clipboard// tests.mjs import assert from 'node:assert'; import test from 'node:test'; test('that 1 is equal 1', () => { assert.strictEqual(1, 1); }); test('that throws as 1 is not equal 2', () => { // throws an exception because 1 != 2 assert.strictEqual(1, 2); }); // run with `node tests.mjs`JavaScriptCopy to clipboard// crypto.mjs import { createHash } from 'node:crypto'; import { readFile } from 'node:fs/promises'; const hasher = createHash('sha1'); hasher.setEncoding('hex'); // ensure you have a `package.json` file for this test! hasher.write(await readFile('package.json')); hasher.end(); const fileHash = hasher.read(); // run with `node crypto.mjs`JavaScriptCopy to clipboard// streams.mjs import { crea
What a human sees after JavaScript
Skip to contentRun JavaScript EverywhereNode.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.Get Node.js®Get Node.js®Get security supportfor EOL Node.js versionsNode.js is proudly supported by the partners above and more. Create an HTTP ServerWrite TestsRead and Hash a FileStreams PipelineWork with Threads// server.mjs import { createServer } from 'node:http'; const server = createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello World!\n'); }); // starts a simple http server locally on port 3000 server.listen(3000, '127.0.0.1', () => { console.log('Listening on 127.0.0.1:3000'); }); // run with `node server.mjs`JavaScriptCopy to clipboard// tests.mjs import assert from 'node:assert'; import test from 'node:test'; test('that 1 is equal 1', () => { assert.strictEqual(1, 1); }); test('that throws as 1 is not equal 2', () => { // throws an exception because 1 != 2 assert.strictEqual(1, 2); }); // run with `node tests.mjs`JavaScriptCopy to clipboard// crypto.mjs import { createHash } from 'node:crypto'; import { readFile } from 'node:fs/promises'; const hasher = createHash('sha1'); hasher.setEncoding('hex'); // ensure you have a `package.json` file for this test! hasher.write(await readFile('package.json')); hasher.end(); const fileHash = hasher.read(); // run with `node crypto.mjs`JavaScriptCopy to clipboard// streams.mjs import { crea