This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Benchmark = require('benchmark'); | |
Benchmark.prototype.setup = function() { | |
a = ["test"]; | |
for (var i = 0; i < 10000; i++) { | |
a.push("some other stuff"); | |
} | |
s = a.join(); | |
re1 = new RegExp("^test"); | |
re2 = new RegExp("^not there"); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creates a 'range' Array, extracted from Liquid.js | |
function makeRange(from, to) { | |
var arr= [], | |
left= parseInt(from), | |
right= parseInt(to); | |
// Check if left and right are NaN, if so try as characters | |
if( isNaN(left + right) ) { | |
// TODO Add in error checking to make sure ranges are single | |
// character, A-Z or a-z, etc. | |
left = from.charCodeAt(0); |