Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(encoding/yaml): Add support for JS types and user types #789

Merged
merged 3 commits into from
Mar 15, 2021
Merged

feat(encoding/yaml): Add support for JS types and user types #789

merged 3 commits into from
Mar 15, 2021

Conversation

lowlighter
Copy link
Contributor

This extends current YAML support with an EXTENDED_SCHEMA which supports !!js/regexp, !!js/function and !!js/undefined to remove current Deno limitation (heavily based on nodeca/js-yaml-js-types but reworked a bit to be more succint).

This also exposes the Type function (which is already implemented but not available to end-users) to allow the creation of custom types with !tags as defined in YAML spec.

};

const expected = `regexp:
simple: !<tag:yaml.org,2002:js/regexp> /foobar/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so unfortunately, in js-yaml 3 (ported version of Deno), custom tags were dumped with !<tag:yaml.orf,2022:..>, and it has been fixed in v4 (nodeca/js-yaml@a0d0caa)

it does works though, it's just the display which is a bit more verbose and less pretty

@lowlighter lowlighter requested a review from kt3k March 10, 2021 19:10

Deno.test({
name:
"`!!js/*` yaml types are correctly handled with extended schema while stringifying",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice test!

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests look very well (It has 81% diff coverage ref: https://github.com/denoland/deno_std/pull/789/checks?check_run_id=2079608904)

LGTM

@kt3k kt3k merged commit 46fc705 into denoland:main Mar 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants