@@ -4,133 +4,134 @@ layout: home
4
4
---
5
5
6
6
<section >
7
- <WithBadge section = " index" />
8
-
9
- <div >
10
- <h1 className = " special" >Exécuter du JavaScript partout</h1 >
11
-
12
- Node.js® est un environnement d'exécution JavaScript gratuit,
13
- open-source et multiplateforme qui permet aux développeurs de créer des serveurs,
14
- des applications web et des applications de gestion de contenu. qui permet
15
- aux développeurs de créer des serveurs, des applications web, des outils en
16
- ligne de commande et des scripts.
17
-
18
- </div >
19
-
20
- <div >
21
- <WithNodeRelease status = { [' LTS' ]} >
22
- { ({ release }) => (
23
- <>
24
- <DownloadButton release = { release } >Télécharger Node.js (LTS)</DownloadButton >
25
- <small >
26
- Télécharger Node.js <b >{ release .versionWithPrefix } </b >
27
- <sup title = " Downloads a Node.js installer for your current platform" >1</sup > avec un support à long terme.
28
- Node.js peut également être installé via <Link href = " /download/package-manager" >gestionnaires de paquets</Link >.
29
- </small >
30
- </>
31
- )}
32
- </WithNodeRelease >
7
+ <WithBadge section = " index" />
8
+
9
+ <div >
10
+ <h1 className = " special" >Exécuter du JavaScript partout</h1 >
11
+
12
+ Node.js® est un environnement d'exécution JavaScript gratuit, open-source et multiplateforme qui permet aux développeurs de créer des serveurs, des applications web, des outils en ligne de commande et des scripts.
13
+
14
+ </div >
33
15
34
- <WithNodeRelease status = { [' Current' ]} >
35
- { ({ release }) => (
16
+ <div >
17
+ <WithNodeRelease status = { [' LTS' ]} >
18
+ { ({ release }) => (
19
+ <>
20
+ <DownloadButton release = { release } >Télécharger Node.js (LTS)</DownloadButton >
36
21
<small >
37
- Vous voulez de nouvelles fonctionnalités plus tôt ?
38
- Obtenez < b > Node.js < DownloadLink release = { release } > { release . versionWithPrefix } </ DownloadLink ></ b >
39
- < sup title = " Downloads a Node.js installer for your current platform " >1</ sup > à la place .
22
+ Télécharger Node.js < b > { release . versionWithPrefix } </ b >
23
+ < sup title = " Downloads a Node.js installer for your current platform " >1</ sup > avec un support à long terme.
24
+ Node.js peut également être installé via < Link href = " /download/package-manager " >gestionnaires de paquets</ Link > .
40
25
</small >
41
- )}
42
- </WithNodeRelease >
43
-
44
- </div >
26
+ </>
27
+ )}
28
+ </WithNodeRelease >
29
+
30
+ <WithNodeRelease status = { [' Current' ]} >
31
+ { ({ release }) => (
32
+ <small >
33
+ Vous voulez de nouvelles fonctionnalités plus tôt ?
34
+ Obtenez <b >Node.js <DownloadLink release = { release } >{ release .versionWithPrefix } </DownloadLink ></b >
35
+ <sup title = " Downloads a Node.js installer for your current platform" >1</sup > à la place.
36
+ </small >
37
+ )}
38
+ </WithNodeRelease >
39
+ </div >
45
40
</section >
46
41
47
42
<section >
48
- <div >
49
- ``` js displayName="Create an HTTP Server"
50
- // server.mjs
51
- import { createServer } from ' node:http' ;
52
-
53
- const server = createServer ((req , res ) => {
54
- res .writeHead (200 , { ' Content-Type' : ' text/plain' });
55
- res .end (' Hello World!\n ' );
56
- });
57
-
58
- // starts a simple http server locally on port 3000
59
- server .listen (3000 , ' 127.0.0.1' , () => {
60
- console .log (' Listening on 127.0.0.1:3000' );
61
- });
62
-
63
- // run with `node server.mjs`
64
- ```
65
-
66
- ``` js displayName="Write Tests"
67
- // tests.mjs
68
- import assert from ' node:assert' ;
69
- import test from ' node:test' ;
70
-
71
- test (' that 1 is equal 1' , () => {
72
- assert .strictEqual (1 , 1 );
73
- });
74
-
75
- test (' that throws as 1 is not equal 2' , () => {
76
- // throws an exception because 1 != 2
77
- assert .strictEqual (1 , 2 );
78
- });
79
-
80
- // run with `node tests.mjs`
81
- ```
82
-
83
- ``` js displayName="Read and Hash a File"
84
- // crypto.mjs
85
- import { createHash } from ' node:crypto' ;
86
- import { readFile } from ' node:fs/promises' ;
87
-
88
- const hasher = createHash (' sha1' );
89
-
90
- hasher .setEncoding (' hex' );
91
- // ensure you have a `package.json` file for this test!
92
- hasher .write (await readFile (' package.json' ));
93
- hasher .end ();
94
-
95
- const fileHash = hasher .read ();
96
-
97
- // run with `node crypto.mjs`
98
- ```
99
-
100
- ``` js displayName="Streams Pipeline"
101
- // streams.mjs
102
- import { pipeline } from ' node:stream/promises' ;
103
- import { createReadStream , createWriteStream } from ' node:fs' ;
104
- import { createGzip } from ' node:zlib' ;
105
-
106
- // ensure you have a `package.json` file for this test!
107
- await pipeline
108
- (
109
- createReadStream (' package.json' ),
110
- createGzip (),
111
- createWriteStream (' package.json.gz' )
112
- );
113
-
114
- // run with `node streams.mjs`
115
- ```
116
-
117
- ``` js displayName="Work with Threads"
118
- // threads.mjs
119
- import { Worker , isMainThread ,
120
- workerData , parentPort } from ' node:worker_threads' ;
121
-
122
- if (isMainThread) {
123
- const data = ' some data' ;
124
- const worker = new Worker (import .meta.filename, { workerData : data });
125
- worker .on (' message' , msg => console .log (' Reply from Thread:' , msg));
126
- } else {
127
- const source = workerData;
128
- parentPort .postMessage (btoa (source .toUpperCase ()));
129
- }
130
-
131
- // run with `node threads.mjs`
132
- ` ` `
133
-
134
- </div>
135
- Apprenez-en plus sur ce que Node.js est capable d'offrir avec notre [Matériel d'apprentissage](/learn).
43
+ <div >
44
+ ``` js displayName="Create an HTTP Server"
45
+ // server.mjs
46
+ import { createServer } from ' node:http' ;
47
+
48
+ const server = createServer ((req , res ) => {
49
+ res .writeHead (200 , { ' Content-Type' : ' text/plain' });
50
+ res .end (' Hello World!\n ' );
51
+ });
52
+
53
+ // starts a simple http server locally on port 3000
54
+ server .listen (3000 , ' 127.0.0.1' , () => {
55
+ console .log (' Listening on 127.0.0.1:3000' );
56
+ });
57
+
58
+ // run with `node server.mjs`
59
+
60
+ ````
61
+
62
+ ` ` ` js displayName="Write Tests"
63
+ // tests.mjs
64
+ import assert from 'node:assert';
65
+ import test from 'node:test';
66
+
67
+ test('that 1 is equal 1', () => {
68
+ assert.strictEqual(1, 1);
69
+ });
70
+
71
+ test('that throws as 1 is not equal 2', () => {
72
+ // throws an exception because 1 != 2
73
+ assert.strictEqual(1, 2);
74
+ });
75
+
76
+ // run with ` node tests .mjs `
77
+ ` ` ` `
78
+
79
+ ` ` ` js displayName= " Read and Hash a File"
80
+ // crypto.mjs
81
+ import { createHash } from ' node:crypto' ;
82
+ import { readFile } from ' node:fs/promises' ;
83
+
84
+ const hasher = createHash (' sha1' );
85
+
86
+ hasher .setEncoding (' hex' );
87
+ // ensure you have a `package.json` file for this test!
88
+ hasher .write (await readFile (' package.json' ));
89
+ hasher .end ();
90
+
91
+ const fileHash = hasher .read ();
92
+
93
+ // run with `node crypto.mjs`
94
+ ```
95
+
96
+ ``` js displayName="Streams Pipeline"
97
+ // streams.mjs
98
+ import { pipeline } from ' node:stream/promises' ;
99
+ import { createReadStream , createWriteStream } from ' node:fs' ;
100
+ import { createGzip } from ' node:zlib' ;
101
+
102
+ // ensure you have a `package.json` file for this test!
103
+ await pipeline (
104
+ createReadStream (' package.json' ),
105
+ createGzip (),
106
+ createWriteStream (' package.json.gz' )
107
+ );
108
+
109
+ // run with `node streams.mjs`
110
+ ```
111
+
112
+ ``` js displayName="Work with Threads"
113
+ // threads.mjs
114
+ import {
115
+ Worker ,
116
+ isMainThread ,
117
+ workerData ,
118
+ parentPort ,
119
+ } from ' node:worker_threads' ;
120
+
121
+ if (isMainThread) {
122
+ const data = ' some data' ;
123
+ const worker = new Worker (import .meta.filename, { workerData : data });
124
+ worker .on (' message' , msg => console .log (' Reply from Thread:' , msg));
125
+ } else {
126
+ const source = workerData;
127
+ parentPort .postMessage (btoa (source .toUpperCase ()));
128
+ }
129
+
130
+ // run with `node threads.mjs`
131
+ ` ` `
132
+
133
+ </div>
134
+
135
+ Apprenez-en plus sur ce que Node.js est capable d'offrir avec notre [Matériel d'apprentissage](/learn).
136
+
136
137
</section>
0 commit comments