@signaldb/core 2.0.0-beta.8 → 2.0.0-beta.9

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.
@@ -56,11 +56,20 @@ var Collection = class Collection extends require_EventEmitter.default {
56
56
  const execute = () => Collection.collections.reduce((memo, collection) => () => {
57
57
  return collection.batch(memo);
58
58
  }, callback)();
59
- const maybePromise = execute();
60
59
  const afterBatch = () => {
61
60
  Collection.batchOperationInProgress = false;
62
61
  };
63
- if (maybePromise && typeof maybePromise.then === "function") return maybePromise.then(() => afterBatch());
62
+ let maybePromise;
63
+ try {
64
+ maybePromise = execute();
65
+ } catch (error) {
66
+ afterBatch();
67
+ throw error;
68
+ }
69
+ if (maybePromise && typeof maybePromise.then === "function") return maybePromise.then(() => afterBatch(), (error) => {
70
+ afterBatch();
71
+ throw error;
72
+ });
64
73
  else afterBatch();
65
74
  }
66
75
  name;
@@ -318,13 +327,22 @@ var Collection = class Collection extends require_EventEmitter.default {
318
327
  batch(callback) {
319
328
  if (this.batchOperationInProgress) return callback();
320
329
  this.batchOperationInProgress = true;
321
- const maybePromise = callback();
322
330
  const afterBatch = () => {
323
331
  this.batchOperationInProgress = false;
324
332
  this.postBatchCallbacks.forEach((callback_) => callback_());
325
333
  this.postBatchCallbacks.clear();
326
334
  };
327
- if (maybePromise && typeof maybePromise.then === "function") return maybePromise.then(() => afterBatch());
335
+ let maybePromise;
336
+ try {
337
+ maybePromise = callback();
338
+ } catch (error) {
339
+ afterBatch();
340
+ throw error;
341
+ }
342
+ if (maybePromise && typeof maybePromise.then === "function") return maybePromise.then(() => afterBatch(), (error) => {
343
+ afterBatch();
344
+ throw error;
345
+ });
328
346
  else afterBatch();
329
347
  }
330
348
  onPostBatch(callback) {
package/dist/index25.mjs CHANGED
@@ -56,11 +56,20 @@ var Collection = class Collection extends EventEmitter {
56
56
  const execute = () => Collection.collections.reduce((memo, collection) => () => {
57
57
  return collection.batch(memo);
58
58
  }, callback)();
59
- const maybePromise = execute();
60
59
  const afterBatch = () => {
61
60
  Collection.batchOperationInProgress = false;
62
61
  };
63
- if (maybePromise && typeof maybePromise.then === "function") return maybePromise.then(() => afterBatch());
62
+ let maybePromise;
63
+ try {
64
+ maybePromise = execute();
65
+ } catch (error) {
66
+ afterBatch();
67
+ throw error;
68
+ }
69
+ if (maybePromise && typeof maybePromise.then === "function") return maybePromise.then(() => afterBatch(), (error) => {
70
+ afterBatch();
71
+ throw error;
72
+ });
64
73
  else afterBatch();
65
74
  }
66
75
  name;
@@ -318,13 +327,22 @@ var Collection = class Collection extends EventEmitter {
318
327
  batch(callback) {
319
328
  if (this.batchOperationInProgress) return callback();
320
329
  this.batchOperationInProgress = true;
321
- const maybePromise = callback();
322
330
  const afterBatch = () => {
323
331
  this.batchOperationInProgress = false;
324
332
  this.postBatchCallbacks.forEach((callback_) => callback_());
325
333
  this.postBatchCallbacks.clear();
326
334
  };
327
- if (maybePromise && typeof maybePromise.then === "function") return maybePromise.then(() => afterBatch());
335
+ let maybePromise;
336
+ try {
337
+ maybePromise = callback();
338
+ } catch (error) {
339
+ afterBatch();
340
+ throw error;
341
+ }
342
+ if (maybePromise && typeof maybePromise.then === "function") return maybePromise.then(() => afterBatch(), (error) => {
343
+ afterBatch();
344
+ throw error;
345
+ });
328
346
  else afterBatch();
329
347
  }
330
348
  onPostBatch(callback) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signaldb/core",
3
- "version": "2.0.0-beta.8",
3
+ "version": "2.0.0-beta.9",
4
4
  "description": "SignalDB is a client-side database that provides a simple MongoDB-like interface to the data with first-class typescript support to achieve an optimistic UI. Data persistence can be achieved by using storage providers that store the data through a JSON interface to places such as localStorage.",
5
5
  "scripts": {
6
6
  "build": "rimraf dist && vite build",