samora/validr — pull request #4 by mocheng (2014-08-28 09:10:34+00:00)
Title: Improve perf by iterates validator.js methods only once

Fix #3

Currently, every new `Validr` instance is created, `validator.js` methods are iterated and new wrapper functions are created. This looks a waste, since `Validr` instance must be created a lot of times in real product node.js program.

I create a new method `generateValidatorClass` which returns a class whose `prototype` has wrapper methods for `validator.js` methods. Instance of the class is to replace the `Validaor._validators`.

In my Mac, the `benchmark/test.js` shows that 10000 loops cost about half second
> Cost time: 532

Before this fix, 10000 loops cost almost one second
> Cost time: 902