From e1548a2ea0988cb183737d80b3957c05860529e4 Mon Sep 17 00:00:00 2001 From: Eemeli Aro Date: Sun, 31 Oct 2021 15:00:17 +0200 Subject: [PATCH] feat: Expose tags & types required by custom composers --- docs/06_custom_tags.md | 3 +++ package.json | 1 + src/index.ts | 5 +++-- src/util.ts | 3 +++ util.d.ts | 3 +++ 5 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 util.d.ts diff --git a/docs/06_custom_tags.md b/docs/06_custom_tags.md index 85b73319..9b0d81ca 100644 --- a/docs/06_custom_tags.md +++ b/docs/06_custom_tags.md @@ -137,6 +137,9 @@ import { debug, // (logLevel, ...messages) => void -- Log debug messages to console findPair, // (items, key) => Pair? -- Given a key, find a matching Pair foldFlowLines, // (text, indent, mode, options) => string -- Fold long lines + mapTag, // CollectionTag + seqTag, // CollectionTag + stringTag, // ScalarTag stringifyNumber, // (node) => string stringifyString, // (node, ctx, ...) => string toJS, // (value, arg, ctx) => any -- Recursively convert to plain JS diff --git a/package.json b/package.json index a026aab7..795dfc03 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "files": [ "browser/", "dist/", + "util.d.ts", "util.js" ], "type": "commonjs", diff --git a/src/index.ts b/src/index.ts index 50bd1b14..96281316 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ export { Composer } from './compose/composer.js' export { Document } from './doc/Document.js' export { Schema } from './schema/Schema.js' -export { YAMLError, YAMLParseError, YAMLWarning } from './errors.js' +export { ErrorCode, YAMLError, YAMLParseError, YAMLWarning } from './errors.js' export { Alias } from './nodes/Alias.js' export { @@ -16,7 +16,8 @@ export { isScalar, isSeq, Node, - ParsedNode + ParsedNode, + Range } from './nodes/Node.js' export { Pair } from './nodes/Pair.js' export { Scalar } from './nodes/Scalar.js' diff --git a/src/util.ts b/src/util.ts index 6ba8320e..954b0f7b 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,6 +1,9 @@ export { debug, LogLevelId, warn } from './log.js' export { findPair } from './nodes/YAMLMap.js' export { toJS, ToJSContext } from './nodes/toJS.js' +export { map as mapTag } from './schema/common/map.js' +export { seq as seqTag } from './schema/common/seq.js' +export { string as stringTag } from './schema/common/string.js' export { foldFlowLines } from './stringify/foldFlowLines' export { stringifyNumber } from './stringify/stringifyNumber.js' export { stringifyString } from './stringify/stringifyString.js' diff --git a/util.d.ts b/util.d.ts new file mode 100644 index 00000000..c656480d --- /dev/null +++ b/util.d.ts @@ -0,0 +1,3 @@ +// Workaround for incomplete exports support in TypeScript +// https://github.com/microsoft/TypeScript/issues/33079 +export * from './dist/util.js'