@nsshunt/stsobservability 1.0.99 → 1.0.100

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.
@@ -4201,64 +4201,6 @@ function ensureUint8Array(buffer) {
4201
4201
  return Uint8Array.from(buffer);
4202
4202
  }
4203
4203
  }
4204
- var __addDisposableResource = function(env, value, async) {
4205
- if (value !== null && value !== void 0) {
4206
- if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
4207
- var dispose, inner;
4208
- if (async) {
4209
- if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
4210
- dispose = value[Symbol.asyncDispose];
4211
- }
4212
- if (dispose === void 0) {
4213
- if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
4214
- dispose = value[Symbol.dispose];
4215
- if (async) inner = dispose;
4216
- }
4217
- if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
4218
- if (inner) dispose = function() {
4219
- try {
4220
- inner.call(this);
4221
- } catch (e) {
4222
- return Promise.reject(e);
4223
- }
4224
- };
4225
- env.stack.push({ value, dispose, async });
4226
- } else if (async) {
4227
- env.stack.push({ async: true });
4228
- }
4229
- return value;
4230
- };
4231
- var __disposeResources = /* @__PURE__ */ function(SuppressedError2) {
4232
- return function(env) {
4233
- function fail(e) {
4234
- env.error = env.hasError ? new SuppressedError2(e, env.error, "An error was suppressed during disposal.") : e;
4235
- env.hasError = true;
4236
- }
4237
- var r, s = 0;
4238
- function next() {
4239
- while (r = env.stack.pop()) {
4240
- try {
4241
- if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
4242
- if (r.dispose) {
4243
- var result = r.dispose.call(r.value);
4244
- if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) {
4245
- fail(e);
4246
- return next();
4247
- });
4248
- } else s |= 1;
4249
- } catch (e) {
4250
- fail(e);
4251
- }
4252
- }
4253
- if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
4254
- if (env.hasError) throw env.error;
4255
- }
4256
- return next();
4257
- };
4258
- }(typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
4259
- var e = new Error(message);
4260
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
4261
- });
4262
4204
  const DEFAULT_MAX_DEPTH = 100;
4263
4205
  const DEFAULT_INITIAL_BUFFER_SIZE = 2048;
4264
4206
  class Encoder {
@@ -4293,56 +4235,40 @@ class Encoder {
4293
4235
  reinitializeState() {
4294
4236
  this.pos = 0;
4295
4237
  }
4296
- enteringGuard() {
4297
- this.entered = true;
4298
- return {
4299
- [Symbol.dispose]: () => {
4300
- this.entered = false;
4301
- }
4302
- };
4303
- }
4304
4238
  /**
4305
4239
  * This is almost equivalent to {@link Encoder#encode}, but it returns an reference of the encoder's internal buffer and thus much faster than {@link Encoder#encode}.
4306
4240
  *
4307
4241
  * @returns Encodes the object and returns a shared reference the encoder's internal buffer.
4308
4242
  */
4309
4243
  encodeSharedRef(object) {
4310
- const env_1 = { stack: [], error: void 0, hasError: false };
4244
+ if (this.entered) {
4245
+ const instance = this.clone();
4246
+ return instance.encodeSharedRef(object);
4247
+ }
4311
4248
  try {
4312
- if (this.entered) {
4313
- const instance = this.clone();
4314
- return instance.encodeSharedRef(object);
4315
- }
4316
- const _guard = __addDisposableResource(env_1, this.enteringGuard(), false);
4249
+ this.entered = true;
4317
4250
  this.reinitializeState();
4318
4251
  this.doEncode(object, 1);
4319
4252
  return this.bytes.subarray(0, this.pos);
4320
- } catch (e_1) {
4321
- env_1.error = e_1;
4322
- env_1.hasError = true;
4323
4253
  } finally {
4324
- __disposeResources(env_1);
4254
+ this.entered = false;
4325
4255
  }
4326
4256
  }
4327
4257
  /**
4328
4258
  * @returns Encodes the object and returns a copy of the encoder's internal buffer.
4329
4259
  */
4330
4260
  encode(object) {
4331
- const env_2 = { stack: [], error: void 0, hasError: false };
4261
+ if (this.entered) {
4262
+ const instance = this.clone();
4263
+ return instance.encode(object);
4264
+ }
4332
4265
  try {
4333
- if (this.entered) {
4334
- const instance = this.clone();
4335
- return instance.encode(object);
4336
- }
4337
- const _guard = __addDisposableResource(env_2, this.enteringGuard(), false);
4266
+ this.entered = true;
4338
4267
  this.reinitializeState();
4339
4268
  this.doEncode(object, 1);
4340
4269
  return this.bytes.slice(0, this.pos);
4341
- } catch (e_2) {
4342
- env_2.error = e_2;
4343
- env_2.hasError = true;
4344
4270
  } finally {
4345
- __disposeResources(env_2);
4271
+ this.entered = false;
4346
4272
  }
4347
4273
  }
4348
4274
  doEncode(object, depth) {