
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
fs package extension function
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 5 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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.