@onyx.dev/onyx-database 0.1.6 → 0.1.7

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
@@ -582,13 +582,36 @@ var QueryResults = class extends Array {
582
582
  /**
583
583
  * Iterates over each record on the current page only.
584
584
  * @param action - Function to invoke for each record.
585
+ * @param thisArg - Optional `this` binding for the callback.
585
586
  * @example
586
587
  * ```ts
587
588
  * results.forEachOnPage(u => console.log(u.id));
588
589
  * ```
589
590
  */
590
- forEachOnPage(action) {
591
- this.forEach(action);
591
+ forEachOnPage(action, thisArg) {
592
+ super.forEach((value, index) => {
593
+ action.call(thisArg, value, index, this);
594
+ });
595
+ }
596
+ /**
597
+ * Iterates over every record across all pages sequentially.
598
+ * @param action - Function executed for each record. Returning `false`
599
+ * stops iteration early.
600
+ * @param thisArg - Optional `this` binding for the callback.
601
+ * @example
602
+ * ```ts
603
+ * await results.forEach(u => {
604
+ * console.log(u.id);
605
+ * });
606
+ * ```
607
+ */
608
+ forEach(action, thisArg) {
609
+ let index = 0;
610
+ return this.forEachAll(async (item) => {
611
+ const result = await action.call(thisArg, item, index, this);
612
+ index += 1;
613
+ return result;
614
+ });
592
615
  }
593
616
  /**
594
617
  * Iterates over every record across all pages sequentially.