Comparing version 0.1.0 to 0.2.0
@@ -39,5 +39,2 @@ var os = require('os'); | ||
} | ||
function padHex(hex, digits) { | ||
return hex.length >= digits ? hex.substring(0, digits) : this.getRandom(digits - hex.length) + hex; | ||
} | ||
@@ -50,2 +47,5 @@ var Clerobee = function Clerobee( length ) { | ||
ClerobeeProto.padHex = function(hex, digits) { | ||
return hex.length >= digits ? hex.substring(0, digits) : this.getRandom(digits - hex.length) + hex; | ||
}; | ||
ClerobeeProto.derive = function( config, masterID ) { | ||
@@ -95,3 +95,3 @@ var lengthP = config.timeLength + config.processLength + config.networkLength; | ||
var refString = this.cryptify( JSON.stringify( reference ), config.randomLength ); | ||
return this.innerGenerate.bind( self, config, function( ){ return padHex.bind(self, refString, config.randomLength )(); } )(); | ||
return this.innerGenerate.bind( self, config, function( ){ return self.padHex(refString, config.randomLength); } )(); | ||
}; | ||
@@ -124,2 +124,3 @@ ClerobeeProto.generate = function( basis, extra ) { | ||
ClerobeeProto.getRandom = function( randomLength, masterRandom, masterNano) { | ||
var self = this; | ||
randomLength = randomLength || this.config.randomLength; | ||
@@ -134,3 +135,3 @@ | ||
random += padHex( Number( parseInt(sliceR, 36) + parseInt(masterNano, 36) ).toString(36), length ); | ||
random += self.padHex( Number( parseInt(sliceR, 36) + parseInt(masterNano, 36) ).toString(36), length ); | ||
} | ||
@@ -171,5 +172,5 @@ else{ | ||
return padHex( Number( value ).toString(36), length); | ||
return this.padHex( Number( value ).toString(36), length); | ||
}; | ||
module.exports = exports = Clerobee; | ||
module.exports = exports = Clerobee; |
{ | ||
"name": "clerobee", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "A featureful dependency-free UID generator", | ||
@@ -48,3 +48,3 @@ "keywords": [ | ||
}, | ||
"_id": "clerobee@0.1.0" | ||
"_id": "clerobee@0.2.0" | ||
} |
Clerobee - a featureful UID generator | ||
[](https://nodei.co/npm/clerobee/) | ||
======== | ||
@@ -3,0 +6,0 @@ [clerobee](https://github.com/imrefazekas/clerobee) is a very handy dependency-free utility library allowing to generate UIDs considering actual time, network resources and process in a distributed environment. |
11870
187
76