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

Switch all functions to run synchronously #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ridafkih
Copy link

@ridafkih ridafkih commented Apr 19, 2023

Removes all asynchronous functionality from the library.

Feel free to not merge, if it's not something you want to implement. I'm sure you had your reasons for going fully asynchronous (performance?). For myself, I'm setting up a custom integration with your (great) library which integrates directly into my app.config.ts, but this library doesn't play well because the configuration cannot return a promise, and cannot resolve as a module (meaning no top-level asynchronous functionality).

I'll re-release this under my own namespace for personal use, and switch it over if you decide to merge this in. c:

Note, this would constitute a major version bump.

@ridafkih
Copy link
Author

ridafkih commented Apr 19, 2023

No dice, the performance just wasn't going to cut it for my implementation, asynchronous is really required for this library with the current implementation. I was unable to reliably hash with a compiled package made from this PRs code, it would sometimes take minutes at a time. I did go ahead and make my own spin on a native dependency hashing library. On a relatively fresh Expo project, I'm able to get ~3.5K files hashed into an MD5 hash in about 460ms.

CleanShot 2023-04-19 at 13 17 33

The repository can be found at ridafkih/dephash, and it's on NPM @ dephash

It uses glob to check for a series of patterns, puts those all in a list, instantiates a single hash, iterates over it and gets the Buffer that represents the contents each matched file, updates the hash iteratively, and then digests it once all files have been included. By employing some of that here, we could likely improve the performance tremendously.

@robertherber
Copy link
Member

@ridafkih Looks nice with a faster file processing approach, would you like to open a PR on this? :) Is it also taking into account whether the files are gitignored or not?

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.

2 participants