All Projects → unruly → Vast Parser

unruly / Vast Parser

Licence: mit
Recursively requests and parses VAST chains into a single JavaScript object.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Vast Parser

Nokogiri
Nokogiri (鋸) makes it easy and painless to work with XML and HTML from Ruby.
Stars: ✭ 5,748 (+31833.33%)
Mutual labels:  xml
Array To Xml
A simple class to convert an array to xml
Stars: ✭ 744 (+4033.33%)
Mutual labels:  xml
Cardinalpgm Maps
Make OCN Great Again!
Stars: ✭ 6 (-66.67%)
Mutual labels:  xml
Dom4j
flexible XML framework for Java
Stars: ✭ 689 (+3727.78%)
Mutual labels:  xml
Ofbiz
Apache OFBiz - Main development has moved to the ofbiz-frameworks repository.
Stars: ✭ 719 (+3894.44%)
Mutual labels:  xml
Dasel
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Stars: ✭ 759 (+4116.67%)
Mutual labels:  xml
Sirix
SirixDB is a temporal, evolutionary database system, which uses an accumulate only approach. It keeps the full history of each resource. Every commit stores a space-efficient snapshot through structural sharing. It is log-structured and never overwrites data. SirixDB uses a novel page-level versioning approach called sliding snapshot.
Stars: ✭ 638 (+3444.44%)
Mutual labels:  xml
Fuzi
A fast & lightweight XML & HTML parser in Swift with XPath & CSS support
Stars: ✭ 894 (+4866.67%)
Mutual labels:  xml
Docconv
Converts PDF, DOC, DOCX, XML, HTML, RTF, etc to plain text
Stars: ✭ 735 (+3983.33%)
Mutual labels:  xml
Rss Parser
A lightweight RSS parser, for Node and the browser
Stars: ✭ 793 (+4305.56%)
Mutual labels:  xml
Leanify
lightweight lossless file minifier/optimizer
Stars: ✭ 694 (+3755.56%)
Mutual labels:  xml
Cxf
Apache CXF
Stars: ✭ 697 (+3772.22%)
Mutual labels:  xml
Etree
parse and generate XML easily in go
Stars: ✭ 763 (+4138.89%)
Mutual labels:  xml
Structured Text Tools
A list of command line tools for manipulating structured text data
Stars: ✭ 6,180 (+34233.33%)
Mutual labels:  xml
Easyxml
Simplifies parsing and modifying of (huge) XML streams (files) based on the StAX parser with combination of JAXB or JDom2
Stars: ✭ 6 (-66.67%)
Mutual labels:  xml
Pinview
A pinview library for android. ✨
Stars: ✭ 650 (+3511.11%)
Mutual labels:  xml
Textfieldboxes
Material Design text field that comes in a box, based on (OLD) Google Material Design guidelines.
Stars: ✭ 760 (+4122.22%)
Mutual labels:  xml
Wed
Wed is a web-based editor that assists users in editing XML documents according to a schema.
Stars: ✭ 17 (-5.56%)
Mutual labels:  xml
Xml Comp
Compare ANY markup documents.
Stars: ✭ 16 (-11.11%)
Mutual labels:  xml
Macsvg
macSVG - An open-source macOS app for designing HTML5 SVG (Scalable Vector Graphics) art and animation with a WebKit web view ➤➤➤
Stars: ✭ 789 (+4283.33%)
Mutual labels:  xml

@unruly/vast-parser

Travis npm

Recursively requests and parses VAST chains into a single JavaScript object.

VAST Chains are VAST Wrappers wrapped in more VAST Wrappers eventually resulting in a VAST Inline.

Example

import { VastAdManager } from '@unruly/vast-parser'

const vastAdManager = new VastAdManager()
vastAdManager.requestVastChain({ url: 'http://example.com/vast-file.xml' })
  .then(
    vastResponse => {
      // success
    },
    vastError => {
      // failure
    }
  )

Installation

You'll need to use a package manager like npm to install this package.

# npm
npm install @unruly/vast-parser

# yarn
yarn add @unruly/vast-parser

Notable Dependencies

  • jQuery for requesting nested VAST URIs. We hope to replace this in the future.

Polyfills

You may need to include some polyfills depending on your target environment.

Usage

Use this package like a typical ES6 module. For detailed usage information on each export, see the subsections below.

// import what you need
import {
  VastAdManager,
  VastErrorCodes,
  VastParser
} from '@unruly/vast-parser'

// do what you want

VastAdManager

new VastAdManager(): { requestVastChain, addEventListener }

Creates a VastAdManager.

vastAdManager.requestVastChain(config: ({ url: string })): Promise

Recursively requests a given VAST URL until a VAST Inline is reached.

Resolves to a VastResponse.

Rejects to a VastError with a code matching to one of the VastErrorCodes.code (see VastErrorCodes section).

vastAdManager.addEventListener(eventName: string, handler: (event: Event) => void): void

Calls the given handler when an event of the eventName is fired. The handler is passed the event as its first parameter.

Event Names

  • requestStart - start of request for VAST file
  • requestEnd - end of request for VAST file

Event Properties

  • requestNumber - the current depth of the VAST chain.
  • uri - the URI for the request.
  • vastResponse - the VastResponse by being built reference.

Caveats

  • VastAdManager currently does not support NodeJS as it relies on jQuery.

VastErrorCodes

An Enum of possible error codes on a VastError (see vastAdManager.requestVastChain section).

For possible values, see the module.

VastParser

VastParser.parse(doc: (Document | { xml: string })): Document

Parses a given VAST document into a JSXMLNode. JSXMLNode a simple JS representation of an XML document.

Caveats

  • To work in NodeJS, you'll need to pass a Document. Use a library like xmldom to parse your document string before sending it to VastParser.parse.

License

License information can be found in the LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].