From 70a766d0c5969689e4616743420d0bec6c20389b Mon Sep 17 00:00:00 2001 From: "Node.js Crowdin Bot" <148437438+nodejs-crowdin@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:59:03 +0200 Subject: [PATCH] chore: synced translations from crowdin [skip ci] --- apps/site/pages/id/index.mdx | 169 +++++++++++++++++------------------ 1 file changed, 81 insertions(+), 88 deletions(-) diff --git a/apps/site/pages/id/index.mdx b/apps/site/pages/id/index.mdx index b7ca646a0b6ab..9da20d625dc3d 100644 --- a/apps/site/pages/id/index.mdx +++ b/apps/site/pages/id/index.mdx @@ -9,8 +9,7 @@ layout: home

Jalankan JavaScript Di Mana Saja

-Node.js® adalah lingkungan runtime JavaScript gratis dan sumber terbuka yang lintas platform, yang memungkinkan pengembang membuat server, aplikasi web, alat baris perintah, dan skrip. - + Node.js® adalah lingkungan runtime JavaScript gratis dan sumber terbuka yang lintas platform, yang memungkinkan pengembang membuat server, aplikasi web, alat baris perintah, dan skrip.
@@ -45,93 +44,87 @@ Node.js® adalah lingkungan runtime JavaScript gratis dan sumber terbuka yang li // 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` - -```` - -```js displayName="Write Tests" -// 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` -```` - -```js displayName="Read and Hash a File" -// 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` -``` - -```js displayName="Streams Pipeline" -// streams.mjs -import { pipeline } from 'node:stream/promises'; -import { createReadStream, createWriteStream } from 'node:fs'; -import { createGzip } from 'node:zlib'; - -// ensure you have a `package.json` file for this test! -await pipeline( - createReadStream('package.json'), - createGzip(), - createWriteStream('package.json.gz') -); - -// run with `node streams.mjs` -``` - -```js displayName="Work with Threads" -// threads.mjs -import { - Worker, - isMainThread, - workerData, - parentPort, -} from 'node:worker_threads'; - -if (isMainThread) { - const data = 'some data'; - const worker = new Worker(import.meta.filename, { workerData: data }); - worker.on('message', msg => console.log('Reply from Thread:', msg)); -} else { - const source = workerData; - parentPort.postMessage(btoa(source.toUpperCase())); -} - -// run with `node threads.mjs` -``` - + 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` + ``` + + ```js displayName="Write Tests" + // 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` + ``` + + ```js displayName="Read and Hash a File" + // 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` + ``` + + ```js displayName="Streams Pipeline" + // streams.mjs + import { pipeline } from 'node:stream/promises'; + import { createReadStream, createWriteStream } from 'node:fs'; + import { createGzip } from 'node:zlib'; + + // ensure you have a `package.json` file for this test! + await pipeline + ( + createReadStream('package.json'), + createGzip(), + createWriteStream('package.json.gz') + ); + + // run with `node streams.mjs` + ``` + + ```js displayName="Work with Threads" + // threads.mjs + import { Worker, isMainThread, + workerData, parentPort } from 'node:worker_threads'; + + if (isMainThread) { + const data = 'some data'; + const worker = new Worker(import.meta.filename, { workerData: data }); + worker.on('message', msg => console.log('Reply from Thread:', msg)); + } else { + const source = workerData; + parentPort.postMessage(btoa(source.toUpperCase())); + } + + // run with `node threads.mjs` + ```
Pelajari lebih lanjut tentang apa yang bisa ditawarkan Node.js melalui [Bahan Pembelajaran](/learn) kami. -