iab-vast-parser
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -15,35 +15,27 @@ 'use strict'; | ||
var createPod = function createPod($ads, options) { | ||
var pod = new _iabVastModel.AdPod(); | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
var createPod = function createPod($vast, vast, options) { | ||
var podAds = $vast.ad.filter(function ($ad) { | ||
return typeof $ad.sequence !== 'undefined'; | ||
}).map(function ($ad) { | ||
return (0, _ad2.default)($ad, options); | ||
}); | ||
if (podAds.length > 0) { | ||
vast.adPod = new _iabVastModel.AdPod(); | ||
for (var i = 0; i < podAds.length; i++) { | ||
vast.adPod.ads.add(podAds[i]); | ||
} | ||
} | ||
}; | ||
try { | ||
for (var _iterator = $ads[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var $ad = _step.value; | ||
try { | ||
var createdAd = (0, _ad2.default)($ad, options); | ||
pod.ads.add(createdAd); | ||
} catch (err) { | ||
options.errorHandler(err); | ||
} | ||
var createBuffet = function createBuffet($vast, vast, options) { | ||
var buffetAds = $vast.ad.filter(function ($ad) { | ||
return typeof $ad.sequence === 'undefined'; | ||
}).map(function ($ad) { | ||
return (0, _ad2.default)($ad, options); | ||
}); | ||
if (buffetAds.length > 0) { | ||
for (var i = 0; i < buffetAds.length; i++) { | ||
vast.ads.add(buffetAds[i]); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
return pod; | ||
}; | ||
@@ -55,11 +47,7 @@ | ||
if ($vast.ad && $vast.ad.length > 0) { | ||
if ($vast.ad.length > 1) { | ||
vast.adPod = createPod($vast.ad, options); | ||
} else { | ||
try { | ||
var createdAd = (0, _ad2.default)($vast.ad[0], options); | ||
vast.ads.add(createdAd); | ||
} catch (err) { | ||
options.errorHandler(err); | ||
} | ||
try { | ||
createPod($vast, vast, options); | ||
createBuffet($vast, vast, options); | ||
} catch (err) { | ||
options.errorHandler(err); | ||
} | ||
@@ -69,2 +57,2 @@ } | ||
}; | ||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImZhY3RvcnkvdmFzdC5qcyJdLCJuYW1lcyI6WyJjcmVhdGVQb2QiLCIkYWRzIiwib3B0aW9ucyIsInBvZCIsIiRhZCIsImNyZWF0ZWRBZCIsImFkcyIsImFkZCIsImVyciIsImVycm9ySGFuZGxlciIsIiR2YXN0IiwidmFzdCIsInZlcnNpb24iLCJhZCIsImxlbmd0aCIsImFkUG9kIl0sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQTs7QUFDQTs7Ozs7O0FBRUEsSUFBTUEsWUFBWSxTQUFaQSxTQUFZLENBQUNDLElBQUQsRUFBT0MsT0FBUCxFQUFtQjtBQUNuQyxNQUFNQyxNQUFNLHlCQUFaO0FBRG1DO0FBQUE7QUFBQTs7QUFBQTtBQUVuQyx5QkFBa0JGLElBQWxCLDhIQUF3QjtBQUFBLFVBQWJHLEdBQWE7O0FBQ3RCLFVBQUk7QUFDRixZQUFNQyxZQUFZLGtCQUFTRCxHQUFULEVBQWNGLE9BQWQsQ0FBbEI7QUFDQUMsWUFBSUcsR0FBSixDQUFRQyxHQUFSLENBQVlGLFNBQVo7QUFDRCxPQUhELENBR0UsT0FBT0csR0FBUCxFQUFZO0FBQ1pOLGdCQUFRTyxZQUFSLENBQXFCRCxHQUFyQjtBQUNEO0FBQ0Y7QUFUa0M7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTs7QUFVbkMsU0FBT0wsR0FBUDtBQUNELENBWEQ7O2tCQWFlLFVBQUNPLEtBQU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dC5hZFBvZCA9IG5ldyBBZFBvZCgpXG4gICAgZm9yIChsZXQgaSA9IDA7IGkgPCBwb2RBZHMubGVuZ3RoOyBpKyspIHtcbiAgICAgIHZhc3QuYWRQb2QuYWRzLmFkZChwb2RBZHNbaV0pXG4gICAgfVxuICB9XG59XG5cbmNvbnN0IGNyZWF0ZUJ1ZmZldCA9ICgkdmFzdCwgdmFzdCwgb3B0aW9ucykgPT4ge1xuICBjb25zdCBidWZmZXRBZHMgPSAkdmFzdC5hZFxuICAgIC5maWx0ZXIoJGFkID0+IHR5cGVvZiAkYWQuc2VxdWVuY2UgPT09ICd1bmRlZmluZWQnKVxuICAgIC5tYXAoJGFkID0+IGNyZWF0ZUFkKCRhZCwgb3B0aW9ucykpXG4gIGlmIChidWZmZXRBZHMubGVuZ3RoID4gMCkge1xuICAgIGZvciAobGV0IGkgPSAwOyBpIDwgYnVmZmV0QWRzLmxlbmd0aDsgaSsrKSB7XG4gICAgICB2YXN0LmFkcy5hZGQoYnVmZmV0QWRzW2ldKVxuICAgIH1cbiAgfVxufVxuXG5leHBvcnQgZGVmYXVsdCAoJHZhc3QsIG9wdGlvbnMpID0+IHtcbiAgY29uc3QgdmFzdCA9IG5ldyBWQVNUKClcbiAgdmFzdC52ZXJzaW9uID0gJHZhc3QudmVyc2lvblxuICBpZiAoJHZhc3QuYWQgJiYgJHZhc3QuYWQubGVuZ3RoID4gMCkge1xuICAgIHRyeSB7XG4gICAgICBjcmVhdGVQb2QoJHZhc3QsIHZhc3QsIG9wdGlvbnMpXG4gICAgICBjcmVhdGVCdWZmZXQoJHZhc3QsIHZhc3QsIG9wdGlvbnMpXG4gICAgfSBjYXRjaCAoZXJyKSB7XG4gICAgICBvcHRpb25zLmVycm9ySGFuZGxlcihlcnIpXG4gICAgfVxuICB9XG4gIHJldHVybiB2YXN0XG59XG4iXX0= |
@@ -13,26 +13,12 @@ 'use strict'; | ||
var _strict = require('./errors/strict'); | ||
var _strict2 = _interopRequireDefault(_strict); | ||
var _loose = require('./errors/loose'); | ||
var _loose2 = _interopRequireDefault(_loose); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var DEFAULT_OPTIONS = { | ||
strict: false | ||
}; | ||
exports.default = function (xml) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
options = Object.assign({}, DEFAULT_OPTIONS, options); | ||
if (options.domParser == null) { | ||
options.domParser = new _xmldom.DOMParser(); | ||
} | ||
options.errorHandler = options.strict ? _strict2.default : _loose2.default; | ||
return (0, _parse2.default)(xml, options); | ||
}; | ||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LmpzIl0sIm5hbWVzIjpbIkRFRkFVTFRfT1BUSU9OUyIsInN0cmljdCIsInhtbCIsIm9wdGlvbnMiLCJPYmplY3QiLCJhc3NpZ24iLCJkb21QYXJzZXIiLCJlcnJvckhhbmRsZXIiXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBOztBQUNBOzs7O0FBQ0E7Ozs7QUFDQTs7Ozs7O0FBRUEsSUFBTUEsa0JBQWtCO0FBQ3RCQyxVQUFRO0FBRGMsQ0FBeEI7O2tCQUllLFVBQUNDLEdBQUQsRUFBdUI7QUFBQSxNQUFqQkMsT0FBaUIsdUVBQVAsRUFBTzs7QUFDcENBLFlBQVVDLE9BQU9DLE1BQVAsQ0FBYyxFQUFkLEVBQWtCTCxlQUFsQixFQUFtQ0csT0FBbkMsQ0FBVjtBQUNBLE1BQUlBLFFBQVFHLFNBQVIsSUFBcUIsSUFBekIsRUFBK0I7QUFDN0JILFlBQVFHLFNBQVIsR0FBb0IsdUJBQXBCO0FBQ0Q7QUFDREgsVUFBUUksWUFBUixHQUF1QkosUUFBUUYsTUFBUixxQ0FBdkI7QUFDQSxTQUFPLHFCQUFNQyxHQUFOLEVBQVdDLE9BQVgsQ0FBUDtBQUNELEMiLCJmaWxlIjoiaW5kZXguanM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xPQUFYLENBQVA7QUFDRCxDIiwiZmlsZSI6ImluZGV4LmpzIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHtET01QYXJzZXJ9IGZyb20gJ3htbGRvbSdcbmltcG9ydCBwYXJzZSBmcm9tICcuL3BhcnNlJ1xuXG5leHBvcnQgZGVmYXVsdCAoeG1sLCBvcHRpb25zID0ge30pID0+IHtcbiAgaWYgKG9wdGlvbnMuZG9tUGFyc2VyID09IG51bGwpIHtcbiAgICBvcHRpb25zLmRvbVBhcnNlciA9IG5ldyBET01QYXJzZXIoKVxuICB9XG4gIHJldHVybiBwYXJzZSh4bWwsIG9wdGlvbnMpXG59XG4iXX0= |
@@ -19,4 +19,16 @@ 'use strict'; | ||
var _strict = require('./errors/strict'); | ||
var _strict2 = _interopRequireDefault(_strict); | ||
var _loose = require('./errors/loose'); | ||
var _loose2 = _interopRequireDefault(_loose); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var DEFAULT_OPTIONS = { | ||
strict: false | ||
}; | ||
var toElement = function toElement(xml, options) { | ||
@@ -36,2 +48,4 @@ if (typeof xml === 'string') { | ||
options = Object.assign({}, DEFAULT_OPTIONS, options); | ||
options.errorHandler = options.strict ? _strict2.default : _loose2.default; | ||
var elem = toElement(xml, options); | ||
@@ -42,2 +56,2 @@ var unmarshaler = new _unmarshaler2.default(_schema2.default); | ||
}; | ||
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInBhcnNlLmpzIl0sIm5hbWVzIjpbInRvRWxlbWVudCIsInhtbCIsIm9wdGlvbnMiLCJkb21QYXJzZXIiLCJET01QYXJzZXIiLCJwYXJzZUZyb21TdHJpbmciLCJkb2N1bWVudEVsZW1lbnQiLCJlbGVtIiwidW5tYXJzaGFsZXIiLCJyb290IiwidW5tYXJzaGFsIl0sIm1hcHBpbmdzIjoiOzs7Ozs7QUFBQTs7OztBQUNBOzs7O0FBQ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GxlciBmcm9tICcuL2Vycm9ycy9sb29zZSdcblxuY29uc3QgREVGQVVMVF9PUFRJT05TID0ge1xuICBzdHJpY3Q6IGZhbHNlXG59XG5cbmNvbnN0IHRvRWxlbWVudCA9ICh4bWwsIG9wdGlvbnMpID0+IHtcbiAgaWYgKHR5cGVvZiB4bWwgPT09ICdzdHJpbmcnKSB7XG4gICAgY29uc3QgZG9tUGFyc2VyID0gb3B0aW9ucy5kb21QYXJzZXIgfHwgbmV3IERPTVBhcnNlcigpXG4gICAgeG1sID0gZG9tUGFyc2VyLnBhcnNlRnJvbVN0cmluZyh4bWwsICd0ZXh0L3htbCcpXG4gIH1cbiAgaWYgKHhtbC5kb2N1bWVudEVsZW1lbnQgIT0gbnVsbCkge1xuICAgIHhtbCA9IHhtbC5kb2N1bWVudEVsZW1lbnRcbiAgfVxuICByZXR1cm4geG1sXG59XG5cbmV4cG9ydCBkZWZhdWx0ICh4bWwsIG9wdGlvbnMgPSB7fSkgPT4ge1xuICBvcHRpb25zID0gT2JqZWN0LmFzc2lnbih7fSwgREVGQVVMVF9PUFRJT05TLCBvcHRpb25zKVxuICBvcHRpb25zLmVycm9ySGFuZGxlciA9IG9wdGlvbnMuc3RyaWN0ID8gc3RyaWN0SGFuZGxlciA6IGxvb3NlSGFuZGxlclxuICBjb25zdCBlbGVtID0gdG9FbGVtZW50KHhtbCwgb3B0aW9ucylcbiAgY29uc3QgdW5tYXJzaGFsZXIgPSBuZXcgVW5tYXJzaGFsZXIoc2NoZW1hKVxuICBjb25zdCByb290ID0gdW5tYXJzaGFsZXIudW5tYXJzaGFsKGVsZW0pXG4gIHJldHVybiBjcmVhdGVWQVNUKHJvb3QsIG9wdGlvbnMpXG59XG4iXX0= |
{ | ||
"name": "iab-vast-parser", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"description": "Parses IAB VAST tags into iab-vast-model objects.", | ||
@@ -13,3 +13,3 @@ "main": "index.js", | ||
"engines": { | ||
"node": ">=0.12.0" | ||
"node": ">=4" | ||
}, | ||
@@ -37,13 +37,12 @@ "license": "MIT", | ||
"devDependencies": { | ||
"babel-eslint": "^7.1.1", | ||
"babel-plugin-transform-runtime": "^6.15.0", | ||
"babel-preset-es2015": "^6.22.0", | ||
"babel-preset-stage-3": "^6.17.0", | ||
"babel-register": "^6.22.0", | ||
"babel-runtime": "^6.20.0", | ||
"babel-plugin-transform-runtime": "^6.23.0", | ||
"babel-preset-es2015": "^6.24.0", | ||
"babel-preset-stage-3": "^6.22.0", | ||
"babel-register": "^6.24.0", | ||
"babel-runtime": "^6.23.0", | ||
"chai": "^3.5.0", | ||
"chai-as-promised": "^6.0.0", | ||
"del": "^2.2.0", | ||
"fs-extra": "^2.0.0", | ||
"fs-promise": "^1.0.0", | ||
"fs-extra": "^2.1.2", | ||
"fs-promise": "^2.0.0", | ||
"globule": "^1.0.0", | ||
@@ -55,6 +54,6 @@ "gulp": "^3.9.1", | ||
"gulp-istanbul": "^1.0.0", | ||
"gulp-load-plugins": "^1.4.0", | ||
"gulp-mocha": "^3.0.0", | ||
"gulp-sourcemaps": "^2.4.0", | ||
"gulp-standard": "^8.0.3", | ||
"gulp-load-plugins": "^1.5.0", | ||
"gulp-mocha": "^3.0.1", | ||
"gulp-sourcemaps": "^2.4.1", | ||
"gulp-standard": "^9.0.0", | ||
"gulp-util": "^3.0.8", | ||
@@ -64,10 +63,9 @@ "in-publish": "^2.0.0", | ||
"json-stable-stringify": "^1.0.1", | ||
"mocha-junit-reporter": "^1.12.1", | ||
"mocha-junit-reporter": "^1.13.0", | ||
"normalize-newline": "^3.0.0", | ||
"run-sequence": "^1.1.5", | ||
"standard": "^8.6.0", | ||
"yargs": "^6.5.0" | ||
"standard": "^9.0.1", | ||
"yargs": "^7.0.2" | ||
}, | ||
"standard": { | ||
"parser": "babel-eslint", | ||
"globals": [ | ||
@@ -79,11 +77,3 @@ "describe", | ||
] | ||
}, | ||
"greenkeeper": { | ||
"ignore": [ | ||
"babel-eslint", | ||
"gulp-standard", | ||
"normalize-newline", | ||
"standard" | ||
] | ||
} | ||
} |
import {VAST, AdPod} from 'iab-vast-model' | ||
import createAd from './ad' | ||
const createPod = ($ads, options) => { | ||
const pod = new AdPod() | ||
for (const $ad of $ads) { | ||
try { | ||
const createdAd = createAd($ad, options) | ||
pod.ads.add(createdAd) | ||
} catch (err) { | ||
options.errorHandler(err) | ||
const createPod = ($vast, vast, options) => { | ||
const podAds = $vast.ad | ||
.filter($ad => typeof $ad.sequence !== 'undefined') | ||
.map($ad => createAd($ad, options)) | ||
if (podAds.length > 0) { | ||
vast.adPod = new AdPod() | ||
for (let i = 0; i < podAds.length; i++) { | ||
vast.adPod.ads.add(podAds[i]) | ||
} | ||
} | ||
return pod | ||
} | ||
const createBuffet = ($vast, vast, options) => { | ||
const buffetAds = $vast.ad | ||
.filter($ad => typeof $ad.sequence === 'undefined') | ||
.map($ad => createAd($ad, options)) | ||
if (buffetAds.length > 0) { | ||
for (let i = 0; i < buffetAds.length; i++) { | ||
vast.ads.add(buffetAds[i]) | ||
} | ||
} | ||
} | ||
export default ($vast, options) => { | ||
@@ -21,11 +31,7 @@ const vast = new VAST() | ||
if ($vast.ad && $vast.ad.length > 0) { | ||
if ($vast.ad.length > 1) { | ||
vast.adPod = createPod($vast.ad, options) | ||
} else { | ||
try { | ||
const createdAd = createAd($vast.ad[0], options) | ||
vast.ads.add(createdAd) | ||
} catch (err) { | ||
options.errorHandler(err) | ||
} | ||
try { | ||
createPod($vast, vast, options) | ||
createBuffet($vast, vast, options) | ||
} catch (err) { | ||
options.errorHandler(err) | ||
} | ||
@@ -32,0 +38,0 @@ } |
import {DOMParser} from 'xmldom' | ||
import parse from './parse' | ||
import strictHandler from './errors/strict' | ||
import looseHandler from './errors/loose' | ||
const DEFAULT_OPTIONS = { | ||
strict: false | ||
} | ||
export default (xml, options = {}) => { | ||
options = Object.assign({}, DEFAULT_OPTIONS, options) | ||
if (options.domParser == null) { | ||
options.domParser = new DOMParser() | ||
} | ||
options.errorHandler = options.strict ? strictHandler : looseHandler | ||
return parse(xml, options) | ||
} |
import Unmarshaler from './xml/unmarshaler' | ||
import schema from './vast/schema' | ||
import createVAST from './factory/vast' | ||
import strictHandler from './errors/strict' | ||
import looseHandler from './errors/loose' | ||
const DEFAULT_OPTIONS = { | ||
strict: false | ||
} | ||
const toElement = (xml, options) => { | ||
@@ -17,2 +23,4 @@ if (typeof xml === 'string') { | ||
export default (xml, options = {}) => { | ||
options = Object.assign({}, DEFAULT_OPTIONS, options) | ||
options.errorHandler = options.strict ? strictHandler : looseHandler | ||
const elem = toElement(xml, options) | ||
@@ -19,0 +27,0 @@ const unmarshaler = new Unmarshaler(schema) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
134645
29
0
1916