Guid0: JavaScript GUIDs

View original post found on Ajaxian » Front Page authored by Dion Almaer

Our own Michael Mahemoff is at it again, creating a simple little GUID generator called Guid0:

Guid0 is a GUID library for Javascript. Okay, it doesn’t yet do official, bona fide, 128-bit, GUIDs yet, mainly for API design reasons. But this is a library you might find useful if you want to generate a unique ID in your Ajax app.

JAVASCRIPT:

  1.  
  2. // simple
  3. guid = new Guid();
  4. var newguid = guid.generate();
  5.  
  6. // options
  7. guid = new Guid(
  8.   {
  9.         chars: Guid.constants.base85// or you could say "abc" if you only wanted those chars to appear
  10.         epoch: “June 1, 2003″,
  11.         counterSequenceLength: 2, // a counter field appended to the end
  12.         randomSequenceLength: 2 // a random field appended to the end
  13.   }
  14. );
  15.  

He is working on 128-bit support.

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment