-
-
Notifications
You must be signed in to change notification settings - Fork 794
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
Much faster implementation #466
Conversation
Much faster now
|
Tested on latest version: Chrome
Safari
Firefox
Browser support doesn't change at all. |
I now updated the right place. |
Ok i will fix everything you mentioned. Maybe I should remove the comment instead since it not important |
OK, let's keep string as is. I will do some optimizations later for smaller bundle size. |
Done. Package size limit has exceeded by 34 B |
Try to import alphabet from https://github.com/ai/nanoid/blob/main/url-alphabet/index.js We have a fun hack there, we put the same letters not in alhabetical order, but in order for better gzip. And please update |
Made the changes |
I also reduced 8 bytes by reusing |
Using the while loop is actually a little bit faster. |
I know this is a lazy PR since I didn't check other files to make sure I'm making the correct changes, so I'm sorry about that.
This implementation is much faster.
The benchmark checks the time to generate one million nanoids.
I hope you find it useful 🙏