Attempt to make the customAlphabet API more similar to nanoid #348
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I want to use a custom alphabet, but I find that going from
nanoid(size)
tonanoid = customAlphabet(alphabet, size)
is a bit cumbersome.Wouldn't it be better if the function returned by
customAlphabet
behaved exactly likenanoid
? That way I could just change hownanoid
is defined and the rest of my code would continue to work, since there arenanoid
calls that generate IDs of different lengths scattered throughout the code.So instead of:
nanoid/non-secure/index.js
Lines 10 to 11 in 7528a73
It would use:
Just like the usual
nanoid
function. But since that would be a breaking change, perhaps this change would be easier to introduce?So I started making the change, but I was unsure how to change all of the files. So I figured I'll just ask here, especially since there seems to be an extreme amount of attention paid to the resulting size of the function. 馃し
Thanks!