-
Notifications
You must be signed in to change notification settings - Fork 113
Permalink
Choose a base ref
{{ refName }}
default
Choose a head ref
{{ refName }}
default
Comparing changes
Choose two branches to see what’s changed or to start a new pull request.
If you need to, you can also or
learn more about diff comparisons.
Open a pull request
Create a new pull request by comparing changes across two branches. If you need to, you can also .
Learn more about diff comparisons here.
base repository: ulid/javascript
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.0.0
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}
default
Loading
...
head repository: ulid/javascript
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.0.1
Could not load branches
Nothing to show
Loading
Could not load tags
Nothing to show
{{ refName }}
default
Loading
- 6 commits
- 3 files changed
- 3 contributors
Commits on Apr 2, 2025
-
Hi @j0pgrm, re #81 Your `if` statement is there to cover the possbility that your PRNG will generate the number 1. In general, PRNGs produce values from 0 to _less than_ 1, i.e. from the range 0 (inclusive) to 1 (exclusive). This is because when they generate an N-bit binary fraction, the highest value (all `1`s) will be just a tiny bit smaller than 1. Your `Math.floor` correctly rounds downward, so that `rand` will be in the range 0 (inclusive) to ENCODING_LEN *- 1* (inclusive). So the `if` will never be triggered. If, for some reason, you in future switch to a prng that somehow can generate a 1, for example because it has an idiosyncratic desire to cover a range of 0 (_exclusive_) to 1 (_inclusive_), then: * the chance of this is extremely small (1 in 2**N, not 1 in 2**8) * the PRNG will have lost the ability to generate 0 * your random character generator would have a micrscopically smaller chance of generating the first encoding character, and have a microscopic chance of trying to pick the non-existent character at #ENCODING_LEN. A neat solution for you is to simply wrap round that exactly-1 PRNG value back to 0, most conveniently A simple way to achieve this is to modulo the `rand` by ENCODING_LEN. Thank you for an excellent library.
Configuration menu - View commit details
-
Copy full SHA for d44c3d9 - Browse repository at this point
Copy the full SHA d44c3d9View commit details
Commits on Jun 8, 2025
-
Configuration menu - View commit details
-
Copy full SHA for 5c14ac9 - Browse repository at this point
Copy the full SHA 5c14ac9View commit details -
Merge pull request #120 from darrelfrancis/master
Resolve #81 to deal with a potential future scenario of PRNG generating `1`
Configuration menu - View commit details
-
Copy full SHA for 63784e2 - Browse repository at this point
Copy the full SHA 63784e2View commit details -
Configuration menu - View commit details
-
Copy full SHA for b17312d - Browse repository at this point
Copy the full SHA b17312dView commit details -
Configuration menu - View commit details
-
Copy full SHA for fe3953d - Browse repository at this point
Copy the full SHA fe3953dView commit details -
Configuration menu - View commit details
-
Copy full SHA for ab232d7 - Browse repository at this point
Copy the full SHA ab232d7View commit details
Loading
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff v3.0.0...v3.0.1