seroval 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/development/index.cjs +270 -270
- package/dist/cjs/development/index.cjs.map +3 -3
- package/dist/cjs/production/index.cjs +4 -4
- package/dist/esm/development/index.mjs +270 -270
- package/dist/esm/development/index.mjs.map +3 -3
- package/dist/esm/production/index.mjs +5 -5
- package/dist/types/core/Serializer.d.ts.map +1 -1
- package/dist/types/core/base-primitives.d.ts.map +1 -1
- package/dist/types/core/constants.d.ts +4 -4
- package/dist/types/core/constants.d.ts.map +1 -1
- package/dist/types/core/context/deserializer.d.ts +1 -1
- package/dist/types/core/context/deserializer.d.ts.map +1 -1
- package/dist/types/core/context/parser/async.d.ts +1 -1
- package/dist/types/core/context/parser/async.d.ts.map +1 -1
- package/dist/types/core/context/parser/stream.d.ts +2 -2
- package/dist/types/core/context/parser/stream.d.ts.map +1 -1
- package/dist/types/core/context/parser/sync.d.ts +3 -3
- package/dist/types/core/context/parser/sync.d.ts.map +1 -1
- package/dist/types/core/context/parser.d.ts.map +1 -1
- package/dist/types/core/context/serializer.d.ts +1 -1
- package/dist/types/core/context/serializer.d.ts.map +1 -1
- package/dist/types/core/cross/async.d.ts +1 -1
- package/dist/types/core/cross/async.d.ts.map +1 -1
- package/dist/types/core/cross/deserializer.d.ts +1 -1
- package/dist/types/core/cross/deserializer.d.ts.map +1 -1
- package/dist/types/core/cross/serializer.d.ts +1 -1
- package/dist/types/core/cross/serializer.d.ts.map +1 -1
- package/dist/types/core/errors.d.ts +1 -1
- package/dist/types/core/errors.d.ts.map +1 -1
- package/dist/types/core/plugin.d.ts +1 -1
- package/dist/types/core/plugin.d.ts.map +1 -1
- package/dist/types/core/tree/async.d.ts +1 -1
- package/dist/types/core/tree/async.d.ts.map +1 -1
- package/dist/types/core/tree/deserializer.d.ts +1 -1
- package/dist/types/core/tree/deserializer.d.ts.map +1 -1
- package/dist/types/core/tree/index.d.ts.map +1 -1
- package/dist/types/core/tree/serializer.d.ts +1 -1
- package/dist/types/core/tree/serializer.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +1 -1
- package/dist/types/core/types.d.ts.map +1 -1
- package/package.json +4 -5
- package/src/core/Serializer.ts +5 -5
- package/src/core/base-primitives.ts +4 -4
- package/src/core/constants.ts +12 -12
- package/src/core/context/deserializer.ts +20 -20
- package/src/core/context/parser/async.ts +27 -27
- package/src/core/context/parser/stream.ts +5 -5
- package/src/core/context/parser/sync.ts +16 -16
- package/src/core/context/parser.ts +3 -3
- package/src/core/context/serializer.ts +24 -24
- package/src/core/cross/async.ts +1 -1
- package/src/core/cross/deserializer.ts +1 -1
- package/src/core/cross/serializer.ts +2 -2
- package/src/core/errors.ts +5 -2
- package/src/core/literals.ts +4 -4
- package/src/core/plugin.ts +1 -1
- package/src/core/reference.ts +2 -2
- package/src/core/stream.ts +2 -2
- package/src/core/tree/async.ts +1 -1
- package/src/core/tree/deserializer.ts +1 -1
- package/src/core/tree/index.ts +8 -2
- package/src/core/tree/serializer.ts +5 -5
- package/src/core/types.ts +2 -2
package/src/core/stream.ts
CHANGED
|
@@ -25,7 +25,7 @@ export function createStream<T>(): Stream<T> {
|
|
|
25
25
|
const listeners = new Set<StreamListener<T>>();
|
|
26
26
|
const buffer: unknown[] = [];
|
|
27
27
|
let alive = true;
|
|
28
|
-
let success =
|
|
28
|
+
let success = true;
|
|
29
29
|
|
|
30
30
|
function flushNext(value: T): void {
|
|
31
31
|
for (const listener of listeners.keys()) {
|
|
@@ -53,7 +53,7 @@ export function createStream<T>(): Stream<T> {
|
|
|
53
53
|
}
|
|
54
54
|
for (let i = 0, len = buffer.length; i < len; i++) {
|
|
55
55
|
const value = buffer[i];
|
|
56
|
-
if (i === len - 1) {
|
|
56
|
+
if (i === len - 1 && !alive) {
|
|
57
57
|
if (success) {
|
|
58
58
|
listener.return(value as T);
|
|
59
59
|
} else {
|
package/src/core/tree/async.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import BaseAsyncParserContext from '../context/parser/async';
|
|
2
1
|
import type { BaseParserContextOptions } from '../context/parser';
|
|
2
|
+
import BaseAsyncParserContext from '../context/parser/async';
|
|
3
3
|
import type { SerovalMode } from '../plugin';
|
|
4
4
|
|
|
5
5
|
export type AsyncParserContextOptions = Omit<BaseParserContextOptions, 'refs'>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import BaseDeserializerContext from '../context/deserializer';
|
|
2
1
|
import type { BaseDeserializerOptions } from '../context/deserializer';
|
|
2
|
+
import BaseDeserializerContext from '../context/deserializer';
|
|
3
3
|
import type { SerovalMode } from '../plugin';
|
|
4
4
|
|
|
5
5
|
export interface VanillaDeserializerContextOptions
|
package/src/core/tree/index.ts
CHANGED
|
@@ -85,7 +85,10 @@ export async function toJSONAsync<T>(
|
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
export function compileJSON(
|
|
88
|
+
export function compileJSON(
|
|
89
|
+
source: SerovalJSON,
|
|
90
|
+
options: PluginAccessOptions = {},
|
|
91
|
+
): string {
|
|
89
92
|
const plugins = resolvePlugins(options.plugins);
|
|
90
93
|
const ctx = new VanillaSerializerContext({
|
|
91
94
|
plugins,
|
|
@@ -95,7 +98,10 @@ export function compileJSON(source: SerovalJSON, options: PluginAccessOptions =
|
|
|
95
98
|
return ctx.serializeTop(source.t);
|
|
96
99
|
}
|
|
97
100
|
|
|
98
|
-
export function fromJSON<T>(
|
|
101
|
+
export function fromJSON<T>(
|
|
102
|
+
source: SerovalJSON,
|
|
103
|
+
options: PluginAccessOptions = {},
|
|
104
|
+
): T {
|
|
99
105
|
const plugins = resolvePlugins(options.plugins);
|
|
100
106
|
const ctx = new VanillaDeserializerContext({
|
|
101
107
|
plugins,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { SerovalNodeType } from '../constants';
|
|
2
|
+
import type { BaseSerializerContextOptions } from '../context/serializer';
|
|
3
|
+
import BaseSerializerContext from '../context/serializer';
|
|
4
|
+
import { SerovalUnsupportedNodeError } from '../errors';
|
|
5
|
+
import type { SerovalMode } from '../plugin';
|
|
1
6
|
import type {
|
|
2
7
|
SerovalNode,
|
|
3
8
|
SerovalPromiseConstructorNode,
|
|
4
9
|
SerovalPromiseRejectNode,
|
|
5
10
|
SerovalPromiseResolveNode,
|
|
6
11
|
} from '../types';
|
|
7
|
-
import type { BaseSerializerContextOptions } from '../context/serializer';
|
|
8
|
-
import BaseSerializerContext from '../context/serializer';
|
|
9
12
|
import getIdentifier from '../utils/get-identifier';
|
|
10
|
-
import type { SerovalMode } from '../plugin';
|
|
11
|
-
import { SerovalNodeType } from '../constants';
|
|
12
|
-
import { SerovalUnsupportedNodeError } from '../errors';
|
|
13
13
|
|
|
14
14
|
export type VanillaSerializerContextOptions = BaseSerializerContextOptions;
|
|
15
15
|
|
package/src/core/types.ts
CHANGED