Parses VAST files into plain javascript objects
The library currently makes use of the current projects and is dependent on them:
The main module to use is vastAdManager
which exposes two functions:
requestVastChain
addEventListener
The requestVastChain
returns a promise and will resolve once it has finished downloading all of the VAST files in the chain.
It returns a VastResponse
object.
vastAdManager.requestVastChain('http://example.com/vast-file.xml')
.fail(function(vastError) {
// handle any errors that may have occurred such as an HTTP 404.
})
.then(function(vastResponse) {
// use the vastResponse
});
It is possible to register event listeners for when a request is about to be made and when it has finished.
requestStart
- start of request for VAST filerequestEnd
- end of request for VAST file
These events can be useful for logging purposes or for timing how long each request takes.
Each event passes has the following properties available:
requestNumber
- the current request number, which can be more than one when VAST wrapper files are useduri
- the URI for the requestvastResponse
- theVastResponse
object that is being added to while following a chain of VAST files.
In one terminal run
npm start
Then go to http://localhost:8000/test/phantom/testrunner.html in your browser.
Or run npm test
License information can be found in the LICENSE file.