Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
directory-tree-promise
Advanced tools
npm install directory-tree-promise
Use async await while traversing a directory tree.
const directoryTree = require('directory-tree-promise')
const tree = await directoryTree('./example')
Output of tree
:
{
"path": "./example",
"name": "example",
"children": [
{
"path": "example/subfolder",
"name": "subfolder",
"children": [
// excluded
],
"size": 22
},
{
// excluded
}
],
"size": 34
}
You can also pass an async function as a second parameter to modify the object returned for files
const directoryTree = require('directory-tree-promise')
const tree = await directoryTree('./example', async file => {
file.content = await someFunctionToReadFileData(file.path)
return file
})
Items are returned with the following properties:
Each object in the tree is extended with a property isFile
const directoryTree = require('directory-tree-promise')
const tree = await directoryTree(process.cwd())
tree.children[0].isFile // true or false
Device, FIFO and socket files are ignored.
Fork this repository and run npm install
in project directory. Before versioning and publishing, run npm dist
to transcompile for Node 6 support.
npm run test
FAQs
Asynchronously return a directory tree as a JS object
The npm package directory-tree-promise receives a total of 4 weekly downloads. As such, directory-tree-promise popularity was classified as not popular.
We found that directory-tree-promise 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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.