diff --git a/docs/04_documents.md b/docs/04_documents.md index b0ad88c5..82265df5 100644 --- a/docs/04_documents.md +++ b/docs/04_documents.md @@ -102,7 +102,6 @@ During stringification, a document with a true-ish `version` value will include | ------------------------------------------ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | createNode(value, options?) | `Node` | Recursively wrap any input with appropriate `Node` containers. See [Creating Nodes](#creating-nodes) for more information. | | createPair(key, value, options?) | `Pair` | Recursively wrap `key` and `value` into a `Pair` object. See [Creating Nodes](#creating-nodes) for more information. | -| listNonDefaultTags() | `string[]` | List the tags used in the document that are not in the default `tag:yaml.org,2002:` namespace. | | parse(cst) | `Document` | Parse a CST into this document. Mostly an internal method, modifying the document according to the contents of the parsed `cst`. Calling this multiple times on a Document is not recommended. | | setSchema(id?, customTags?) | `void` | Set the schema used by the document. `id` may either be a YAML version, or the identifier of a YAML 1.2 schema; if set, `customTags` should have the same shape as the similarly-named option. | | setTagPrefix(handle, prefix) | `void` | Set `handle` as a shorthand string for the `prefix` tag namespace. | diff --git a/index.d.ts b/index.d.ts index 6b17369c..99f8cc3a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -283,11 +283,7 @@ export class Document extends Collection { * `Scalar` objects. */ createPair(key: any, value: any, options?: { wrapScalars?: boolean }): Pair - /** - * List the tags used in the document that are not in the default - * `tag:yaml.org,2002:` namespace. - */ - listNonDefaultTags(): string[] + /** Parse a CST into this document */ parse(cst: CST.Document): this /** diff --git a/src/doc/Document.d.ts b/src/doc/Document.d.ts index 7bf391eb..48dcb1fe 100644 --- a/src/doc/Document.d.ts +++ b/src/doc/Document.d.ts @@ -87,11 +87,7 @@ export class Document extends Collection { * `Scalar` objects. */ createPair(key: any, value: any, options?: { wrapScalars?: boolean }): Pair - /** - * List the tags used in the document that are not in the default - * `tag:yaml.org,2002:` namespace. - */ - listNonDefaultTags(): string[] + /** Parse a CST into this document */ parse(cst: CST.Document): this /** diff --git a/src/doc/Document.js b/src/doc/Document.js index 52b088fa..433c5501 100644 --- a/src/doc/Document.js +++ b/src/doc/Document.js @@ -239,12 +239,6 @@ export class Document { return this } - listNonDefaultTags() { - return listTagNames(this.contents).filter( - t => t.indexOf(defaultTagPrefix) !== 0 - ) - } - setTagPrefix(handle, prefix) { if (handle[0] !== '!' || handle[handle.length - 1] !== '!') throw new Error('Handle must start and end with !') @@ -306,7 +300,9 @@ export class Document { lines.push(vd) hasDirectives = true } - const tagNames = this.listNonDefaultTags() + const tagNames = listTagNames(this.contents).filter( + t => t.indexOf(defaultTagPrefix) !== 0 + ) this.tagPrefixes.forEach(({ handle, prefix }) => { if (tagNames.some(t => t.indexOf(prefix) === 0)) { lines.push(`%TAG ${handle} ${prefix}`)