svelte-common 6.8.4 → 6.8.5

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/pagination.mjs +12 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-common",
3
- "version": "6.8.4",
3
+ "version": "6.8.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Pagination support store.
3
3
  * Pages go from 1 ... numberOfPages
4
- * @param {Map|Array|Store} data
4
+ * @param {Map|Set|Array|Store} data
5
5
  * @param {Object} options
6
6
  * @param {number} [options.itemsPerPage]
7
7
  * @param {Function} [options.sorter]
@@ -51,22 +51,22 @@ export class Pagination {
51
51
  }
52
52
  }
53
53
 
54
- set _data(data) {
55
- this.#data = data;
56
- this.recalibrateCurrentPage();
57
- this.fireSubscriptions();
58
- }
59
-
60
54
  set data(data) {
61
55
  if (this.#unsubscribeData) {
62
56
  this.#unsubscribeData();
63
57
  this.#unsubscribeData = undefined;
64
58
  }
65
59
 
60
+ const d = data => {
61
+ this.#data = data;
62
+ this.recalibrateCurrentPage();
63
+ this.fireSubscriptions();
64
+ };
65
+
66
66
  if (data?.subscribe) {
67
- this.#unsubscribeData = data.subscribe(newData => (this._data = newData));
67
+ this.#unsubscribeData = data.subscribe(newData => d(newData));
68
68
  } else {
69
- this._data = data;
69
+ d(data);
70
70
  }
71
71
  }
72
72
 
@@ -155,10 +155,9 @@ export class Pagination {
155
155
 
156
156
  const n = this.page - 1;
157
157
 
158
- yield *data.slice(
159
- n * this.itemsPerPage,
160
- (n + 1) * this.itemsPerPage
161
- )[Symbol.iterator]();
158
+ yield* data
159
+ .slice(n * this.itemsPerPage, (n + 1) * this.itemsPerPage)
160
+ [Symbol.iterator]();
162
161
  }
163
162
 
164
163
  /**