{"id":22072943,"url":"https://github.com/unruly/vast-parser","last_synced_at":"2025-07-24T11:30:57.805Z","repository":{"id":23853811,"uuid":"27231731","full_name":"unruly/vast-parser","owner":"unruly","description":"Recursively requests and parses VAST chains into a single JavaScript object.","archived":false,"fork":false,"pushed_at":"2022-12-08T15:08:28.000Z","size":630,"stargazers_count":20,"open_issues_count":17,"forks_count":5,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-09-20T09:11:11.802Z","etag":null,"topics":["adtech","vast","vast-tools","xml"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@unruly/vast-parser","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unruly.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-27T15:44:22.000Z","updated_at":"2022-11-26T22:17:57.000Z","dependencies_parsed_at":"2023-01-13T23:58:21.887Z","dependency_job_id":null,"html_url":"https://github.com/unruly/vast-parser","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unruly%2Fvast-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unruly%2Fvast-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unruly%2Fvast-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unruly%2Fvast-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unruly","download_url":"https://codeload.github.com/unruly/vast-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227432290,"owners_count":17775894,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adtech","vast","vast-tools","xml"],"created_at":"2024-11-30T21:16:07.285Z","updated_at":"2024-11-30T21:16:08.188Z","avatar_url":"https://github.com/unruly.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @unruly/vast-parser\n\n[![Travis](https://img.shields.io/travis/unruly/vast-parser.svg)](https://travis-ci.org/unruly/vast-parser)\n[![npm](https://img.shields.io/npm/v/@unruly/vast-parser.svg)](https://www.npmjs.com/package/@unruly/vast-parser)\n\nRecursively requests and parses VAST chains into a single JavaScript object.\n\nVAST Chains are VAST Wrappers wrapped in more VAST Wrappers eventually resulting in a VAST Inline.\n\n## Example\n\n```js\nimport { VastAdManager } from '@unruly/vast-parser'\n\nconst vastAdManager = new VastAdManager()\nvastAdManager.requestVastChain({ url: 'http://example.com/vast-file.xml' })\n  .then(\n    vastResponse =\u003e {\n      // success\n    },\n    vastError =\u003e {\n      // failure\n    }\n  )\n```\n\n## Installation\n\nYou'll need to use a package manager like npm to install this package.\n\n```bash\n# npm\nnpm install @unruly/vast-parser\n\n# yarn\nyarn add @unruly/vast-parser\n```\n\n### Notable Dependencies\n\n- [jQuery](https://jquery.com/) for requesting nested VAST URIs. We hope to replace this in the future.\n\n### Polyfills\n\nYou may need to include some polyfills depending on your target environment.\n\n- [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\n- [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL)\n\n## Usage\n\nUse this package like a typical ES6 module. For detailed usage information on each export, see the subsections below.\n\n```js\n// import what you need\nimport {\n  VastAdManager,\n  VastErrorCodes,\n  VastParser\n} from '@unruly/vast-parser'\n\n// do what you want\n```\n\n### VastAdManager\n\n#### new VastAdManager(): { requestVastChain, addEventListener }\n\nCreates a `VastAdManager`.\n\n##### vastAdManager.requestVastChain(config: ({ url: string })): Promise\u003cVastResponse\u003e\n\nRecursively requests a given VAST URL until a VAST Inline is reached.\n\nResolves to a [`VastResponse`](https://github.com/unruly/vast-parser/blob/master/src/model/vastResponse.js).\n\nRejects to a [`VastError`](https://github.com/unruly/vast-parser/blob/master/src/vastError.js) with a `code` matching to one of the `VastErrorCodes.code` (see `VastErrorCodes` section).\n\n##### vastAdManager.addEventListener(eventName: string, handler: (event: Event) =\u003e void): void\n\nCalls the given `handler` when an `event` of the `eventName` is fired. The `handler` is passed the `event` as its first parameter.\n\n**Event Names**\n\n- `requestStart` - start of request for VAST file\n- `requestEnd` - end of request for VAST file\n\n**Event Properties**\n\n- `requestNumber` - the current depth of the VAST chain.\n- `uri` - the URI for the request.\n- `vastResponse` - the [`VastResponse`](https://github.com/unruly/vast-parser/blob/master/src/model/vastResponse.js) by being built reference.\n\n#### Caveats\n\n- VastAdManager currently does not support NodeJS as it relies on jQuery.\n\n### VastErrorCodes\n\nAn Enum of possible error codes on a `VastError` (see `vastAdManager.requestVastChain` section).\n\n[For possible values, see the module.](https://github.com/unruly/vast-parser/blob/master/src/vastErrorCodes.js)\n\n### VastParser\n\n#### VastParser.parse(doc: (Document | { xml: string })): Document\n\nParses a given VAST document into a JSXMLNode. JSXMLNode a simple JS representation of an XML document.\n\n#### Caveats\n\n- 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`.\n\n## License\n\nLicense information can be found in the LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funruly%2Fvast-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funruly%2Fvast-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funruly%2Fvast-parser/lists"}