Giter Site home page Giter Site logo

Comments (12)

ericelliott avatar ericelliott commented on August 29, 2024

Thanks for the heads up!

Fixed in d6bd849

from cuid.

ericelliott avatar ericelliott commented on August 29, 2024

Slugs are 7 characters. =)

from cuid.

powmedia avatar powmedia commented on August 29, 2024

Having said that, one of the new slug IDs I've just seen created is 8
characters!
On Nov 11, 2014 4:37 AM, "Eric Elliott" [email protected] wrote:

Slugs are 7 characters. =)

Reply to this email directly or view it on GitHub
#16 (comment).

from cuid.

ericelliott avatar ericelliott commented on August 29, 2024

Oops. Is this causing problems? Maybe one of the entropy sources is just too short sometimes. I'd have to look at the implementation again and pad it for consistency.

from cuid.

powmedia avatar powmedia commented on August 29, 2024

It's not causing problems right now but would be good to know it was
consistent.

On Tue, Nov 11, 2014 at 12:29 PM, Eric Elliott [email protected]
wrote:

Oops. Is this causing problems? Maybe one of the entropy sources is just
too short sometimes. I'd have to look at the implementation again and pad
it for consistency.

Reply to this email directly or view it on GitHub
#16 (comment).

from cuid.

ericelliott avatar ericelliott commented on August 29, 2024

Length is not guaranteed.

from cuid.

MarkHerhold avatar MarkHerhold commented on August 29, 2024

@ericelliott Could you explain what part of the cuid slug may vary in length? I'm wondering if this would affect the alphanumeric sortability of slugs.

from cuid.

MarkHerhold avatar MarkHerhold commented on August 29, 2024

To answer my own question, the counter portion of the slug grows unboundedly, which is why there is no guarantee on length.

The 2-character date representation comes before the counter, so I'd consider the resulting records well sortable across instances when generating IDs every few milliseconds. For anyone reading this, please note that I am no statistician. :)

from cuid.

ericelliott avatar ericelliott commented on August 29, 2024

Want to submit a PR?

from cuid.

MarkHerhold avatar MarkHerhold commented on August 29, 2024

@ericelliott for what? I'm OK with the slug growing unbounded mostly because I don't have a better strategy for keeping everything short while maintaining a reasonable guarantee of uniqueness.

Or did you mean a docs update? :) I can do this tomorrow.

from cuid.

ericelliott avatar ericelliott commented on August 29, 2024

Docs would be fine. =)

from cuid.

MarkHerhold avatar MarkHerhold commented on August 29, 2024

I ran into this again and did re-investigated the code (I am running a SQL DB with fixed column lengths). It turns out that my previous conclusion that the slug grows unboundedly is incorrect. 😕

The actual max slug length is 10 characters as the counter will only ever contribute a max of 4 characters to the slug length. Therefore, slugs range for 7 - 10 chars. I'll update the README. Sorry about this!

from cuid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.