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 = require('uuid-js');
var uuid4 = UUID.create();
console.log(uuid4.toString());
var uuid1 = UUID.create(1);
console.log(uuid1.toString());
var date = new Date().getTime();
var uuidFirst = UUID.fromTime(date, false);
var uuidLast = UUID.fromTime(date, true);
console.log(uuidFirst.toString(), uuidLast.toString());
var today = new Date().getTime();
var last30days = (new Date().setDate( today.getDate() - 30 )).getTime();
var rangeStart = UUID.firstFromTime(last30days);
var rangeEnd = UUID.lastFromTime(today);
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.create(4);
UUID.create(1);
UUID.fromTime(time, last);
UUID.firstFromTime(time);
UUID.lastFromTime(time);
UUID.fromURN(strId);
UUID.fromBytes(ints);
UUID.fromBinary(binary);
Methods List
These must be called on an instance of the UUID object:
uuid.fromParts(timeLow, timeMid, timeHiAndVersion, clockSeqHiAndReserved, clockSeqLow, node);
uuid.toString();
uuid.toURN();
uuid.toBytes();
Tests
make test
Contributors
This work was based RFC and by the work of these people.