@adviser/cement 0.2.29 → 0.2.30

Sign up to get free protection for your applications and to get access to all the features.
package/index.cjs CHANGED
@@ -146,7 +146,8 @@ __export(src_exports, {
146
146
  removeSelfRef: () => removeSelfRef,
147
147
  runtimeFn: () => runtimeFn,
148
148
  toCryptoRuntime: () => toCryptoRuntime,
149
- utils: () => utils_exports
149
+ utils: () => utils_exports,
150
+ wrapRefcounted: () => wrapRefcounted
150
151
  });
151
152
  module.exports = __toCommonJS(src_exports);
152
153
 
@@ -2329,6 +2330,26 @@ var VERSION = Object.keys({
2329
2330
  __packageVersion__: "xxxx"
2330
2331
  })[0];
2331
2332
 
2333
+ // src/refcounted.ts
2334
+ function wrapRefcounted(t, method) {
2335
+ const my2 = t;
2336
+ my2.__refcounted = (my2.__refcounted || 0) + 1;
2337
+ if (my2.__refcounted === 1) {
2338
+ my2.__unrefcounted = my2[method];
2339
+ const mRec = my2;
2340
+ mRec[method] = function() {
2341
+ this.__refcounted--;
2342
+ if (this.__refcounted === 0) {
2343
+ this.__unrefcounted();
2344
+ }
2345
+ if (this.__refcounted < 0) {
2346
+ throw new Error("already closed");
2347
+ }
2348
+ };
2349
+ }
2350
+ return t;
2351
+ }
2352
+
2332
2353
  // src/utils/index.ts
2333
2354
  var utils_exports = {};
2334
2355
  __export(utils_exports, {
@@ -2588,6 +2609,7 @@ function uint8array2stream(str) {
2588
2609
  removeSelfRef,
2589
2610
  runtimeFn,
2590
2611
  toCryptoRuntime,
2591
- utils
2612
+ utils,
2613
+ wrapRefcounted
2592
2614
  });
2593
2615
  //# sourceMappingURL=index.cjs.map