Skip to content

Instantly share code, notes, and snippets.

View 13protons's full-sized avatar

Alan Languirand 13protons

View GitHub Profile
@13protons
13protons / benchmark-startswith.js
Last active December 17, 2017 19:09 — forked from dai-shi/benchmark-startswith.js
benchmark of String.startsWith equivalents in Node.js
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");
};
@13protons
13protons / range.js
Last active August 29, 2015 14:07 — forked from mattmccray/range.js
// 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);