X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/16c90b3616f1645aab9fe284fd3b89641dfb42f2..d1effc78cd6e71573f29f7901c598cabc3c2aaf8:/src/wlxml/extensions/metadata/metadata.js?ds=sidebyside diff --git a/src/wlxml/extensions/metadata/metadata.js b/src/wlxml/extensions/metadata/metadata.js index 54b3f96..b19cd52 100644 --- a/src/wlxml/extensions/metadata/metadata.js +++ b/src/wlxml/extensions/metadata/metadata.js @@ -8,8 +8,8 @@ var _ = require('libs/underscore'), var Row = function(key, value, metadata) { - this.key = key; - this.value = value; + this.key = key || ''; + this.value = value || ''; this.metadata = metadata; }; @@ -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;