From d5f4c1bb0dc3a9ff8845d209c75d00cc733b3360 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Tue, 21 Jan 2014 11:04:31 +0100 Subject: [PATCH 1/1] wlxml: metadata - additional iterator, filtering --- src/wlxml/extensions/metadata/metadata.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/wlxml/extensions/metadata/metadata.js b/src/wlxml/extensions/metadata/metadata.js index b30b94c..b19cd52 100644 --- a/src/wlxml/extensions/metadata/metadata.js +++ b/src/wlxml/extensions/metadata/metadata.js @@ -90,8 +90,16 @@ _.extend(Metadata.prototype, { } }), - forEach: function(callback) { - return this._rows.forEach(callback); + _iter: function(method, callback, key) { + return this._rows + .filter(function(row) { return !key || row.getKey() === key; }) + [method](function(row) { return callback(row); }); + }, + forEach: function(callback, key) { + return this._iter('forEach', callback, key); + }, + some: function(callback, key) { + return this._iter('some', callback, key); }, add: function(rowDesc, options) { var row; -- 2.20.1