## Classes
Document
## Functions
bundle(files, [options])Document
## Document **Kind**: global class * [Document](#Document) * [new Document(parsedJSONList, base)](#new_Document_new) * [.json()](#Document+json) ⇒ Object * [.yml()](#Document+yml) ⇒ string * [.string()](#Document+string) ⇒ string ### new Document(parsedJSONList, base) | Param | Type | | --- | --- | | parsedJSONList | Array.<Object> | | base | Object | **Example** ```js const document = new Document(parsedJSONList, base); console.log(document.json()); // get JSON object console.log(document.yml()); // get YAML string console.log(document.string()); // get JSON string ``` ### document.json() ⇒ Object **Kind**: instance method of [Document](#Document) ### document.yml() ⇒ string **Kind**: instance method of [Document](#Document) ### document.string() ⇒ string **Kind**: instance method of [Document](#Document) ## bundle(files, [options]) ⇒ [Document](#Document) **Kind**: global function | Param | Type | Description | | --- | --- | --- | | files | Array.<string> |

Array of stringified AsyncAPI documents in YAML format, that are to be bundled (or array of filepaths, resolved and passed via Array.map() and fs.readFileSync, which is the same, see README.md).

| | [options] | Object | | | [options.base] | string \| object |

Base object whose properties will be retained.

| | [options.referenceIntoComponents] | boolean |

Pass true to resolve external references to components.

| **Example** **TypeScript** ```ts import { readFileSync, writeFileSync } from 'fs'; import bundle from '@asyncapi/bundler'; async function main() { const document = await bundle([readFileSync('./main.yaml', 'utf-8')], { referenceIntoComponents: true, }); console.log(document.yml()); // the complete bundled AsyncAPI document writeFileSync('asyncapi.yaml', document.yml()); // the complete bundled AsyncAPI document } main().catch(e => console.error(e)); ``` **JavaScript CJS module system** ```js 'use strict'; const { readFileSync, writeFileSync } = require('fs'); const bundle = require('@asyncapi/bundler'); async function main() { const document = await bundle([readFileSync('./main.yaml', 'utf-8')], { referenceIntoComponents: true, }); writeFileSync('asyncapi.yaml', document.yml()); } main().catch(e => console.error(e)); ``` **JavaScript ESM module system** ```js 'use strict'; import { readFileSync, writeFileSync } from 'fs'; import bundle from '@asyncapi/bundler'; async function main() { const document = await bundle([readFileSync('./main.yaml', 'utf-8')], { referenceIntoComponents: true, }); writeFileSync('asyncapi.yaml', document.yml()); } main().catch(e => console.error(e)); ```