2019-11-18 14:39:32 +00:00
|
|
|
// Ported from js-yaml v3.13.1:
|
|
|
|
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
|
|
|
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
2024-01-01 21:11:32 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-03-18 12:36:00 +00:00
|
|
|
// This module is browser compatible.
|
2019-11-18 14:39:32 +00:00
|
|
|
|
|
|
|
export type KindType = "sequence" | "scalar" | "mapping";
|
2024-07-03 03:55:38 +00:00
|
|
|
/**
|
|
|
|
* The style variation for `styles` option of {@linkcode stringify}
|
|
|
|
*/
|
|
|
|
export type StyleVariant =
|
|
|
|
| "lowercase"
|
|
|
|
| "uppercase"
|
|
|
|
| "camelcase"
|
|
|
|
| "decimal"
|
|
|
|
| "binary"
|
|
|
|
| "octal"
|
2024-07-05 02:02:39 +00:00
|
|
|
| "hexadecimal";
|
2019-11-18 14:39:32 +00:00
|
|
|
|
2024-07-11 08:20:57 +00:00
|
|
|
export type RepresentFn<D> = (data: D, style?: StyleVariant) => string;
|
|
|
|
|
|
|
|
// deno-lint-ignore no-explicit-any
|
2024-07-17 04:30:32 +00:00
|
|
|
export interface Type<K extends KindType, D = any> {
|
2024-06-21 04:13:08 +00:00
|
|
|
tag: string;
|
2024-07-17 04:30:32 +00:00
|
|
|
kind: K;
|
2024-07-17 04:16:33 +00:00
|
|
|
predicate?: (data: unknown) => data is D;
|
2024-08-21 21:58:27 +00:00
|
|
|
represent?: RepresentFn<D> | Record<string, RepresentFn<D>>;
|
2024-06-21 04:13:08 +00:00
|
|
|
defaultStyle?: StyleVariant;
|
2024-07-09 09:22:53 +00:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2024-07-11 08:20:57 +00:00
|
|
|
resolve: (data: any) => boolean;
|
2024-07-09 09:22:53 +00:00
|
|
|
// deno-lint-ignore no-explicit-any
|
2024-07-11 08:20:57 +00:00
|
|
|
construct: (data: any) => D;
|
2019-11-18 14:39:32 +00:00
|
|
|
}
|