From: Aleksander Ɓukasz Date: Tue, 21 Jan 2014 10:04:31 +0000 (+0100) Subject: wlxml: metadata - additional iterator, filtering X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/d5f4c1bb0dc3a9ff8845d209c75d00cc733b3360 wlxml: metadata - additional iterator, filtering --- 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;