The popular open-source contract for web designers and developers by Stuff & Nonsense
- Originally published: 23/12/2008
- Revised date: 15/12/2013
- Original post
var raw_str_regex = "-([a-zA-Z0-9_]+)$"; | |
var regex = new RegExp(raw_str_regex, "gm"); | |
var lst = [ | |
"this is -not", | |
"this is -not", | |
"this is -not", | |
"this is -not", | |
"this is -not", | |
"this is -not" |
var raw_str_regex = "(?:\\s|^)((?:\!|\-)\\w+)"; | |
var regex = new RegExp(raw_str_regex, "gm"); | |
var lst = [ | |
"this is !not", |
exports.arity_decorator = function(fun) { | |
function wrapped() { | |
if(arguments.length != fun.length) | |
throw new Error("Y U NO USE RIGHT?!") | |
fun.apply(this, arguments) | |
} | |
return wrapped; | |
} | |
> function foo(x,y) { | |
if(arguments.length > 2) throw new Error("Stupid no method overloading lameness error"); | |
... args = Array.prototype.join.call(arguments, ","); | |
... console.log('X:' + x + ' Y:' + y + ' Args:' + args) | |
... } | |
> foo(1,2) | |
X:1 Y:2 Args:1,2 | |
> foo(1,2,3,4,5) | |
X:1 Y:2 Args:1,2,3,4,5 |
/* | |
* | |
* | |
* file: raft.js | |
* R.A.F.T. | |
* | |
* Request | |
* Animation | |
* Frame | |
* Timer/Template |
/* | |
* | |
* | |
* file: animator.js | |
* author: gregory tomlinson | |
* desc: handy scaffolding for doing continous animations | |
* | |
* the requestion animation frame works very well as a lazy timer | |
* it's cpu cycles are low and it informs the browser the | |
* intention is to change the DOM |
// utility string parse function | |
function out( str, options ) { | |
for(k in options) { | |
str=str.replace(/%\{([a-zA-Z0-9-]{1,}?)\}/mi, function(m, key ){ | |
return options[key]; | |
}); | |
} | |
return str; | |
} |
/* | |
* | |
* setTimeout can take more than 2 arguments. args > 2 will be passed to method in arg position 1 | |
* setTimeout(myMethod, 10, "one", { "foo" : "bar" } | |
* | |
* */ | |
function myMethod( param1, param2 ) { | |
console.log(arguments); | |
} |
/* | |
* SeriesQueue | |
* author: gregory tomlinson | |
* */ | |
(function(window, undefined) { | |
// If a method returns true, the motion queue continues animation | |
// by default, functions return null, meaning empty funcs | |
// will not animate, instead, they will execute once, |