本文整理汇总了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;
});
});