Skip to content

Commit

Permalink
Remove cross JSON methods
Browse files Browse the repository at this point in the history
  • Loading branch information
lxsmnsyc committed Sep 8, 2023
1 parent a9bffac commit b6f3728
Showing 1 changed file with 36 additions and 36 deletions.
72 changes: 36 additions & 36 deletions packages/seroval/src/core/cross/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Feature } from '../compat';
import {
ROOT_REFERENCE,
} from '../keys';
import type { SerovalNode } from '../types';
// import type { SerovalNode } from '../types';
import parseAsync from './async';
import type {
CrossParserContextOptions,
Expand Down Expand Up @@ -73,44 +73,44 @@ export async function crossSerializeAsync<T>(
);
}

export interface SerovalCrossJSON {
t: SerovalNode;
f: number;
}
// export interface SerovalCrossJSON {
// t: SerovalNode;
// f: number;
// }

export function toCrossJSON<T>(
source: T,
options?: CrossParserContextOptions,
): SerovalCrossJSON {
const ctx = createCrossParserContext(options);
return {
t: parseSync(ctx, source),
f: ctx.features,
};
}
// export function toCrossJSON<T>(
// source: T,
// options?: CrossParserContextOptions,
// ): SerovalCrossJSON {
// const ctx = createCrossParserContext(options);
// return {
// t: parseSync(ctx, source),
// f: ctx.features,
// };
// }

export async function toCrossJSONAsync<T>(
source: T,
options?: CrossParserContextOptions,
): Promise<SerovalCrossJSON> {
const ctx = createCrossParserContext(options);
return {
t: await parseAsync(ctx, source),
f: ctx.features,
};
}
// export async function toCrossJSONAsync<T>(
// source: T,
// options?: CrossParserContextOptions,
// ): Promise<SerovalCrossJSON> {
// const ctx = createCrossParserContext(options);
// return {
// t: await parseAsync(ctx, source),
// f: ctx.features,
// };
// }

export function compileCrossJSON(source: SerovalCrossJSON): string {
const serial = createCrossSerializerContext({
features: source.f,
});
const result = crossSerializeTree(serial, source.t);
return finalize(
serial,
source.t.i,
result,
);
}
// export function compileCrossJSON(source: SerovalCrossJSON): string {
// const serial = createCrossSerializerContext({
// features: source.f,
// });
// const result = crossSerializeTree(serial, source.t);
// return finalize(
// serial,
// source.t.i,
// result,
// );
// }

// export function fromJSON<T>(source: SerovalJSON): T {
// const serial = createDeserializerContext({
Expand Down

0 comments on commit b6f3728

Please sign in to comment.