-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Add counter for multiple occurences #46
Conversation
The counter cannot be global. It needs to create a new instance. |
Not sure I understand, the current implementation is used like so const countableSlugify = slugify.counter();
t.is(countableSlugify('foo bar'), 'foo-bar'); |
https://github.com/sindresorhus/slugify/pull/46/files#diff-168726dbe96b3ce427e7fedce31bb0bcR71 is global. If |
You're right 😅 |
Yes, perfect. That's exactly what I had in mind. |
Can you add docs (readme + TypeScript file)? And also mention some use-cases in the docs. |
I updated everything as good as I could. |
Should the countableSlugify(""); // => ""
countableSlugify(""); // => "-2" or should it always return |
This. Add tests for that. |
Make sure |
Thanks for the reminder, I only ran |
Looks great now. Thanks for working on this 👍 |
Thanks a lot for your patience & guidance @sindresorhus very much appreciated 🙏 |
Closes #37
That's actually what I already made for @gaiama/slugger
only issue so far is, it's not doing the by you preferred
-2-2
😢and I'm currently not sure how to properly do it without a rewrite.
I'm open to other implementations or preferences.
index.d.ts
is probably not correct? Still very new to TS and external declarations.Also I'm not sure if the used regex
/(?:-\d+?)+?$/
is ReDoS safe or how much that matters here 🤷♂