iab-vast-parser
Version:
Parses IAB VAST tags into iab-vast-model objects.
30 lines (23 loc) • 755 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
var nodeTypeIs = function nodeTypeIs(type) {
return function (node) {
return node.nodeType === type;
};
};
var isElement = exports.isElement = nodeTypeIs(1);
var isText = exports.isText = nodeTypeIs(3);
var isCdata = exports.isCdata = nodeTypeIs(4);
var getChildren = exports.getChildren = function getChildren(node, filter) {
return Array.prototype.filter.call(node.childNodes, filter);
};
var isTextOrCdata = function isTextOrCdata(node) {
return isText(node) || isCdata(node);
};
var getText = exports.getText = function getText(node) {
return getChildren(node, isTextOrCdata).map(function (child) {
return child.nodeValue;
}).join('').trim();
};
;