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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request : allow an optional constructor to build the result #25

Open
zipang opened this issue Jul 2, 2018 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@zipang
Copy link

zipang commented Jul 2, 2018

It would be awesome to allow an optional constructor in the options, to return whatever types the user really needs, ie : an array of vfile instead of an array of paths.

Example :

const glob = require('tiny-glob')
const vfile = require('to-vfile')

let files = glob('*.md', {mount: vfile})
@terkelg
Copy link
Owner

terkelg commented Jul 8, 2018

I would like to keep tiny glob as simple as possible. What would a implementation for this look like and what are the benefits? It's easy to map the returned array to get basename, extension etc.

@zipang
Copy link
Author

zipang commented Jul 11, 2018

Hi @terkelg !
I do agree that mapping on the returned array is pretty easy in term of coding, but i did believe that your package's implementation was all about performances !?

To load a vfile, i need the full path of a file.
So right now, the implementation is allready doing a full re-map on the matched elements just to return their absolute path.
So mapping again on all the matched elements returned by glob to convert them to vfile.. and it would be 2 unnecessary loops involved.

I can submit a PR if you are interested..

@terkelg
Copy link
Owner

terkelg commented Jul 11, 2018

I would love to see some code, but I can't promise I'll merge it into master. All PRs are very welcome.
Can you do it without introducing dependencies?

zipang added a commit to zipang/tiny-glob that referenced this issue Jul 12, 2018
@terkelg terkelg added the enhancement New feature or request label Aug 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants