0.0.1 • Published 9 years ago

llguid v0.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
9 years ago

nodejs-llGuid

This is used in nodejs generated Guid by random.

This module checked your system, support on Windows, Linux, Mac OS X platform

How to use it

##Installation You can install with npm:

$ npm install llguid

i'm publish in npm unsuccessfully, please download and unzip this package and change folder name with llguid. Finally, put this folder into your project's node_modules

##Get a Guid object from nodejs

var llGuid = require('llguid');
var myGuid = llGuid.newGuid(); // -> Create new Guid
console.log(myGuid.toString()); // -> The console print like this "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

Methods

The Constructors

    var emptyGuid = new llGuid(); // -> Create a empty Guid like `llGuid.empty()`;
    var myGuid = new llGuid('A4F1A501-D421-4621-BB51-DE7E8857BA09'); //Create a known Guid from String

Object methods

    var myGuid1 = llGuid.newGuid(); // -> Create a new Guid
    var myGuid2 = llGuid.newGuid(); // -> Create a new Guid again
    myGuid1.equals(myGuid2); // -> Check of these two Guid object are equal
    var bytes = myGuid1.toArray(); // -> get a byte array from this `myGuid1`, length of 16, like this `[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]`
    var guidStr = myGuid2.toString(); // -> get a Guid string from this `myGuid2`, length of 36, like this '00000000-0000-0000-0000-000000000000'

Static methods

    var emptyGuid = llGuid.empty(); // -> Create a empty Guid, like this '00000000-0000-0000-0000-000000000000'
    var myGuid = llGuid.parse('A4F1A501-D421-4621-BB51-DE7E8857BA09'); // -> Transform a Guid object from guid string, like `new Guid('guid string')`
    var isGuid = llGuid.isGuid('A4F1A501-D421-4621-BB51-DE7E8857BA09'); // -> Check a `string` or a `llGuid` object is Guid or another?
    var isEqueal = llGuid.equals(emptyGuid, myGuid); //Check `emptyGuid` and `myGuid` is equal;
        //remark: llGuid.equals method`s two parameters must be llGuid`s object, another return false