From fd5817a6bb3185314540825e3d665e94ffe188c0 Mon Sep 17 00:00:00 2001 From: Ben Burwell Date: Wed, 14 Sep 2016 12:30:04 -0400 Subject: Initial commit --- lib/util.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lib/util.js (limited to 'lib/util.js') diff --git a/lib/util.js b/lib/util.js new file mode 100644 index 0000000..3c6857c --- /dev/null +++ b/lib/util.js @@ -0,0 +1,13 @@ +HTMLCollection.prototype.map = function(fn) { + var results = []; + for (var idx = 0; idx < this.length; idx++) { + results.push(fn(this.item(idx))); + } + return results; +}; + +HTMLCollection.prototype.forEach = function(fn) { + for (var idx = 0; idx < this.length; idx++) { + fn(this.item(idx)); + } +}; -- cgit v1.2.3