-
-
Notifications
You must be signed in to change notification settings - Fork 788
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
Option to change defaults? #99
Comments
I understand you. But we can't suggest global settings API. What if your dependency use Nano ID too and new settings will create conflict there? But there is more simple solution: // random.js
import nanoid from 'nanoid'
module exports function random () {
return nanoid(alphabet, size)
}
// main.js
import random from './random' |
I do understand that work around, but I don't like that I need to have relative imports throughout my code. The suggestion to set I do understand that you're hesitant to implement this. But I also think that library authors should be aware that they shouldn't change the defaults, and that anyone changing the defaults, should be aware that it can have side effects. |
I like how optimistic you are about users 😄. Unfortunately, I know by my practice with Developers do not read docs. Developers prefer to save few bytes instead of protecting system from long term problems. How even you can be sure, that your dependency well not change defaults and broke your code? 😏
Sure. Can you tell me what alphabet, what size and why do you use them? Maybe I can find better solution. |
Developers should be the better kind of users 😇 But unfortunately, I must agree. Point taken. Sure; all info is in the opening post; but here again: const ALPHABET = '23456789ABCDEFGHJKLMNPQRSTWXYZabcdefghijkmnopqrstuvwxyz';
const LENGTH = 17; Why? So that I can replace
A little more on the "why": Meteor style import definitions suck, as it's not easy testable. I try to lessen my dependencies on the framework, and move more to Meteor as a build tool. Thereby, depending on In the long term, when I would leave Meteor entirely, I still want to have the database ids to look the same. Currently So perhaps a |
I have a better plan. Send this alphabet to nanoid-dictionary as Then you can use it as it. Or ask import unmistakable from 'nanoid-dictionary/unmistakable'
unmistakable(17) |
I added issues there: |
Hope that solves your issue: https://github.com/CyberAP/nanoid-generate#nolookalikes |
I know there is a
generate
method, to change thealphabet
andlength
of the id that will be generated.The case is; I need to migrate my id generation away from
Meteor/Random
, while I also don't want my id's to start look different.I can achieve this with:
But, that means that I need to specify this alphabet and length on every place where I need an ID.
It would be nice if there was a method to change the defaults so that the next
require('nanoid')()
uses custom settings.The text was updated successfully, but these errors were encountered: