Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added depth option #70

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Added depth option #70

wants to merge 4 commits into from

Conversation

dvergeylen
Copy link

@dvergeylen dvergeylen commented Aug 26, 2019

Minimal code change, optional depth option, new test and updated README.md 馃檪

Fix #34

.filter(e => !!e);
item.size = item.children.reduce((prev, cur) => prev + cur.size, 0);
const opts = (options && (options.depth >= 0))
? { ...options, depth: Number(options.depth) - 1 }
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spread operator is only available from Node 8.3, tests are failing because of this 馃槥

@mihneadb
Copy link
Owner

Hi, thanks for the PR!

I suggest you extract the code in a new directoryTreeWithDepth function that takes an extra depth parameter which is still Number? and decrement that as a primitive value. This I think makes things easier to follow (the depth recursion pattern is pretty familiar to people I think) and you also get around the issue of copying the settings object every time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add depth option
2 participants