@onyx.dev/onyx-database 0.1.5 → 0.1.6

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.d.cts CHANGED
@@ -202,7 +202,7 @@ declare class QueryResults<T> extends Array<T> {
202
202
  * const results = new QueryResults(users, token, t => fetchMore(t));
203
203
  * ```
204
204
  */
205
- constructor(records: T[], nextPage: string | null, fetcher?: (token: string) => Promise<QueryResults<T>>);
205
+ constructor(records: Iterable<T> | ArrayLike<T> | T | null | undefined, nextPage: string | null, fetcher?: (token: string) => Promise<QueryResults<T>>);
206
206
  /**
207
207
  * Returns the first record in the result set.
208
208
  * @throws Error if the result set is empty.
package/dist/index.d.ts CHANGED
@@ -202,7 +202,7 @@ declare class QueryResults<T> extends Array<T> {
202
202
  * const results = new QueryResults(users, token, t => fetchMore(t));
203
203
  * ```
204
204
  */
205
- constructor(records: T[], nextPage: string | null, fetcher?: (token: string) => Promise<QueryResults<T>>);
205
+ constructor(records: Iterable<T> | ArrayLike<T> | T | null | undefined, nextPage: string | null, fetcher?: (token: string) => Promise<QueryResults<T>>);
206
206
  /**
207
207
  * Returns the first record in the result set.
208
208
  * @throws Error if the result set is empty.
package/dist/index.js CHANGED
@@ -519,7 +519,18 @@ var QueryResults = class extends Array {
519
519
  * ```
520
520
  */
521
521
  constructor(records, nextPage, fetcher) {
522
- super(...records);
522
+ const items = (() => {
523
+ if (records == null) return [];
524
+ if (Array.isArray(records)) return records;
525
+ if (typeof records[Symbol.iterator] === "function") {
526
+ return Array.from(records);
527
+ }
528
+ if (typeof records.length === "number") {
529
+ return Array.from(records);
530
+ }
531
+ return [records];
532
+ })();
533
+ super(...items);
523
534
  Object.setPrototypeOf(this, new.target.prototype);
524
535
  this.nextPage = nextPage;
525
536
  this.fetcher = fetcher;