Last active
August 29, 2015 14:07
-
-
Save goliatone/fde84615051c1323adcd to your computer and use it in GitHub Desktop.
simple javascript helper, repeat method
This file contains hidden or 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
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