Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
fs-extend
Advanced tools
Readme
npm i fs-extend -S
const fsEx = require('fs-extend')
fsEx.mkdir('./1/2/3/4/5/6/7/8/9', (err) => {
if (err) {
return console.error(err)
}
console.log('ok')
})
mkdir(path, callback)
递归建立目录mkdirSync(path)
同步递归建立目录rm(path, callback)
删除目录及子目录rmSync(path)
同步删除目录及子目录find(path, pattern, callback)
查找path
目录及子目录下匹配pattern
的文件和目录。findSync(path, pattern)
同步查找path
目录及子目录下匹配pattern
的文件和目录。listFiles(path, callback)
列出目录及子目录下所有文件listFilesSync(path)
同步列出目录及子目录所有文件empty(path, callback)
判断目录是否空目录emptySync(path)
同步判断目录是否空目录path
<string> 目录路径callback
<Function>
err
<Error>递归建立目录
fsEx.mkdir('./1/2/3/4/5/6/7/8/9', (err) => {
if (err) {
return console.error(err)
}
console.log('ok')
})
同步递归建立目录
path
<string>try {
fsEx.mkdirSync('./1/2/3/4/5/6/7/8/9')
console.log('ok')
} catch (err) {
console.error(err)
}
删除目录及子目录
path
<string> 目录路径callback
<Function>
err
<Error>fsEx.rm('./1', (err) => {
if (err) {
return console.error(err)
}
console.log('ok')
})
同步删除目录及子目录。
path
<string> 删除的目录try {
fsEx.rmSync('./1')
console.log('ok')
} catch (err) {
console.error(err)
}
查找path
目录及子目录下匹配pattern
的文件和目录。
path
<string> 查找的目录。pattern
<string> | <RegExp> 查找的模式。callback
<Function>
err
<Error>result
<string[]> 查找的结果。fsEx.find('.', '.jpg', (err, result) => {
if (err) {
return console.error(err)
}
console.log(result)
})
同步查找path
目录及子目录下匹配pattern
的文件和目录。
path
<string> 目录路径。pattern
<string> | <RegExp> 查找的模式。try {
const result = fsEx.findSync('.', '.jpg')
console.log(result)
} catch (err) {
console.error(err)
}
列出目录及子目录下所有文件。
path
<string>callback
<Function>
err
<Error>result
<string[]> 文件列表。fsEx.listFiles('.', (err, result) => {
if (err) {
return console.error(err)
}
console.log(result)
})
同步列出目录及子目录所有文件。
try {
const result = fsEx.listFilesSync('.')
console.log(result)
} catch (err) {
console.error(err)
}
判断目录是否空目录
fsEx.empty('.', (err, isEmpty) => {
if (err) {
return console.error(err)
}
console.log('isEmpty: %s', isEmpty)
})
同步判断目录是否空目录。
path
<string>try {
const isEmpty = fsEx.emptySync('.')
console.log('isEmpty: %s', isEmpty)
} catch (err) {
console.error(err)
}
FAQs
提供扩展原生fs模块不支持的功能
The npm package fs-extend receives a total of 6 weekly downloads. As such, fs-extend popularity was classified as not popular.
We found that fs-extend demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.