diff --git a/recentrunes.js b/recentrunes.js index 3047aa0..2e1341b 100644 --- a/recentrunes.js +++ b/recentrunes.js @@ -188,6 +188,48 @@ rr.EndOfText = function() { +/** + * @constructor + * + * @param {string} value + * @private + */ +rr.Insert_ = function(value) { + this.value_ = value; +}; + + +/** + * @param {rr.Context} context + * @return {rr.typeIterator} + */ +rr.Insert_.prototype.match = function(context) { + return rr.iterableFromArray_([{ + 'context': context, + 'nodes': [document.createTextNode(this.value_)] + }]); +}; + + +/** + * @param {string} value + * @return {rr.Insert_} + */ +rr.Insert = function(value) { + return (rr.Insert.cache_[value] || + (rr.Insert.cache_[value] = new rr.Insert_(value))); +}; + + +/** + * @type {Object.} + * @const + * @private + */ +rr.Insert.cache_ = {}; + + + /** * @constructor *