本文整理匯總了TypeScript中node-dir.files函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript files函數的具體用法?TypeScript files怎麽用?TypeScript files使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了files函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: Promise
return new Promise((resolve, reject) => {
dir.files(process.cwd(), (err, files) => {
if(err) {
reject(err);
} else {
resolve(applyFilter(files, filter));
}
});
});
示例2:
const hostRule = (ruleName, subdir, subdirS) => {
dir.files(subdir, (err, files) => {
if (err) {
throw err;
}
let relativeDir = '/gamerules/';
for (let i = 2; i < subdirS.length; i = i + 1) {
relativeDir += subdirS[i] + '/';
}
files.forEach((file) => {
const fileS = file.split(/[\/\\]/);
const route = relativeDir + fileS[fileS.length - 1];
console.log('Setting route ' + route + ' => ' + file);
app.get(route, (req, res) => {
res.sendFile(file);
});
});
});
}
示例3: next
next();
},
function(err, files){
console.log('finished reading files:',files);
});
// the callback for each file can optionally have a filename argument as its 3rd parameter
// and the finishedCallback argument is optional, e.g.
dir.readFiles("./", function(err: any, content: any, filename: string, next: any) {
console.log('processing content of file', filename);
next();
});
dir.files("./", function(err, files) {
console.log(files);
});
dir.files("./", function(err, files) {
// sort descending
files.reverse();
// include only certain filenames
files = files.filter(function(file: any) {
return ['allowed', 'file', 'names'].indexOf(file) > -1;
});
// exclude some filenames
files = files.filter(function(file: any) {
return ['exclude', 'these', 'files'].indexOf(file) === -1;
});
});