summaryrefslogtreecommitdiff
path: root/luigi-template.js
diff options
context:
space:
mode:
authorpabs@pablotron.org <pabs@pablotron.org>2014-12-18 02:07:08 -0500
committerpabs@pablotron.org <pabs@pablotron.org>2014-12-18 02:07:08 -0500
commitd49ccd25b30efb777fcfc6007ee29785e8d843a2 (patch)
treed103e4097d11daa2660e8f80097eb03acb6d884f /luigi-template.js
parent44a1780688aa1bfec6928a19a41dc5b06742eede (diff)
downloadluigi-template-d49ccd25b30efb777fcfc6007ee29785e8d843a2.tar.bz2
luigi-template-d49ccd25b30efb777fcfc6007ee29785e8d843a2.zip
add array.reduce polyfill
Diffstat (limited to 'luigi-template.js')
-rw-r--r--luigi-template.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/luigi-template.js b/luigi-template.js
index 806ddea..0afa0d6 100644
--- a/luigi-template.js
+++ b/luigi-template.js
@@ -109,6 +109,25 @@ LuigiTemplate = (function() {
}
})();
+ // Array.reduce polyfill
+ var reduce = (function() {
+ if (Array.prototype.reduce) {
+ return function(a, fn, iv) {
+ return a.reduce(fn, iv);
+ };
+ } else {
+ return function(a, fn, iv) {
+ var r = iv;
+
+ each(a, function(v, i) {
+ r = fn(r, v, i, a);
+ });
+
+ return r;
+ };
+ }
+ })();
+
// String.scan polyfill
function scan(s, re, fn) {
var m;