UUID-js
A js library to generate and parse UUID's, TimeUUID's and generate empty TimeUUID's based on TimeStamp for range selections.
var UUID = ; // Generate a V4 UUIDvar uuid4 = UUID;console;// Prints: 896b677f-fb14-11e0-b14d-d11ca798dbac // Generate a V1 TimeUUIDvar uuid1 = UUID;console; // First and last possible v1 TimeUUID for a given timestamp:var date = ;var uuidFirst = UUID;var uuidLast = UUID;console;// Prints: aa0f9af0-0e1f-11e1-0000-000000000000 aa0f9af0-0e1f-11e1-c0ff-ffffffffffff // Use these TimeUUID's to perform range queries in cassandra:var today = ;var last30days = ; var rangeStart = UUID;var rangeEnd = UUID; var query = ..."select first 50 reversed ?..? from user_twits where key=?" rangeStart rangeEnd "patricknegri" ;
Instalation
$ npm install uuid-js
Functions List
These are available just with require and return an instance of the UUID object:
UUID; // Generate V4 UUID UUID; // Generate V1 TimeUUID UUID; // Generate a V1 empty TimeUUID from a Date object (Ex: new Date().getTime() ) UUID; // Same as fromTime but first sequence UUID; // Same as fromTime but last sequence UUID; // Generate a UUID object from string UUID; // Generate a UUID object from bytes UUID; // Generate a UUID object from binary
Methods List
These must be called on an instance of the UUID object:
uuid; uuid; // hex string version of UUID uuid; // same as hex, but with urn:uuid prefix uuid; // converted to an array of bytes
Tests
make test
Contributors
- Christoph Tavan dev@tavan.de
This work was based RFC and by the work of these people.
- LiosK contact@mail.liosk.net
- Gary Dusbabek gdusbabek@gmail.com