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.
Files changed (63) hide show
  1. package/dist/cjs/development/index.cjs +270 -270
  2. package/dist/cjs/development/index.cjs.map +3 -3
  3. package/dist/cjs/production/index.cjs +4 -4
  4. package/dist/esm/development/index.mjs +270 -270
  5. package/dist/esm/development/index.mjs.map +3 -3
  6. package/dist/esm/production/index.mjs +5 -5
  7. package/dist/types/core/Serializer.d.ts.map +1 -1
  8. package/dist/types/core/base-primitives.d.ts.map +1 -1
  9. package/dist/types/core/constants.d.ts +4 -4
  10. package/dist/types/core/constants.d.ts.map +1 -1
  11. package/dist/types/core/context/deserializer.d.ts +1 -1
  12. package/dist/types/core/context/deserializer.d.ts.map +1 -1
  13. package/dist/types/core/context/parser/async.d.ts +1 -1
  14. package/dist/types/core/context/parser/async.d.ts.map +1 -1
  15. package/dist/types/core/context/parser/stream.d.ts +2 -2
  16. package/dist/types/core/context/parser/stream.d.ts.map +1 -1
  17. package/dist/types/core/context/parser/sync.d.ts +3 -3
  18. package/dist/types/core/context/parser/sync.d.ts.map +1 -1
  19. package/dist/types/core/context/parser.d.ts.map +1 -1
  20. package/dist/types/core/context/serializer.d.ts +1 -1
  21. package/dist/types/core/context/serializer.d.ts.map +1 -1
  22. package/dist/types/core/cross/async.d.ts +1 -1
  23. package/dist/types/core/cross/async.d.ts.map +1 -1
  24. package/dist/types/core/cross/deserializer.d.ts +1 -1
  25. package/dist/types/core/cross/deserializer.d.ts.map +1 -1
  26. package/dist/types/core/cross/serializer.d.ts +1 -1
  27. package/dist/types/core/cross/serializer.d.ts.map +1 -1
  28. package/dist/types/core/errors.d.ts +1 -1
  29. package/dist/types/core/errors.d.ts.map +1 -1
  30. package/dist/types/core/plugin.d.ts +1 -1
  31. package/dist/types/core/plugin.d.ts.map +1 -1
  32. package/dist/types/core/tree/async.d.ts +1 -1
  33. package/dist/types/core/tree/async.d.ts.map +1 -1
  34. package/dist/types/core/tree/deserializer.d.ts +1 -1
  35. package/dist/types/core/tree/deserializer.d.ts.map +1 -1
  36. package/dist/types/core/tree/index.d.ts.map +1 -1
  37. package/dist/types/core/tree/serializer.d.ts +1 -1
  38. package/dist/types/core/tree/serializer.d.ts.map +1 -1
  39. package/dist/types/core/types.d.ts +1 -1
  40. package/dist/types/core/types.d.ts.map +1 -1
  41. package/package.json +4 -5
  42. package/src/core/Serializer.ts +5 -5
  43. package/src/core/base-primitives.ts +4 -4
  44. package/src/core/constants.ts +12 -12
  45. package/src/core/context/deserializer.ts +20 -20
  46. package/src/core/context/parser/async.ts +27 -27
  47. package/src/core/context/parser/stream.ts +5 -5
  48. package/src/core/context/parser/sync.ts +16 -16
  49. package/src/core/context/parser.ts +3 -3
  50. package/src/core/context/serializer.ts +24 -24
  51. package/src/core/cross/async.ts +1 -1
  52. package/src/core/cross/deserializer.ts +1 -1
  53. package/src/core/cross/serializer.ts +2 -2
  54. package/src/core/errors.ts +5 -2
  55. package/src/core/literals.ts +4 -4
  56. package/src/core/plugin.ts +1 -1
  57. package/src/core/reference.ts +2 -2
  58. package/src/core/stream.ts +2 -2
  59. package/src/core/tree/async.ts +1 -1
  60. package/src/core/tree/deserializer.ts +1 -1
  61. package/src/core/tree/index.ts +8 -2
  62. package/src/core/tree/serializer.ts +5 -5
  63. package/src/core/types.ts +2 -2
@@ -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 = false;
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 {
@@ -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
@@ -85,7 +85,10 @@ export async function toJSONAsync<T>(
85
85
  };
86
86
  }
87
87
 
88
- export function compileJSON(source: SerovalJSON, options: PluginAccessOptions = {}): string {
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>(source: SerovalJSON, options: PluginAccessOptions = {}): 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
@@ -1,9 +1,9 @@
1
1
  import type {
2
+ ErrorConstructorTag,
3
+ SerovalConstant,
2
4
  SerovalNodeType,
3
5
  SerovalObjectFlags,
4
- SerovalConstant,
5
6
  Symbols,
6
- ErrorConstructorTag,
7
7
  } from './constants';
8
8
  import type { SpecialReference } from './special-reference';
9
9