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

refactor(yaml): remove State class #5275

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions yaml/_dumper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import {
VERTICAL_LINE,
} from "./_chars.ts";
import { YamlError } from "./_error.ts";
import type { Schema } from "./_schema.ts";
import { State } from "./_state.ts";
import { DEFAULT_SCHEMA, type Schema } from "./_schema.ts";
import type { RepresentFn, StyleVariant, Type } from "./_type.ts";
import * as common from "./_utils.ts";

Expand Down Expand Up @@ -146,7 +145,8 @@ export interface DumperStateOptions {
condenseFlow?: boolean;
}

export class DumperState extends State {
export class DumperState {
schema: Schema;
indent: number;
noArrayIndent: boolean;
skipInvalid: boolean;
Expand All @@ -166,7 +166,7 @@ export class DumperState extends State {
dump: Any;

constructor({
schema,
schema = DEFAULT_SCHEMA,
indent = 2,
noArrayIndent = false,
skipInvalid = false,
Expand All @@ -178,7 +178,7 @@ export class DumperState extends State {
noCompatMode = false,
condenseFlow = false,
}: DumperStateOptions) {
super(schema);
this.schema = schema;
this.indent = Math.max(1, indent);
this.noArrayIndent = noArrayIndent;
this.skipInvalid = skipInvalid;
Expand Down
10 changes: 5 additions & 5 deletions yaml/_loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import {
} from "./_chars.ts";
import { YamlError } from "./_error.ts";
import { Mark } from "./_mark.ts";
import type { Schema, TypeMap } from "./_schema.ts";
import { State } from "./_state.ts";
import { DEFAULT_SCHEMA, type Schema, type TypeMap } from "./_schema.ts";
import type { Type } from "./_type.ts";
import * as common from "./_utils.ts";

Expand Down Expand Up @@ -72,7 +71,8 @@ interface LoaderStateOptions {
// deno-lint-ignore no-explicit-any
type ResultType = any[] | Record<string, any> | string;

class LoaderState extends State {
class LoaderState {
schema: Schema;
input: string;
length: number;
lineIndent = 0;
Expand All @@ -96,12 +96,12 @@ class LoaderState extends State {
constructor(
input: string,
{
schema,
schema = DEFAULT_SCHEMA,
onWarning,
json = false,
}: LoaderStateOptions,
) {
super(schema);
this.schema = schema;
this.input = input;
this.onWarning = onWarning;
this.json = json;
Expand Down
13 changes: 0 additions & 13 deletions yaml/_state.ts

This file was deleted.