njsetn:listing_directory_files
fs module → file system
→ nodejs.org/api/fs.html
var fs = require("fs"); var files = fs.readdirSync('./lib'); // lecture synchrone : bloque le thread nodejs /* fs.readdirSync('./lib', function(error, files) { // callback if (error) { throw error; } console.log(files); }); // lecture asynchrone console.log("reading files"); */ console.log(files);
Toutes les commande du module fs ont une version synchrone et asynchrone.
njsetn/listing_directory_files.txt · Last modified: 2016/03/23 21:19 by leo