Closed
Description
Since the initial library has been out for a few weeks, I got to mess around with it a bit more and realized there are a few rough edges we could iron out:
- Lower reserved characters count from 3 to 1 (more data packing into generated IDs)
- As a side-effect of number one, min alphabet length can decrease from 5 to 3
- Decrease blocklist-related re-generation attempts from almost-unlimited to the length of the alphabet (cc @tzvetkoff)
- As a result of number three, re-generated IDs don't have to grow in length (try blocking "SrIu" in the playground to see what I'm talking about)
- Also as a result of number three, min length padding is smoother now (cc @joviczarko)
- Sounds like
minValue
andmaxValue
are not that useful, let's remove? (cc @peterhellberg) - Increase min length limit from alphabet-length to an arbitrary value (1_000 for example)
Pros:
- Less code; spec (with comments, etc) went from 336 to 301
- Limited (but still sufficient it seems) number of re-generation attempts, as opposed to currently almost-unlimited / less-predictable
- Smoother blocklist and min length handling
- Packing more data into IDs + smaller alphabet allowed
Cons:
- More dev work for maintainers to re-adjust code (you + me)
- IDs change, which means users that might have current libs in production would have breaking prod changes (although most of our libs are pre-production version (v0.x) ...so comes with the territory)
Unknowns:
- Are there any use-cases we don't test for since changing reserved chars from 3 to 1?
Current: https://sqids.org/playground (algorithm code / explanation)
Proposed: https://sqids.org/playground/simpler (algorithm code / explanation)
P.S: Also worth noting that I have no intention of changing the algorithm over and over; I figured this might be cleaner + address some current issues/questions, while we're still technically mostly pre-prod.
Thoughts/feedback?
Metadata
Metadata
Assignees
Labels
No labels