seroval 1.7.6 → 1.7.8

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/index.cjs CHANGED
@@ -8,7 +8,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
8
8
  let Feature = /* @__PURE__ */ function(Feature) {
9
9
  Feature[Feature["AggregateError"] = 1] = "AggregateError";
10
10
  /**
11
- * @deprecated Has no effect. Output always uses arrow functions.
11
+ * @deprecated Has no effect. Output follows the syntax of the build seroval
12
+ * runs in: arrow functions, or `function` expressions in an ES5 build.
12
13
  */
13
14
  Feature[Feature["ArrowFunction"] = 2] = "ArrowFunction";
14
15
  Feature[Feature["ErrorPrototypeStack"] = 4] = "ErrorPrototypeStack";
@@ -166,7 +167,8 @@ function escapeCharCode(code) {
166
167
  default: return;
167
168
  }
168
169
  }
169
- function serializeString(str) {
170
+ function serializeString(input) {
171
+ const str = "" + input;
170
172
  if (!NEEDS_ESCAPE.test(str)) return str;
171
173
  if (str.length >= MIN_JSON_STRINGIFY_LENGTH && !JSON_ESCAPE_DIFFERENCES.test(str)) {
172
174
  let result = JSON.stringify(str).slice(1, -1);
@@ -390,6 +392,30 @@ function getTypedArrayName(value) {
390
392
  if (!typedArrayNameGetter) typedArrayNameGetter = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Int8Array.prototype), Symbol.toStringTag).get;
391
393
  return typedArrayNameGetter.call(value);
392
394
  }
395
+ let typedArrayGetters;
396
+ let dataViewGetters;
397
+ function getAccessor(proto, key) {
398
+ return Object.getOwnPropertyDescriptor(proto, key).get;
399
+ }
400
+ function getViewGetters(proto, lengthKey) {
401
+ return {
402
+ buffer: getAccessor(proto, "buffer"),
403
+ byteOffset: getAccessor(proto, "byteOffset"),
404
+ byteLength: getAccessor(proto, "byteLength"),
405
+ length: getAccessor(proto, lengthKey)
406
+ };
407
+ }
408
+ function readArrayBufferView(value, isDataView) {
409
+ let getters;
410
+ if (isDataView) getters = dataViewGetters ?? (dataViewGetters = getViewGetters(DataView.prototype, "byteLength"));
411
+ else getters = typedArrayGetters ?? (typedArrayGetters = getViewGetters(Object.getPrototypeOf(Int8Array.prototype), "length"));
412
+ return {
413
+ buffer: getters.buffer.call(value),
414
+ byteOffset: getters.byteOffset.call(value),
415
+ byteLength: getters.byteLength.call(value),
416
+ length: getters.length.call(value)
417
+ };
418
+ }
393
419
  //#endregion
394
420
  //#region src/core/base-primitives.ts
395
421
  function createNumberNode(value) {
@@ -410,12 +436,14 @@ function createBigIntNode(current) {
410
436
  function createIndexedValueNode(id) {
411
437
  return createSerovalNode(4, id);
412
438
  }
439
+ const getDateTime = Date.prototype.getTime;
440
+ const getDateISOString = Date.prototype.toISOString;
413
441
  function createDateNode(id, current) {
414
- const timestamp = current.valueOf();
415
- return createSerovalNode(5, id, timestamp === timestamp ? current.toISOString() : "");
442
+ const timestamp = getDateTime.call(current);
443
+ return createSerovalNode(5, id, timestamp === timestamp ? getDateISOString.call(current) : "");
416
444
  }
417
- function createTemporalNode(id, type, current) {
418
- return createSerovalNode(36, id, current.toString(), type);
445
+ function createTemporalNode(id, type, temporalClass, current) {
446
+ return createSerovalNode(36, id, temporalClass.prototype.toString.call(current), type);
419
447
  }
420
448
  const getRegExpSource = Object.getOwnPropertyDescriptor(RegExp.prototype, "source").get;
421
449
  const getRegExpFlags = Object.getOwnPropertyDescriptor(RegExp.prototype, "flags").get;
@@ -438,11 +466,11 @@ function createBoxedNode(id, boxed) {
438
466
  return createSerovalNode(21, id, void 0, void 0, void 0, void 0, void 0, void 0, boxed);
439
467
  }
440
468
  const MAX_TYPED_ARRAY_LENGTH = 1e6;
441
- function createViewNode(type, id, current, buffer) {
469
+ function createViewNode(type, id, current, view, buffer) {
442
470
  const isDataView = type === 20;
443
- const size = isDataView ? current.byteLength : current.length;
471
+ const size = view.length;
444
472
  if (size > MAX_TYPED_ARRAY_LENGTH) throw new SerovalUnsupportedTypeError(current);
445
- return createSerovalNode(type, id, void 0, isDataView ? void 0 : getTypedArrayName(current), void 0, void 0, void 0, void 0, buffer, current.byteOffset, void 0, size);
473
+ return createSerovalNode(type, id, void 0, isDataView ? void 0 : getTypedArrayName(current), void 0, void 0, void 0, void 0, buffer, view.byteOffset, void 0, size);
446
474
  }
447
475
  function createErrorNode(type, id, current, options) {
448
476
  return createSerovalNode(type, id, getErrorConstructor(current), void 0, serializeString(current.message), options);
@@ -464,8 +492,9 @@ function createSequenceNode(id, sequence, throwAt, doneAt) {
464
492
  }
465
493
  //#endregion
466
494
  //#region src/core/live-stream.ts
495
+ const BRAND = /* @__PURE__ */ Symbol("LiveStream");
467
496
  function isLiveStream(value) {
468
- return value instanceof LiveStream;
497
+ return value != null && value[BRAND] === true;
469
498
  }
470
499
  /**
471
500
  * A single-consumer stream for incremental serialization. Unlike
@@ -473,11 +502,12 @@ function isLiveStream(value) {
473
502
  * producer operation that sent it settles only when the consumer accepts it.
474
503
  *
475
504
  * An internal class rather than a tagged POJO: identity is checked with
476
- * `instanceof`, which untrusted input cannot forge. The class is exported
505
+ * `isLiveStream`, which untrusted input cannot forge. The class is exported
477
506
  * because bundlers cannot drop an unexported top-level class.
478
507
  */
479
508
  var LiveStream = class {
480
509
  constructor(options) {
510
+ this[BRAND] = true;
481
511
  this.consumed = false;
482
512
  this.closed = false;
483
513
  this.cancelled = false;
@@ -1279,12 +1309,12 @@ function getTemporalType(currentClass) {
1279
1309
  }
1280
1310
  }
1281
1311
  function getObjectClass(current) {
1282
- const currentClass = current.constructor;
1283
- if (typeof currentClass !== "function") {
1284
- const proto = Object.getPrototypeOf(current);
1285
- return proto === null ? void 0 : proto.constructor;
1286
- }
1287
- return currentClass;
1312
+ const proto = Object.getPrototypeOf(current);
1313
+ if (proto === null) return void 0;
1314
+ if (proto === Object.prototype) return Object;
1315
+ const currentClass = proto.constructor;
1316
+ if (typeof currentClass !== "function" || currentClass === Object || currentClass.prototype === proto) return currentClass;
1317
+ return proto;
1288
1318
  }
1289
1319
  /**
1290
1320
  * Decides how an object is parsed. Shared by the sync, stream and async
@@ -1348,10 +1378,14 @@ function createMapNode(id, sentinel, k, v) {
1348
1378
  function createPromiseConstructorNode(ctx, id, resolver) {
1349
1379
  return createSerovalNode(22, id, resolver, void 0, void 0, void 0, void 0, void 0, parseSpecialReference(ctx, 1));
1350
1380
  }
1351
- function getArrayBufferView(ctx, current) {
1352
- if (!ctx.compactArrayBufferViews) return current;
1353
- const buffer = new Uint8Array(current.buffer, current.byteOffset, current.byteLength).slice().buffer;
1354
- return new (current instanceof DataView ? DataView : getTypedArrayConstructor(getTypedArrayName(current)))(buffer);
1381
+ function getArrayBufferView(ctx, view) {
1382
+ if (!ctx.compactArrayBufferViews) return view;
1383
+ return {
1384
+ buffer: new Uint8Array(view.buffer, view.byteOffset, view.byteLength).slice().buffer,
1385
+ byteOffset: 0,
1386
+ byteLength: view.byteLength,
1387
+ length: view.length
1388
+ };
1355
1389
  }
1356
1390
  function createArrayBufferNode(ctx, id, current) {
1357
1391
  return createSerovalNode(19, id, encodeArrayBuffer(current), void 0, void 0, void 0, void 0, void 0, parseSpecialReference(ctx, 5));
@@ -1409,11 +1443,12 @@ async function parsePlainObject$1(ctx, depth, id, current, empty) {
1409
1443
  return createObjectNode(id, current, empty, await parseProperties$1(ctx, depth, current));
1410
1444
  }
1411
1445
  async function parseBoxed$1(ctx, depth, id, current) {
1412
- return createBoxedNode(id, await parseAsync(ctx, depth, current.valueOf()));
1446
+ const node = parseValueAsync(ctx, depth, current.valueOf());
1447
+ return createBoxedNode(id, node instanceof Promise ? await node : node);
1413
1448
  }
1414
1449
  async function parseView$1(ctx, depth, type, id, current) {
1415
- current = getArrayBufferView(ctx.base, current);
1416
- return createViewNode(type, id, current, await parseAsync(ctx, depth, current.buffer));
1450
+ const view = getArrayBufferView(ctx.base, readArrayBufferView(current, type === 20));
1451
+ return createViewNode(type, id, current, view, await parseAsync(ctx, depth, view.buffer));
1417
1452
  }
1418
1453
  async function parseError$1(ctx, depth, type, id, current) {
1419
1454
  const options = getErrorOptions(current, ctx.base.features);
@@ -1518,14 +1553,13 @@ async function parseAsyncIterable$1(ctx, depth, current) {
1518
1553
  const sequence = [];
1519
1554
  for (;;) {
1520
1555
  let result;
1556
+ markParserRef(ctx.base, id);
1521
1557
  try {
1522
1558
  result = await iterator.next();
1523
1559
  } catch (error) {
1524
- markParserRef(ctx.base, id);
1525
1560
  sequence.push(createStreamEventNode(33, id, await parseAsync(ctx, depth, error)));
1526
1561
  break;
1527
1562
  }
1528
- markParserRef(ctx.base, id);
1529
1563
  let parsed;
1530
1564
  try {
1531
1565
  parsed = await parseAsync(ctx, depth, result.value);
@@ -1570,7 +1604,7 @@ async function parseObjectAsync(ctx, depth, id, current) {
1570
1604
  case 12: return parseSet$1(ctx, depth, id, current);
1571
1605
  case 13: return parsePromise$1(ctx, depth, id, current);
1572
1606
  case 14: return createRegExpNode(id, current);
1573
- case 15: return createTemporalNode(id, getTemporalType(currentClass), current);
1607
+ case 15: return createTemporalNode(id, getTemporalType(currentClass), currentClass, current);
1574
1608
  case 16: return parsePlainObject$1(ctx, depth, id, current, !!currentClass);
1575
1609
  default: throw new SerovalUnsupportedTypeError(current);
1576
1610
  }
@@ -2226,10 +2260,6 @@ function createObjectAssign(ctx, ref, key, value) {
2226
2260
  function createSequenceAssign(ctx, ref, index, value) {
2227
2261
  createAssignment(ctx.base, getRefParam(ctx, ref) + ".v[" + index + "]", value);
2228
2262
  }
2229
- /**
2230
- * Checks if the value is in the stack. Stack here is a reference
2231
- * structure to know if a object is to be accessed in a TDZ.
2232
- */
2233
2263
  function getKeyKind(key) {
2234
2264
  const first = key.charCodeAt(0);
2235
2265
  if (first >= 48 && first <= 57) {
@@ -2239,6 +2269,10 @@ function getKeyKind(key) {
2239
2269
  if (key === "Infinity") return 2;
2240
2270
  return isValidIdentifier(key) ? 1 : 0;
2241
2271
  }
2272
+ /**
2273
+ * Checks if the value is in the stack. Stack here is a reference
2274
+ * structure to know if a object is to be accessed in a TDZ.
2275
+ */
2242
2276
  function isIndexedValueInStack(ctx, node) {
2243
2277
  return node.t === 4 && ctx.stack.includes(node.i);
2244
2278
  }
@@ -2317,8 +2351,7 @@ function serializeProperty(ctx, source, key, val) {
2317
2351
  if (isIndexedValueInStack(ctx.base, val)) {
2318
2352
  const refParam = getRefParam(ctx, val.i);
2319
2353
  markSerializerRef(ctx.base, source.i);
2320
- if (kind === 1) createObjectAssign(ctx, source.i, key, refParam);
2321
- else createArrayAssign(ctx, source.i, kind === 2 ? key : "\"" + key + "\"", refParam);
2354
+ createKeyAssign(ctx, source.i, kind, key, refParam);
2322
2355
  return "";
2323
2356
  }
2324
2357
  if (key !== "__proto__") return (kind === 0 ? "\"" + key + "\"" : key) + ":" + serialize$1(ctx, val);
@@ -2406,10 +2439,10 @@ function serializeNullConstructor(ctx, node) {
2406
2439
  return serializeDictionary(ctx, node, NULL_CONSTRUCTOR);
2407
2440
  }
2408
2441
  function serializeDate(node) {
2409
- return "new Date(\"" + node.s + "\")";
2442
+ return "new Date(\"" + serializeString(node.s) + "\")";
2410
2443
  }
2411
2444
  function serializeTemporal(ctx, node) {
2412
- if (ctx.base.features & 64) return "Temporal." + TEMPORAL_TYPE_NAME[node.c] + ".from(\"" + node.s + "\")";
2445
+ if (ctx.base.features & 64) return "Temporal." + TEMPORAL_TYPE_NAME[node.c] + ".from(\"" + serializeString(node.s) + "\")";
2413
2446
  throw new SerovalUnsupportedNodeError(node);
2414
2447
  }
2415
2448
  function serializeRegExp(ctx, node) {
@@ -2523,7 +2556,7 @@ function serializeArrayBuffer(ctx, node) {
2523
2556
  return getConstructor(ctx, node.f) + "(\"" + node.s + "\")";
2524
2557
  }
2525
2558
  function serializeView(ctx, node) {
2526
- return "new " + (node.t === 20 ? "DataView" : node.c) + "(" + serialize$1(ctx, node.f) + "," + node.b + "," + node.l + ")";
2559
+ return "new " + (node.t === 20 ? "DataView" : node.c) + "(" + serialize$1(ctx, node.f) + "," + +node.b + "," + +node.l + ")";
2527
2560
  }
2528
2561
  function serializeAggregateError(ctx, node) {
2529
2562
  const id = node.i;
@@ -2642,7 +2675,7 @@ function serializeSequence(ctx, node) {
2642
2675
  result += (item && result && ",") + item;
2643
2676
  }
2644
2677
  ctx.base.stack.pop();
2645
- if (result) return "{__SEROVAL_SEQUENCE__:!0,v:[" + result + "],t:" + node.s + ",d:" + node.l + "}";
2678
+ if (result) return "{__SEROVAL_SEQUENCE__:!0,v:[" + result + "],t:" + +node.s + ",d:" + +node.l + "}";
2646
2679
  }
2647
2680
  return "{__SEROVAL_SEQUENCE__:!0,v:[],t:-1,d:0}";
2648
2681
  }
@@ -2721,19 +2754,17 @@ function serializeCross(ctx, tree) {
2721
2754
  if (id == null) return result;
2722
2755
  const patches = resolvePatches(ctx.base);
2723
2756
  const ref = getRefParam(ctx, id);
2724
- const scopeId = ctx.state.scopeId;
2725
- const params = scopeId == null ? "" : "$R";
2726
2757
  let body = result;
2727
2758
  if (patches) {
2728
2759
  if (!ctx.base.assignAll && !result.startsWith(ref + "=")) body = ref + "=" + result;
2729
2760
  body = "(" + body + "," + patches + ref + ")";
2730
2761
  }
2731
- if (params === "") {
2762
+ const scopeId = ctx.state.scopeId;
2763
+ if (scopeId == null) {
2732
2764
  if (tree.t === 10 && !patches) return "(" + body + ")";
2733
2765
  return body;
2734
2766
  }
2735
- const args = scopeId == null ? "()" : "($R[\"" + serializeString(scopeId) + "\"])";
2736
- return "(" + createFunction([params], body) + ")" + args;
2767
+ return "(" + createFunction(["$R"], body) + ")($R[\"" + serializeString(scopeId) + "\"])";
2737
2768
  }
2738
2769
  function wrapSerializationError(error) {
2739
2770
  return error instanceof SerovalSerializationError ? error : new SerovalSerializationError(error);
@@ -2815,8 +2846,8 @@ function parseBoxed(ctx, depth, id, current) {
2815
2846
  return createBoxedNode(id, parseSOS(ctx, depth, current.valueOf()));
2816
2847
  }
2817
2848
  function parseView(ctx, depth, type, id, current) {
2818
- current = getArrayBufferView(ctx.base, current);
2819
- return createViewNode(type, id, current, parseSOS(ctx, depth, current.buffer));
2849
+ const view = getArrayBufferView(ctx.base, readArrayBufferView(current, type === 20));
2850
+ return createViewNode(type, id, current, view, parseSOS(ctx, depth, view.buffer));
2820
2851
  }
2821
2852
  function parseError(ctx, depth, type, id, current) {
2822
2853
  const options = getErrorOptions(current, ctx.base.features);
@@ -2907,14 +2938,15 @@ function parseObjectPhase2(ctx, depth, id, current, currentClass) {
2907
2938
  case 12: return parseSet(ctx, depth, id, current);
2908
2939
  case 13: return parsePromise(ctx, depth, id, current);
2909
2940
  case 14: return createRegExpNode(id, current);
2910
- case 15: return createTemporalNode(id, getTemporalType(currentClass), current);
2941
+ case 15: return createTemporalNode(id, getTemporalType(currentClass), currentClass, current);
2911
2942
  case 16: return parsePlainObject(ctx, depth, id, current, !!currentClass);
2912
2943
  default: throw new SerovalUnsupportedTypeError(current);
2913
2944
  }
2914
2945
  }
2915
2946
  function parseObject(ctx, depth, id, current) {
2916
2947
  if (Array.isArray(current)) return parseArray(ctx, depth, id, current);
2917
- if (isStream(current)) return isLiveStream(current) ? parseLiveStream(ctx, depth, id, current) : parseStream(ctx, depth, id, current);
2948
+ if (isLiveStream(current)) return parseLiveStream(ctx, depth, id, current);
2949
+ if (current instanceof Stream) return parseStream(ctx, depth, id, current);
2918
2950
  if (isSequence(current)) return parseSequence(ctx, depth, id, current);
2919
2951
  const currentClass = getObjectClass(current);
2920
2952
  if (currentClass === OpaqueReference) return parseSOS(ctx, depth, current.replacement);
@@ -3094,7 +3126,7 @@ function consumeLiveStream(ctx, depth, id, current) {
3094
3126
  });
3095
3127
  }
3096
3128
  function wrapPromiseResult(ctx, type, id, node) {
3097
- return createSerovalNode(type, id, void 0, void 0, void 0, void 0, void 0, [parseSpecialReference(ctx.base, type === 23 ? 2 : 3), node], void 0, void 0, void 0, void 0);
3129
+ return createSerovalNode(type, id, void 0, void 0, void 0, void 0, void 0, [parseSpecialReference(ctx.base, type === 23 ? 2 : 3), node]);
3098
3130
  }
3099
3131
  function handlePromise(type, id, depth, data) {
3100
3132
  if (this.state.alive) parseEvent(this, depth, data, wrapPromiseResult.bind(null, this, type, id), void 0);
@@ -3156,6 +3188,7 @@ function createStreamParserState(options) {
3156
3188
  writing: false,
3157
3189
  inFlight: void 0,
3158
3190
  reason: void 0,
3191
+ starting: false,
3159
3192
  onParse: options.onParse,
3160
3193
  onError: options.onError,
3161
3194
  onDone: options.onDone,
@@ -3284,25 +3317,30 @@ function startStreamParse(ctx, current) {
3284
3317
  const state = ctx.state;
3285
3318
  let parsed;
3286
3319
  let failure;
3287
- state.parsing++;
3320
+ state.starting = true;
3288
3321
  try {
3289
- parsed = parseSOS(ctx, 0, current);
3290
- } catch (error) {
3291
- failure = { value: error };
3322
+ state.parsing++;
3323
+ try {
3324
+ parsed = parseSOS(ctx, 0, current);
3325
+ } catch (error) {
3326
+ failure = { value: error };
3327
+ } finally {
3328
+ state.parsing--;
3329
+ if (!state.alive) releaseParserValues(ctx);
3330
+ }
3331
+ if (failure) {
3332
+ if (state.alive) stopStreamParse(ctx, 1, failure.value);
3333
+ else throw failure.value;
3334
+ } else if (parsed && state.alive) {
3335
+ state.queue.unshift({
3336
+ node: parsed,
3337
+ initial: true,
3338
+ accept: void 0
3339
+ });
3340
+ drainOutput(ctx);
3341
+ }
3292
3342
  } finally {
3293
- state.parsing--;
3294
- if (!state.alive) releaseParserValues(ctx);
3295
- }
3296
- if (failure) {
3297
- if (state.alive) stopStreamParse(ctx, 1, failure.value);
3298
- else throw failure.value;
3299
- } else if (parsed && state.alive) {
3300
- state.queue.unshift({
3301
- node: parsed,
3302
- initial: true,
3303
- accept: void 0
3304
- });
3305
- drainOutput(ctx);
3343
+ state.starting = false;
3306
3344
  }
3307
3345
  }
3308
3346
  function runCleanups(state) {
@@ -3353,7 +3391,7 @@ function stopStreamParse(ctx, mode, reason) {
3353
3391
  try {
3354
3392
  if (mode === 1) {
3355
3393
  if (onError) onError(reason);
3356
- else throw reason;
3394
+ else if (state.starting) throw reason;
3357
3395
  } else if (mode === 0) onDone?.();
3358
3396
  } catch (error) {
3359
3397
  failure = { value: error };
@@ -3520,6 +3558,7 @@ var Serializer = class {
3520
3558
  if (this.alive && !this.flushed && options) {
3521
3559
  this.pending++;
3522
3560
  this.keys.add(key);
3561
+ let starting = true;
3523
3562
  const cleanup = crossSerializeStream(value, {
3524
3563
  plugins: this.plugins,
3525
3564
  scopeId: options.scopeId,
@@ -3531,7 +3570,7 @@ var Serializer = class {
3531
3570
  let failure;
3532
3571
  try {
3533
3572
  if (options.onError) options.onError(error);
3534
- else throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
3573
+ else if (starting) throw error instanceof SerovalParserError ? error : new SerovalParserError(error);
3535
3574
  } catch (handlerError) {
3536
3575
  failure = { value: handlerError };
3537
3576
  }
@@ -3550,6 +3589,7 @@ var Serializer = class {
3550
3589
  this.finishWrite();
3551
3590
  }
3552
3591
  });
3592
+ starting = false;
3553
3593
  if (this.alive) this.cleanups.push(cleanup);
3554
3594
  else cleanup();
3555
3595
  }
package/dist/index.d.cts CHANGED
@@ -7,7 +7,8 @@
7
7
  export declare enum Feature {
8
8
  AggregateError = 1,
9
9
  /**
10
- * @deprecated Has no effect. Output always uses arrow functions.
10
+ * @deprecated Has no effect. Output follows the syntax of the build seroval
11
+ * runs in: arrow functions, or `function` expressions in an ES5 build.
11
12
  */
12
13
  ArrowFunction = 2,
13
14
  ErrorPrototypeStack = 4,
@@ -483,6 +484,7 @@ interface LiveStreamSink<T> {
483
484
  interface LiveStreamOptions {
484
485
  onCancel?: (reason: unknown) => void;
485
486
  }
487
+ declare const BRAND: unique symbol;
486
488
  export declare function isLiveStream<T>(value: unknown): value is LiveStream<T>;
487
489
  /**
488
490
  * A single-consumer stream for incremental serialization. Unlike
@@ -490,10 +492,11 @@ export declare function isLiveStream<T>(value: unknown): value is LiveStream<T>;
490
492
  * producer operation that sent it settles only when the consumer accepts it.
491
493
  *
492
494
  * An internal class rather than a tagged POJO: identity is checked with
493
- * `instanceof`, which untrusted input cannot forge. The class is exported
495
+ * `isLiveStream`, which untrusted input cannot forge. The class is exported
494
496
  * because bundlers cannot drop an unexported top-level class.
495
497
  */
496
498
  export declare class LiveStream<T> {
499
+ private readonly [BRAND];
497
500
  private pending;
498
501
  private waiting;
499
502
  private consumed;
package/dist/index.d.ts CHANGED
@@ -7,7 +7,8 @@
7
7
  export declare enum Feature {
8
8
  AggregateError = 1,
9
9
  /**
10
- * @deprecated Has no effect. Output always uses arrow functions.
10
+ * @deprecated Has no effect. Output follows the syntax of the build seroval
11
+ * runs in: arrow functions, or `function` expressions in an ES5 build.
11
12
  */
12
13
  ArrowFunction = 2,
13
14
  ErrorPrototypeStack = 4,
@@ -483,6 +484,7 @@ interface LiveStreamSink<T> {
483
484
  interface LiveStreamOptions {
484
485
  onCancel?: (reason: unknown) => void;
485
486
  }
487
+ declare const BRAND: unique symbol;
486
488
  export declare function isLiveStream<T>(value: unknown): value is LiveStream<T>;
487
489
  /**
488
490
  * A single-consumer stream for incremental serialization. Unlike
@@ -490,10 +492,11 @@ export declare function isLiveStream<T>(value: unknown): value is LiveStream<T>;
490
492
  * producer operation that sent it settles only when the consumer accepts it.
491
493
  *
492
494
  * An internal class rather than a tagged POJO: identity is checked with
493
- * `instanceof`, which untrusted input cannot forge. The class is exported
495
+ * `isLiveStream`, which untrusted input cannot forge. The class is exported
494
496
  * because bundlers cannot drop an unexported top-level class.
495
497
  */
496
498
  export declare class LiveStream<T> {
499
+ private readonly [BRAND];
497
500
  private pending;
498
501
  private waiting;
499
502
  private consumed;