phrase-engine
Version:
Language files on steroids for conversational UIs that aren't boring.
30 lines • 1.02 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const Node_1 = require("../Node");
const peek_1 = require("../peek");
class RawTextNode extends Node_1.PhraseNode {
validateNodeName(name) {
return name === '#text' || name === 'text';
}
init(root, packet) {
this.__value = peek_1.default(packet.ignore_spaces)
? root.nodeValue.replace(/[\s\n\r]+/ig, ' ').trim()
: root.nodeValue.replace(/[\s\n\r]+/ig, ' ');
this.setNextNode(peek_1.default(packet.next_stack));
}
eval(packet, branch) {
packet.sentence_components.push(this.__value);
return this.next().eval(packet);
}
*gen(packet) {
packet.sentence_components.push(this.__value);
yield* this.next().gen(packet);
packet.sentence_components.pop();
}
count(e_packet) {
const ret = this.next().count(e_packet);
return ret;
}
}
exports.RawTextNode = RawTextNode;
//# sourceMappingURL=RawTextNode.js.map