Giter Site home page Giter Site logo

hscuid's Introduction

hscuid

Build Status Hackage

A Haskell port of the JavaScript library for collision-resistant identifiers. To install, cabal install hscuid.

What is a CUID?

CUIDs are short random strings designed so that you can generate a lot of them over many different machines and not get collisions. They are intended to be usable in situations from HTML element IDs to database keys. You can read more about them at usecuid.org.

How do I use this library?

>>> import Web.Cuid (newCuid, newSlug)
>>> newCuid
"cib3c3tcu0000zwowx9ho2gh4"
>>> newSlug
"y900001wmf"

Developing

I am currently developing with stack. To install dependencies and compile the library and test suites:

stack build

To run the collision test suite (which generates 1.2M IDs and makes sure they're all unique):

stack test

To test performance with criterion:

stack exec perf-test -- --regress allocated:iters +RTS -T

hscuid's People

Contributors

bdesham avatar bergmark avatar crabmusket avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

hscuid's Issues

Add a client-side implementation

Looks like one can do GHCJS conditional compilation like so. And so.

luite but keep in mind that ghcjs is considered a flavor of ghc by cabal
so impl(ghc) is still true when compiling with ghcjs
you can do tests like if impl(ghc >= 7.2) && impl(ghcjs >= 0.1) to test for ghcjs version 0.1 or higher built against ghc 7.2 or higher

Performance

Currently best-case performance in the 1.2M benchmark is ~9x slower than the Go port. Not sure how much of that is CUID generation and how much is Data.Set, but it would be good to get that number down. Obvious candidate is formatting. AFAICT some of the code inside formatting goes though String at times, so that might want replacing with bespoke functions.

Cuid standard is deprecated.

Due to security concerns (which also exist in database auto-increment ids, uuid/guid, and most other id standrads), the Cuid standard is now deprecated in favor of Cuid2.

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.