Posts

Showing posts from June, 2012

Pseudo-Random UUID Generation with mask support

There are a lot of cases where we may want to generate a pseudo- random universally unique identifier ( UUID ) , sometimes called GUID . I previously wrote an article on creating Pseudo Random numbers in JavaScript, which generates a uuid of length X where x is a numeric value supplied. http://pragmatic-coding.blogspot.com/2012/01/javascript-pseudo-random-id-generator.html The problem with the above generator is that is does not allow developers the flexibility of specifying the format of the uuid as shown below: 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxx0' 'xxxx-xxxx-xxxx-4xxx-yxxx-xxxxxxxxxxx' 'xxxxxxxx-xxxx-xxxx-yxxx-xxxxx-xxxxxx' Above I’ve shown you 3 different uuid formats that 3 different developers wanted, so an algorithm had to be devised that allow developers the flexibility of changing the data formats. One other thing to note about the above is the x values, which represents the values you want to be randomly generated. All o

JavaScript Module Pattern: 2 Forms

JavaScript Module Pattern: 2 Forms The module pattern is a common JavaScript coding pattern. It's generally well understood, but there are a number of advanced uses that have not gotten a lot of attention. In this article, I'll review the basics and cover some truly remarkable advanced topics, including one which I think is original. In the following guide I will explain two different variation of module pattern that I use during development, namely: Loose Augmentation Function Import Augmentation One limitation of the module pattern so far is that the entire module must be in one file. Anyone who has worked in a large code-base understands the value of splitting among multiple files. Luckily, we have a nice solution to  augment modules . First, we import the module, then we add properties, then we export it. Here's an example, augmenting our  MODULAR  from above: // global object being added to the user space var modular = ( function (