Skip to content

Instantly share code, notes, and snippets.

@goliatone
Last active August 29, 2015 14:07
Show Gist options
  • Save goliatone/fde84615051c1323adcd to your computer and use it in GitHub Desktop.
Save goliatone/fde84615051c1323adcd to your computer and use it in GitHub Desktop.
simple javascript helper, repeat method
define('helpers/repeat', ['extend'], function(extend) {
/**
* template:
* repeat(20).with({image:default.png, private:true});
*/
var repeat = function(times) {
var a = Array.apply(null, new Array(times));
a.with = function(template){
return a.map(function(){
return extend({}, template);
});
};
return a;
};
return repeat;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment