arangojs 8.3.0 → 8.4.0

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/connection.js CHANGED
@@ -451,7 +451,7 @@ class Connection {
451
451
  ...this._headers,
452
452
  "content-type": contentType,
453
453
  "x-arango-version": String(this._arangoVersion),
454
- "x-arango-driver": `arangojs/8.3.0 (cloud)`,
454
+ "x-arango-driver": `arangojs/8.4.0 (cloud)`,
455
455
  };
456
456
  if (this._transactionId) {
457
457
  extraHeaders["x-arango-trx-id"] = this._transactionId;
package/cursor.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../src/cursor.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;IACJ;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;OAEG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;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ayCursor {
79
79
  if (!this._id || !this.hasMore)
80
80
  return;
81
81
  const body = await this._db.request({
82
- ...(this._nextBatchId
83
- ? {
84
- method: "POST",
85
- path: `/_api/cursor/${encodeURIComponent(this._id)}/${this._nextBatchId}`,
86
- }
87
- : {
88
- method: "PUT",
89
- path: `/_api/cursor/${encodeURIComponent(this._id)}`,
90
- }),
82
+ method: "POST",
83
+ path: this._nextBatchId
84
+ ? `/_api/cursor/${encodeURIComponent(this._id)}/${this._nextBatchId}`
85
+ : `/_api/cursor/${encodeURIComponent(this._id)}`,
91
86
  hostUrl: this._hostUrl,
92
87
  allowDirtyRead: this._allowDirtyRead,
93
88
  });
package/cursor.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cursor.js","sourceRoot":"","sources":["../src/cursor.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,iDAA2C;AAoH3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,kBAAkB;IAY7B;;OAEG;IACH,YACE,EAAY,EACZ,IAOC,EACD,OAAgB,EAChB,cAAwB;QAExB,MAAM,OAAO,GAAG,IAAI,0BAAU,CAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,0BAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CACxD,CAAC;QACF,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CA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AAC,MAAM,IAAI,CAAC,IAAI,EAAE,CAAQ,CAAC;YACzC,YAAY,GAAG,KAAU,CAAC;YAC1B,KAAK,IAAI,CAAC,CAAC;SACZ;QACD,IAAI,KAAK,GAAG,YAAY,CAAC;QACzB,OAAO,IAAI,CAAC,OAAO,EAAE;YACnB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YAC/B,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,IAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC3C,KAAK,EAAE,CAAC;SACT;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;CACF;AAtZD,kCAsZC","sourcesContent":["/**\n * ```ts\n * import type { ArrayCursor, BatchedArrayCursor } from \"arangojs/cursor\";\n * ```\n *\n * The \"cursor\" module provides cursor-related interfaces for TypeScript.\n *\n * @packageDocumentation\n */\nimport { LinkedList } from \"x3-linkedlist\";\nimport { Database } from \"./database\";\n\n/**\n * Additional information about the cursor.\n */\nexport interface CursorExtras {\n /**\n * Warnings encountered while executing the query.\n */\n warnings: {\n code: number;\n message: string;\n }[];\n /**\n * Query execution plan for the executed query.\n */\n plan?: Record<string, any>;\n /**\n * Additional profiling information for the executed query.\n */\n profile?: Record<string, number>;\n /**\n * Additional statistics about the query execution.\n */\n stats?: CursorStats;\n}\n\n/**\n * Additional statics about the query execution of the cursor.\n */\nexport interface CursorStats {\n /**\n * Total number of index entries read from in-memory caches for indexes of\n * type edge or persistent.\n */\n cacheHits: number;\n /**\n * Total number of cache read attempts for index entries that could not be\n * served from in-memory caches for indexes of type edge or persistent.\n */\n cacheMisses: number;\n /**\n * Total number of cursor objects created during query execution.\n */\n cursorsCreated: number;\n /**\n * Total number of times an existing cursor object was repurposed.\n */\n cursorsRearmed: number;\n /**\n * Total number of data-modification operations successfully executed.\n */\n writesExecuted: number;\n /**\n * Total number of data-modification operations that were unsuccessful, but have been ignored because of query option ignoreErrors.\n */\n writesIgnored: number;\n /**\n * Total number of documents iterated over when scanning a collection without an index.\n */\n scannedFull: number;\n /**\n * Total number of documents iterated over when scanning a collection using an index.\n */\n scannedIndex: number;\n /**\n * Total number of documents that were removed after executing a filter condition in a FilterNode.\n */\n filtered: number;\n /**\n * Maximum memory usage of the query while it was running.\n */\n peakMemoryUsage: number;\n /**\n * Execution time of the query in seconds.\n */\n executionTime: number;\n /**\n * Total number of documents that matched the search condition if the query’s final top-level LIMIT statement were not present.\n */\n fullCount?: number;\n /**\n * Total number of cluster-internal HTTP requests performed.\n */\n httpRequests: number;\n /**\n * Runtime statistics per query execution node if `profile` was set to `2` or greater.\n */\n nodes?: {\n /**\n * Execution node ID to correlate this node with nodes in the `extra.plan`.\n */\n id: number;\n /**\n * Number of calls in this node.\n */\n calls: number;\n /**\n * Number of temporary result items returned by this node.\n */\n items: number;\n filter: number;\n /**\n * Execution time of this node in seconds.\n */\n runtime: number;\n }[];\n}\n\ninterface BatchView<T = any> {\n isEmpty: boolean;\n more(): Promise<void>;\n shift(): T | undefined;\n}\n\n/**\n * The `BatchedArrayCursor` provides a batch-wise API to an {@link ArrayCursor}.\n *\n * When using TypeScript, cursors can be cast to a specific item type in order\n * to increase type safety.\n *\n * @param T - Type to use for each item. Defaults to `any`.\n *\n * @example\n * ```ts\n * const db = new Database();\n * const query = aql`FOR x IN 1..5 RETURN x`;\n * const cursor = await db.query(query) as ArrayCursor<number>;\n * const batches = cursor.batches;\n * ```\n *\n * @example\n * ```js\n * const db = new Database();\n * const query = aql`FOR x IN 1..10000 RETURN x`;\n * const cursor = await db.query(query, { batchSize: 10 });\n * for await (const batch of cursor.batches) {\n * // Process all values in a batch in parallel\n * await Promise.all(batch.map(\n * value => asyncProcessValue(value)\n * ));\n * }\n * ```\n */\nexport class BatchedArrayCursor<T = any> {\n protected _db: Database;\n protected _batches: LinkedList<LinkedList<any>>;\n protected _count?: number;\n protected _extra: CursorExtras;\n protected _hasMore: boolean;\n protected _nextBatchId?: string;\n protected _id: string | undefined;\n protected _hostUrl?: string;\n protected _allowDirtyRead?: boolean;\n protected _itemsCursor: ArrayCursor<T>;\n\n /**\n * @internal\n */\n constructor(\n db: Database,\n body: {\n extra: any;\n result: T[];\n hasMore: boolean;\n nextBatchId?: string;\n id: string;\n count: number;\n },\n hostUrl?: string,\n allowDirtyRead?: boolean\n ) {\n const batches = new LinkedList(\n body.result.length ? [new LinkedList(body.result)] : []\n );\n this._db = db;\n this._batches = batches;\n this._id = body.id;\n this._hasMore = Boolean(body.id && body.hasMore);\n this._nextBatchId = body.nextBatchId;\n this._hostUrl = hostUrl;\n this._count = body.count;\n this._extra = body.extra;\n this._allowDirtyRead = allowDirtyRead;\n this._itemsCursor = new ArrayCursor(this, {\n get isEmpty() {\n return !batches.length;\n },\n more: () => this._more(),\n shift: () => {\n let batch = batches.first?.value;\n while (batch && !batch.length) {\n batches.shift();\n batch = batches.first?.value;\n }\n if (!batch) return undefined;\n const value = batch.shift();\n if (!batch.length) batches.shift();\n return value;\n },\n });\n }\n\n protected async _more(): Promise<void> {\n if (!this._id || !this.hasMore) return;\n const body = await this._db.request({\n ...(this._nextBatchId\n ? {\n method: \"POST\",\n path: `/_api/cursor/${encodeURIComponent(this._id)}/${\n this._nextBatchId\n }`,\n }\n : {\n method: \"PUT\",\n path: `/_api/cursor/${encodeURIComponent(this._id)}`,\n }),\n hostUrl: this._hostUrl,\n allowDirtyRead: this._allowDirtyRead,\n });\n this._batches.push(new LinkedList(body.result));\n this._hasMore = body.hasMore;\n this._nextBatchId = body.nextBatchId;\n }\n\n /**\n * An {@link ArrayCursor} providing item-wise access to the cursor result set.\n *\n * See also {@link ArrayCursor#batches}.\n */\n get items() {\n return this._itemsCursor;\n }\n\n /**\n * Additional information about the cursor.\n */\n get extra(): Readonly<CursorExtras> {\n return this._extra;\n }\n\n /**\n * Total number of documents in the query result. Only available if the\n * `count` option was used.\n */\n get count(): number | undefined {\n return this._count;\n }\n\n /**\n * Whether the cursor has any remaining batches that haven't yet been\n * fetched. If set to `false`, all batches have been fetched and no\n * additional requests to the server will be made when consuming any\n * remaining batches from this cursor.\n */\n get hasMore(): boolean {\n return this._hasMore;\n }\n\n /**\n * Whether the cursor has more batches. If set to `false`, the cursor has\n * already been depleted and contains no more batches.\n */\n get hasNext(): boolean {\n return this.hasMore || Boolean(this._batches.length);\n }\n\n /**\n * Enables use with `for await` to deplete the cursor by asynchronously\n * yielding every batch in the cursor's remaining result set.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`\n * FOR user IN users\n * FILTER user.isActive\n * RETURN user\n * `);\n * for await (const users of cursor.batches) {\n * for (const user of users) {\n * console.log(user.email, user.isAdmin);\n * }\n * }\n * ```\n */\n async *[Symbol.asyncIterator](): AsyncGenerator<T[], undefined, undefined> {\n while (this.hasNext) {\n yield this.next() as Promise<T[]>;\n }\n return undefined;\n }\n\n /**\n * Loads all remaining batches from the server.\n *\n * **Warning**: This may impact memory use when working with very large\n * query result sets.\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 1 }\n * );\n * console.log(cursor.hasMore); // true\n * await cursor.batches.loadAll();\n * console.log(cursor.hasMore); // false\n * console.log(cursor.hasNext); // true\n * for await (const item of cursor) {\n * console.log(item);\n * // No server roundtrips necessary any more\n * }\n * ```\n */\n async loadAll(): Promise<void> {\n while (this._hasMore) {\n await this._more();\n }\n }\n\n /**\n * Depletes the cursor, then returns an array containing all batches in the\n * cursor's remaining result list.\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * const result = await cursor.batches.all(); // [[1, 2], [3, 4], [5]]\n * console.log(cursor.hasNext); // false\n * ```\n */\n async all(): Promise<T[][]> {\n return this.map((batch) => batch);\n }\n\n /**\n * Advances the cursor and returns all remaining values in the cursor's\n * current batch. If the current batch has already been exhausted, fetches\n * the next batch from the server and returns it, or `undefined` if the\n * cursor has been depleted.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR i IN 1..10 RETURN i`,\n * { batchSize: 5 }\n * );\n * const firstBatch = await cursor.batches.next(); // [1, 2, 3, 4, 5]\n * await cursor.next(); // 6\n * const lastBatch = await cursor.batches.next(); // [7, 8, 9, 10]\n * console.log(cursor.hasNext); // false\n * ```\n */\n async next(): Promise<T[] | undefined> {\n while (!this._batches.length && this.hasNext) {\n await this._more();\n }\n if (!this._batches.length) {\n return undefined;\n }\n const batch = this._batches.shift();\n if (!batch) return undefined;\n const values = [...batch.values()];\n batch.clear(true);\n return values;\n }\n\n /**\n * Advances the cursor by applying the `callback` function to each item in\n * the cursor's remaining result list until the cursor is depleted or\n * `callback` returns the exact value `false`. Returns a promise that\n * evalues to `true` unless the function returned `false`.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).\n *\n * @param callback - Function to execute on each element.\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * const result = await cursor.batches.forEach((currentBatch) => {\n * for (const value of currentBatch) {\n * console.log(value);\n * }\n * });\n * console.log(result) // true\n * console.log(cursor.hasNext); // false\n * ```\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * const result = await cursor.batches.forEach((currentBatch) => {\n * for (const value of currentBatch) {\n * console.log(value);\n * }\n * return false; // stop after the first batch\n * });\n * console.log(result); // false\n * console.log(cursor.hasNext); // true\n * ```\n */\n async forEach(\n callback: (currentBatch: T[], index: number, self: this) => false | void\n ): Promise<boolean> {\n let index = 0;\n while (this.hasNext) {\n const currentBatch = await this.next();\n const result = callback(currentBatch!, index, this);\n index++;\n if (result === false) return result;\n if (this.hasNext) await this._more();\n }\n return true;\n }\n\n /**\n * Depletes the cursor by applying the `callback` function to each batch in\n * the cursor's remaining result list. Returns an array containing the\n * return values of `callback` for each batch.\n *\n * **Note**: This creates an array of all return values, which may impact\n * memory use when working with very large query result sets. Consider using\n * {@link BatchedArrayCursor#forEach}, {@link BatchedArrayCursor#reduce} or\n * {@link BatchedArrayCursor#flatMap} instead.\n *\n * See also:\n * [`Array.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).\n *\n * @param R - Return type of the `callback` function.\n * @param callback - Function to execute on each element.\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * const squares = await cursor.batches.map((currentBatch) => {\n * return currentBatch.map((value) => value ** 2);\n * });\n * console.log(squares); // [[1, 4], [9, 16], [25]]\n * console.log(cursor.hasNext); // false\n * ```\n */\n async map<R>(\n callback: (currentBatch: T[], index: number, self: this) => R\n ): Promise<R[]> {\n let index = 0;\n const result: any[] = [];\n while (this.hasNext) {\n const currentBatch = await this.next();\n result.push(callback(currentBatch!, index, this));\n index++;\n }\n return result;\n }\n\n /**\n * Depletes the cursor by applying the `callback` function to each batch in\n * the cursor's remaining result list. Returns an array containing the\n * return values of `callback` for each batch, flattened to a depth of 1.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.flatMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).\n *\n * @param R - Return type of the `callback` function.\n * @param callback - Function to execute on each element.\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * const squares = await cursor.batches.flatMap((currentBatch) => {\n * return currentBatch.map((value) => value ** 2);\n * });\n * console.log(squares); // [1, 1, 2, 4, 3, 9, 4, 16, 5, 25]\n * console.log(cursor.hasNext); // false\n * ```\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 1 }\n * );\n * const odds = await cursor.batches.flatMap((currentBatch) => {\n * if (currentBatch[0] % 2 === 0) {\n * return []; // empty array flattens into nothing\n * }\n * return currentBatch;\n * });\n * console.logs(odds); // [1, 3, 5]\n * ```\n */\n async flatMap<R>(\n callback: (currentBatch: T[], index: number, self: this) => R | R[]\n ): Promise<R[]> {\n let index = 0;\n const result: any[] = [];\n while (this.hasNext) {\n const currentBatch = await this.next();\n const value = callback(currentBatch!, index, this);\n if (Array.isArray(value)) {\n result.push(...value);\n } else {\n result.push(value);\n }\n index++;\n }\n return result;\n }\n\n /**\n * Depletes the cursor by applying the `reducer` function to each batch in\n * the cursor's remaining result list. Returns the return value of `reducer`\n * for the last batch.\n *\n * **Note**: Most complex uses of the `reduce` method can be replaced with\n * simpler code using {@link BatchedArrayCursor#forEach} or the `for await`\n * syntax.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).\n *\n * @param R - Return type of the `reducer` function.\n * @param reducer - Function to execute on each element.\n * @param initialValue - Initial value of the `accumulator` value passed to\n * the `reducer` function.\n *\n * @example\n * ```js\n * function largestValue(baseline, values) {\n * return Math.max(baseline, ...values);\n * }\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 3 }\n * );\n * const result = await cursor.batches.reduce(largestValue, 0);\n * console.log(result); // 5\n * console.log(cursor.hasNext); // false\n * const emptyResult = await cursor.batches.reduce(largestValue, 0);\n * console.log(emptyResult); // 0\n * ```\n *\n * @example\n * ```js\n * // BAD! NEEDLESSLY COMPLEX!\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 1 }\n * );\n * const result = await cursor.reduce((accumulator, currentBatch) => {\n * if (currentBatch[0] % 2 === 0) {\n * accumulator.even.push(...currentBatch);\n * } else {\n * accumulator.odd.push(...currentBatch);\n * }\n * return accumulator;\n * }, { odd: [], even: [] });\n * console.log(result); // { odd: [1, 3, 5], even: [2, 4] }\n *\n * // GOOD! MUCH SIMPLER!\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const odd = [];\n * const even = [];\n * for await (const currentBatch of cursor) {\n * if (currentBatch[0] % 2 === 0) {\n * even.push(...currentBatch);\n * } else {\n * odd.push(...currentBatch);\n * }\n * }\n * console.log({ odd, even }); // { odd: [1, 3, 5], even: [2, 4] }\n * ```\n */\n async reduce<R>(\n reducer: (\n accumulator: R,\n currentBatch: T[],\n index: number,\n self: this\n ) => R,\n initialValue: R\n ): Promise<R>;\n\n /**\n * Depletes the cursor by applying the `reducer` function to each batch in\n * the cursor's remaining result list. Returns the return value of `reducer`\n * for the last batch.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).\n *\n * @param R - Return type of the `reducer` function.\n * @param reducer - Function to execute on each element.\n *\n * @example\n * ```js\n * function largestValue(values1, values2) {\n * return [Math.max(...values1, ...values2)];\n * }\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 3 }\n * );\n * const result = await cursor.batches.reduce(largestValue);\n * console.log(result); // [5]\n * console.log(cursor.hasNext); // false\n * ```\n *\n */\n async reduce<R>(\n reducer: (\n accumulator: T[] | R,\n currentBatch: T[],\n index: number,\n self: this\n ) => R\n ): Promise<R | undefined>;\n async reduce<R>(\n reducer: (\n accumulator: R,\n currentBatch: T[],\n index: number,\n self: this\n ) => R,\n initialValue?: R\n ): Promise<R | undefined> {\n let index = 0;\n if (!this.hasNext) return initialValue;\n if (initialValue === undefined) {\n initialValue = (await this.next()) as any;\n index += 1;\n }\n let value = initialValue as R;\n while (this.hasNext) {\n const currentBatch = await this.next();\n value = reducer(value, currentBatch!, index, this);\n index++;\n }\n return value;\n }\n\n /**\n * Drains the cursor and frees up associated database resources.\n *\n * This method has no effect if all batches have already been consumed.\n *\n * @example\n * ```js\n * const cursor1 = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * console.log(cursor1.hasMore); // false\n * await cursor1.kill(); // no effect\n *\n * const cursor2 = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * console.log(cursor2.hasMore); // true\n * await cursor2.kill(); // cursor is depleted\n * ```\n */\n async kill(): Promise<void> {\n if (this._batches.length) {\n for (const batch of this._batches.values()) {\n batch.clear();\n }\n this._batches.clear();\n }\n if (!this.hasNext) return undefined;\n return this._db.request(\n {\n method: \"DELETE\",\n path: `/_api/cursor/${encodeURIComponent(this._id!)}`,\n },\n () => {\n this._hasMore = false;\n return undefined;\n }\n );\n }\n}\n\n/**\n * The `ArrayCursor` type represents a cursor returned from a\n * {@link database.Database#query}.\n *\n * When using TypeScript, cursors can be cast to a specific item type in order\n * to increase type safety.\n *\n * See also {@link BatchedArrayCursor}.\n *\n * @param T - Type to use for each item. Defaults to `any`.\n *\n * @example\n * ```ts\n * const db = new Database();\n * const query = aql`FOR x IN 1..5 RETURN x`;\n * const result = await db.query(query) as ArrayCursor<number>;\n * ```\n *\n * @example\n * ```js\n * const db = new Database();\n * const query = aql`FOR x IN 1..10 RETURN x`;\n * const cursor = await db.query(query);\n * for await (const value of cursor) {\n * // Process each value asynchronously\n * await processValue(value);\n * }\n * ```\n */\nexport class ArrayCursor<T = any> {\n protected _batches: BatchedArrayCursor<T>;\n protected _view: BatchView<T>;\n\n /**\n * @internal\n */\n constructor(batchedCursor: BatchedArrayCursor, view: BatchView<T>) {\n this._batches = batchedCursor;\n this._view = view;\n }\n\n /**\n * A {@link BatchedArrayCursor} providing batch-wise access to the cursor\n * result set.\n *\n * See also {@link BatchedArrayCursor#items}.\n */\n get batches() {\n return this._batches;\n }\n\n /**\n * Additional information about the cursor.\n */\n get extra(): CursorExtras {\n return this.batches.extra;\n }\n\n /**\n * Total number of documents in the query result. Only available if the\n * `count` option was used.\n */\n get count(): number | undefined {\n return this.batches.count;\n }\n\n /**\n * Whether the cursor has more values. If set to `false`, the cursor has\n * already been depleted and contains no more items.\n */\n get hasNext(): boolean {\n return this.batches.hasNext;\n }\n\n /**\n * Enables use with `for await` to deplete the cursor by asynchronously\n * yielding every value in the cursor's remaining result set.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`\n * FOR user IN users\n * FILTER user.isActive\n * RETURN user\n * `);\n * for await (const user of cursor) {\n * console.log(user.email, user.isAdmin);\n * }\n * ```\n */\n async *[Symbol.asyncIterator](): AsyncGenerator<T, undefined, undefined> {\n while (this.hasNext) {\n yield this.next() as Promise<T>;\n }\n return undefined;\n }\n\n /**\n * Depletes the cursor, then returns an array containing all values in the\n * cursor's remaining result list.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const result = await cursor.all(); // [1, 2, 3, 4, 5]\n * console.log(cursor.hasNext); // false\n * ```\n */\n async all(): Promise<T[]> {\n return this.batches.flatMap((v) => v);\n }\n\n /**\n * Advances the cursor and returns the next value in the cursor's remaining\n * result list, or `undefined` if the cursor has been depleted.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..3 RETURN x`);\n * const one = await cursor.next(); // 1\n * const two = await cursor.next(); // 2\n * const three = await cursor.next(); // 3\n * const empty = await cursor.next(); // undefined\n * ```\n */\n async next(): Promise<T | undefined> {\n while (this._view.isEmpty && this.batches.hasMore) {\n await this._view.more();\n }\n if (this._view.isEmpty) {\n return undefined;\n }\n return this._view.shift();\n }\n\n /**\n * Advances the cursor by applying the `callback` function to each item in\n * the cursor's remaining result list until the cursor is depleted or\n * `callback` returns the exact value `false`. Returns a promise that\n * evalues to `true` unless the function returned `false`.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).\n *\n * @param callback - Function to execute on each element.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const result = await cursor.forEach((currentValue) => {\n * console.log(currentValue);\n * });\n * console.log(result) // true\n * console.log(cursor.hasNext); // false\n * ```\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const result = await cursor.forEach((currentValue) => {\n * console.log(currentValue);\n * return false; // stop after the first item\n * });\n * console.log(result); // false\n * console.log(cursor.hasNext); // true\n * ```\n */\n async forEach(\n callback: (currentValue: T, index: number, self: this) => false | void\n ): Promise<boolean> {\n let index = 0;\n while (this.hasNext) {\n const value = await this.next();\n const result = callback(value!, index, this);\n index++;\n if (result === false) return result;\n }\n return true;\n }\n\n /**\n * Depletes the cursor by applying the `callback` function to each item in\n * the cursor's remaining result list. Returns an array containing the\n * return values of `callback` for each item.\n *\n * **Note**: This creates an array of all return values, which may impact\n * memory use when working with very large query result sets. Consider using\n * {@link ArrayCursor#forEach}, {@link ArrayCursor#reduce} or\n * {@link ArrayCursor#flatMap} instead.\n *\n * See also:\n * [`Array.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).\n *\n * @param R - Return type of the `callback` function.\n * @param callback - Function to execute on each element.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const squares = await cursor.map((currentValue) => {\n * return currentValue ** 2;\n * });\n * console.log(squares); // [1, 4, 9, 16, 25]\n * console.log(cursor.hasNext); // false\n * ```\n */\n async map<R>(\n callback: (currentValue: T, index: number, self: this) => R\n ): Promise<R[]> {\n let index = 0;\n const result: any[] = [];\n while (this.hasNext) {\n const value = await this.next();\n result.push(callback(value!, index, this));\n index++;\n }\n return result;\n }\n\n /**\n * Depletes the cursor by applying the `callback` function to each item in\n * the cursor's remaining result list. Returns an array containing the\n * return values of `callback` for each item, flattened to a depth of 1.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.flatMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).\n *\n * @param R - Return type of the `callback` function.\n * @param callback - Function to execute on each element.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const squares = await cursor.flatMap((currentValue) => {\n * return [currentValue, currentValue ** 2];\n * });\n * console.log(squares); // [1, 1, 2, 4, 3, 9, 4, 16, 5, 25]\n * console.log(cursor.hasNext); // false\n * ```\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const odds = await cursor.flatMap((currentValue) => {\n * if (currentValue % 2 === 0) {\n * return []; // empty array flattens into nothing\n * }\n * return currentValue; // or [currentValue]\n * });\n * console.logs(odds); // [1, 3, 5]\n * ```\n */\n async flatMap<R>(\n callback: (currentValue: T, index: number, self: this) => R | R[]\n ): Promise<R[]> {\n let index = 0;\n const result: any[] = [];\n while (this.hasNext) {\n const value = await this.next();\n const item = callback(value!, index, this);\n if (Array.isArray(item)) {\n result.push(...item);\n } else {\n result.push(item);\n }\n index++;\n }\n return result;\n }\n\n /**\n * Depletes the cursor by applying the `reducer` function to each item in\n * the cursor's remaining result list. Returns the return value of `reducer`\n * for the last item.\n *\n * **Note**: Most complex uses of the `reduce` method can be replaced with\n * simpler code using {@link ArrayCursor#forEach} or the `for await` syntax.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).\n *\n * @param R - Return type of the `reducer` function.\n * @param reducer - Function to execute on each element.\n * @param initialValue - Initial value of the `accumulator` value passed to\n * the `reducer` function.\n *\n * @example\n * ```js\n * function largestOfTwo(one, two) {\n * return Math.max(one, two);\n * }\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const result = await cursor.reduce(largestOfTwo, 0);\n * console.log(result); // 5\n * console.log(cursor.hasNext); // false\n * const emptyResult = await cursor.reduce(largestOfTwo, 0);\n * console.log(emptyResult); // 0\n * ```\n *\n * @example\n * ```js\n * // BAD! NEEDLESSLY COMPLEX!\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const result = await cursor.reduce((accumulator, currentValue) => {\n * if (currentValue % 2 === 0) {\n * accumulator.even.push(...currentValue);\n * } else {\n * accumulator.odd.push(...currentValue);\n * }\n * return accumulator;\n * }, { odd: [], even: [] });\n * console.log(result); // { odd: [1, 3, 5], even: [2, 4] }\n *\n * // GOOD! MUCH SIMPLER!\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const odd = [];\n * const even = [];\n * for await (const currentValue of cursor) {\n * if (currentValue % 2 === 0) {\n * even.push(currentValue);\n * } else {\n * odd.push(currentValue);\n * }\n * }\n * console.log({ odd, even }); // { odd: [1, 3, 5], even: [2, 4] }\n * ```\n */\n async reduce<R>(\n reducer: (accumulator: R, currentValue: T, index: number, self: this) => R,\n initialValue: R\n ): Promise<R>;\n /**\n * Depletes the cursor by applying the `reducer` function to each item in\n * the cursor's remaining result list. Returns the return value of `reducer`\n * for the last item.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).\n *\n * @param R - Return type of the `reducer` function.\n * @param reducer - Function to execute on each element.\n *\n * @example\n * ```js\n * function largestOfTwo(one, two) {\n * return Math.max(one, two);\n * }\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const result = await cursor.reduce(largestOfTwo);\n * console.log(result); // 5\n * console.log(cursor.hasNext); // false\n * const emptyResult = await cursor.reduce(largestOfTwo);\n * console.log(emptyResult); // undefined\n * ```\n */\n async reduce<R>(\n reducer: (\n accumulator: T | R,\n currentValue: T,\n index: number,\n self: this\n ) => R\n ): Promise<R | undefined>;\n async reduce<R>(\n reducer: (accumulator: R, currentValue: T, index: number, self: this) => R,\n initialValue?: R\n ): Promise<R | undefined> {\n let index = 0;\n if (!this.hasNext) return initialValue;\n if (initialValue === undefined) {\n const value = (await this.next()) as any;\n initialValue = value as R;\n index += 1;\n }\n let value = initialValue;\n while (this.hasNext) {\n const item = await this.next();\n value = reducer(value, item!, index, this);\n index++;\n }\n return value;\n }\n\n /**\n * Kills the cursor and frees up associated database resources.\n *\n * This method has no effect if all batches have already been fetched.\n *\n * @example\n * ```js\n * const cursor1 = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * console.log(cursor1.hasMore); // false\n * await cursor1.kill(); // no effect\n *\n * const cursor2 = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * console.log(cursor2.hasMore); // true\n * await cursor2.kill(); // cursor is depleted\n * ```\n */\n async kill(): Promise<void> {\n return this.batches.kill();\n }\n}\n"]}
1
+ {"version":3,"file":"cursor.js","sourceRoot":"","sources":["../src/cursor.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;GAQG;AACH,iDAA2C;AAoH3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAa,kBAAkB;IAY7B;;OAEG;IACH,YACE,EAAY,EACZ,IAOC,EACD,OAAgB,EAChB,cAAwB;QAExB,MAAM,OAAO,GAAG,IAAI,0BAAU,CAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,0BAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CACxD,CAAC;QACF,IAAI,CAAC,GAAG,GAAG,EAAE,CAAC;QACd,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC;QACrC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,IAAI,CAAC,M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ACZ;QACD,IAAI,KAAK,GAAG,YAAY,CAAC;QACzB,OAAO,IAAI,CAAC,OAAO,EAAE;YACnB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;YAC/B,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,IAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;YAC3C,KAAK,EAAE,CAAC;SACT;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;;;;;;;;;;;;;OAkBG;IACH,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC7B,CAAC;CACF;AAtZD,kCAsZC","sourcesContent":["/**\n * ```ts\n * import type { ArrayCursor, BatchedArrayCursor } from \"arangojs/cursor\";\n * ```\n *\n * The \"cursor\" module provides cursor-related interfaces for TypeScript.\n *\n * @packageDocumentation\n */\nimport { LinkedList } from \"x3-linkedlist\";\nimport { Database } from \"./database\";\n\n/**\n * Additional information about the cursor.\n */\nexport interface CursorExtras {\n /**\n * Warnings encountered while executing the query.\n */\n warnings: {\n code: number;\n message: string;\n }[];\n /**\n * Query execution plan for the executed query.\n */\n plan?: Record<string, any>;\n /**\n * Additional profiling information for the executed query.\n */\n profile?: Record<string, number>;\n /**\n * Additional statistics about the query execution.\n */\n stats?: CursorStats;\n}\n\n/**\n * Additional statics about the query execution of the cursor.\n */\nexport interface CursorStats {\n /**\n * Total number of index entries read from in-memory caches for indexes of\n * type edge or persistent.\n */\n cacheHits: number;\n /**\n * Total number of cache read attempts for index entries that could not be\n * served from in-memory caches for indexes of type edge or persistent.\n */\n cacheMisses: number;\n /**\n * Total number of cursor objects created during query execution.\n */\n cursorsCreated: number;\n /**\n * Total number of times an existing cursor object was repurposed.\n */\n cursorsRearmed: number;\n /**\n * Total number of data-modification operations successfully executed.\n */\n writesExecuted: number;\n /**\n * Total number of data-modification operations that were unsuccessful, but have been ignored because of query option ignoreErrors.\n */\n writesIgnored: number;\n /**\n * Total number of documents iterated over when scanning a collection without an index.\n */\n scannedFull: number;\n /**\n * Total number of documents iterated over when scanning a collection using an index.\n */\n scannedIndex: number;\n /**\n * Total number of documents that were removed after executing a filter condition in a FilterNode.\n */\n filtered: number;\n /**\n * Maximum memory usage of the query while it was running.\n */\n peakMemoryUsage: number;\n /**\n * Execution time of the query in seconds.\n */\n executionTime: number;\n /**\n * Total number of documents that matched the search condition if the query’s final top-level LIMIT statement were not present.\n */\n fullCount?: number;\n /**\n * Total number of cluster-internal HTTP requests performed.\n */\n httpRequests: number;\n /**\n * Runtime statistics per query execution node if `profile` was set to `2` or greater.\n */\n nodes?: {\n /**\n * Execution node ID to correlate this node with nodes in the `extra.plan`.\n */\n id: number;\n /**\n * Number of calls in this node.\n */\n calls: number;\n /**\n * Number of temporary result items returned by this node.\n */\n items: number;\n filter: number;\n /**\n * Execution time of this node in seconds.\n */\n runtime: number;\n }[];\n}\n\ninterface BatchView<T = any> {\n isEmpty: boolean;\n more(): Promise<void>;\n shift(): T | undefined;\n}\n\n/**\n * The `BatchedArrayCursor` provides a batch-wise API to an {@link ArrayCursor}.\n *\n * When using TypeScript, cursors can be cast to a specific item type in order\n * to increase type safety.\n *\n * @param T - Type to use for each item. Defaults to `any`.\n *\n * @example\n * ```ts\n * const db = new Database();\n * const query = aql`FOR x IN 1..5 RETURN x`;\n * const cursor = await db.query(query) as ArrayCursor<number>;\n * const batches = cursor.batches;\n * ```\n *\n * @example\n * ```js\n * const db = new Database();\n * const query = aql`FOR x IN 1..10000 RETURN x`;\n * const cursor = await db.query(query, { batchSize: 10 });\n * for await (const batch of cursor.batches) {\n * // Process all values in a batch in parallel\n * await Promise.all(batch.map(\n * value => asyncProcessValue(value)\n * ));\n * }\n * ```\n */\nexport class BatchedArrayCursor<T = any> {\n protected _db: Database;\n protected _batches: LinkedList<LinkedList<any>>;\n protected _count?: number;\n protected _extra: CursorExtras;\n protected _hasMore: boolean;\n protected _nextBatchId?: string;\n protected _id: string | undefined;\n protected _hostUrl?: string;\n protected _allowDirtyRead?: boolean;\n protected _itemsCursor: ArrayCursor<T>;\n\n /**\n * @internal\n */\n constructor(\n db: Database,\n body: {\n extra: any;\n result: T[];\n hasMore: boolean;\n nextBatchId?: string;\n id: string;\n count: number;\n },\n hostUrl?: string,\n allowDirtyRead?: boolean\n ) {\n const batches = new LinkedList(\n body.result.length ? [new LinkedList(body.result)] : []\n );\n this._db = db;\n this._batches = batches;\n this._id = body.id;\n this._hasMore = Boolean(body.id && body.hasMore);\n this._nextBatchId = body.nextBatchId;\n this._hostUrl = hostUrl;\n this._count = body.count;\n this._extra = body.extra;\n this._allowDirtyRead = allowDirtyRead;\n this._itemsCursor = new ArrayCursor(this, {\n get isEmpty() {\n return !batches.length;\n },\n more: () => this._more(),\n shift: () => {\n let batch = batches.first?.value;\n while (batch && !batch.length) {\n batches.shift();\n batch = batches.first?.value;\n }\n if (!batch) return undefined;\n const value = batch.shift();\n if (!batch.length) batches.shift();\n return value;\n },\n });\n }\n\n protected async _more(): Promise<void> {\n if (!this._id || !this.hasMore) return;\n const body = await this._db.request({\n method: \"POST\",\n path: this._nextBatchId\n ? `/_api/cursor/${encodeURIComponent(this._id)}/${this._nextBatchId}`\n : `/_api/cursor/${encodeURIComponent(this._id)}`,\n hostUrl: this._hostUrl,\n allowDirtyRead: this._allowDirtyRead,\n });\n this._batches.push(new LinkedList(body.result));\n this._hasMore = body.hasMore;\n this._nextBatchId = body.nextBatchId;\n }\n\n /**\n * An {@link ArrayCursor} providing item-wise access to the cursor result set.\n *\n * See also {@link ArrayCursor#batches}.\n */\n get items() {\n return this._itemsCursor;\n }\n\n /**\n * Additional information about the cursor.\n */\n get extra(): Readonly<CursorExtras> {\n return this._extra;\n }\n\n /**\n * Total number of documents in the query result. Only available if the\n * `count` option was used.\n */\n get count(): number | undefined {\n return this._count;\n }\n\n /**\n * Whether the cursor has any remaining batches that haven't yet been\n * fetched. If set to `false`, all batches have been fetched and no\n * additional requests to the server will be made when consuming any\n * remaining batches from this cursor.\n */\n get hasMore(): boolean {\n return this._hasMore;\n }\n\n /**\n * Whether the cursor has more batches. If set to `false`, the cursor has\n * already been depleted and contains no more batches.\n */\n get hasNext(): boolean {\n return this.hasMore || Boolean(this._batches.length);\n }\n\n /**\n * Enables use with `for await` to deplete the cursor by asynchronously\n * yielding every batch in the cursor's remaining result set.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`\n * FOR user IN users\n * FILTER user.isActive\n * RETURN user\n * `);\n * for await (const users of cursor.batches) {\n * for (const user of users) {\n * console.log(user.email, user.isAdmin);\n * }\n * }\n * ```\n */\n async *[Symbol.asyncIterator](): AsyncGenerator<T[], undefined, undefined> {\n while (this.hasNext) {\n yield this.next() as Promise<T[]>;\n }\n return undefined;\n }\n\n /**\n * Loads all remaining batches from the server.\n *\n * **Warning**: This may impact memory use when working with very large\n * query result sets.\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 1 }\n * );\n * console.log(cursor.hasMore); // true\n * await cursor.batches.loadAll();\n * console.log(cursor.hasMore); // false\n * console.log(cursor.hasNext); // true\n * for await (const item of cursor) {\n * console.log(item);\n * // No server roundtrips necessary any more\n * }\n * ```\n */\n async loadAll(): Promise<void> {\n while (this._hasMore) {\n await this._more();\n }\n }\n\n /**\n * Depletes the cursor, then returns an array containing all batches in the\n * cursor's remaining result list.\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * const result = await cursor.batches.all(); // [[1, 2], [3, 4], [5]]\n * console.log(cursor.hasNext); // false\n * ```\n */\n async all(): Promise<T[][]> {\n return this.map((batch) => batch);\n }\n\n /**\n * Advances the cursor and returns all remaining values in the cursor's\n * current batch. If the current batch has already been exhausted, fetches\n * the next batch from the server and returns it, or `undefined` if the\n * cursor has been depleted.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR i IN 1..10 RETURN i`,\n * { batchSize: 5 }\n * );\n * const firstBatch = await cursor.batches.next(); // [1, 2, 3, 4, 5]\n * await cursor.next(); // 6\n * const lastBatch = await cursor.batches.next(); // [7, 8, 9, 10]\n * console.log(cursor.hasNext); // false\n * ```\n */\n async next(): Promise<T[] | undefined> {\n while (!this._batches.length && this.hasNext) {\n await this._more();\n }\n if (!this._batches.length) {\n return undefined;\n }\n const batch = this._batches.shift();\n if (!batch) return undefined;\n const values = [...batch.values()];\n batch.clear(true);\n return values;\n }\n\n /**\n * Advances the cursor by applying the `callback` function to each item in\n * the cursor's remaining result list until the cursor is depleted or\n * `callback` returns the exact value `false`. Returns a promise that\n * evalues to `true` unless the function returned `false`.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).\n *\n * @param callback - Function to execute on each element.\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * const result = await cursor.batches.forEach((currentBatch) => {\n * for (const value of currentBatch) {\n * console.log(value);\n * }\n * });\n * console.log(result) // true\n * console.log(cursor.hasNext); // false\n * ```\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * const result = await cursor.batches.forEach((currentBatch) => {\n * for (const value of currentBatch) {\n * console.log(value);\n * }\n * return false; // stop after the first batch\n * });\n * console.log(result); // false\n * console.log(cursor.hasNext); // true\n * ```\n */\n async forEach(\n callback: (currentBatch: T[], index: number, self: this) => false | void\n ): Promise<boolean> {\n let index = 0;\n while (this.hasNext) {\n const currentBatch = await this.next();\n const result = callback(currentBatch!, index, this);\n index++;\n if (result === false) return result;\n if (this.hasNext) await this._more();\n }\n return true;\n }\n\n /**\n * Depletes the cursor by applying the `callback` function to each batch in\n * the cursor's remaining result list. Returns an array containing the\n * return values of `callback` for each batch.\n *\n * **Note**: This creates an array of all return values, which may impact\n * memory use when working with very large query result sets. Consider using\n * {@link BatchedArrayCursor#forEach}, {@link BatchedArrayCursor#reduce} or\n * {@link BatchedArrayCursor#flatMap} instead.\n *\n * See also:\n * [`Array.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).\n *\n * @param R - Return type of the `callback` function.\n * @param callback - Function to execute on each element.\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * const squares = await cursor.batches.map((currentBatch) => {\n * return currentBatch.map((value) => value ** 2);\n * });\n * console.log(squares); // [[1, 4], [9, 16], [25]]\n * console.log(cursor.hasNext); // false\n * ```\n */\n async map<R>(\n callback: (currentBatch: T[], index: number, self: this) => R\n ): Promise<R[]> {\n let index = 0;\n const result: any[] = [];\n while (this.hasNext) {\n const currentBatch = await this.next();\n result.push(callback(currentBatch!, index, this));\n index++;\n }\n return result;\n }\n\n /**\n * Depletes the cursor by applying the `callback` function to each batch in\n * the cursor's remaining result list. Returns an array containing the\n * return values of `callback` for each batch, flattened to a depth of 1.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.flatMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).\n *\n * @param R - Return type of the `callback` function.\n * @param callback - Function to execute on each element.\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * const squares = await cursor.batches.flatMap((currentBatch) => {\n * return currentBatch.map((value) => value ** 2);\n * });\n * console.log(squares); // [1, 1, 2, 4, 3, 9, 4, 16, 5, 25]\n * console.log(cursor.hasNext); // false\n * ```\n *\n * @example\n * ```js\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 1 }\n * );\n * const odds = await cursor.batches.flatMap((currentBatch) => {\n * if (currentBatch[0] % 2 === 0) {\n * return []; // empty array flattens into nothing\n * }\n * return currentBatch;\n * });\n * console.logs(odds); // [1, 3, 5]\n * ```\n */\n async flatMap<R>(\n callback: (currentBatch: T[], index: number, self: this) => R | R[]\n ): Promise<R[]> {\n let index = 0;\n const result: any[] = [];\n while (this.hasNext) {\n const currentBatch = await this.next();\n const value = callback(currentBatch!, index, this);\n if (Array.isArray(value)) {\n result.push(...value);\n } else {\n result.push(value);\n }\n index++;\n }\n return result;\n }\n\n /**\n * Depletes the cursor by applying the `reducer` function to each batch in\n * the cursor's remaining result list. Returns the return value of `reducer`\n * for the last batch.\n *\n * **Note**: Most complex uses of the `reduce` method can be replaced with\n * simpler code using {@link BatchedArrayCursor#forEach} or the `for await`\n * syntax.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).\n *\n * @param R - Return type of the `reducer` function.\n * @param reducer - Function to execute on each element.\n * @param initialValue - Initial value of the `accumulator` value passed to\n * the `reducer` function.\n *\n * @example\n * ```js\n * function largestValue(baseline, values) {\n * return Math.max(baseline, ...values);\n * }\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 3 }\n * );\n * const result = await cursor.batches.reduce(largestValue, 0);\n * console.log(result); // 5\n * console.log(cursor.hasNext); // false\n * const emptyResult = await cursor.batches.reduce(largestValue, 0);\n * console.log(emptyResult); // 0\n * ```\n *\n * @example\n * ```js\n * // BAD! NEEDLESSLY COMPLEX!\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 1 }\n * );\n * const result = await cursor.reduce((accumulator, currentBatch) => {\n * if (currentBatch[0] % 2 === 0) {\n * accumulator.even.push(...currentBatch);\n * } else {\n * accumulator.odd.push(...currentBatch);\n * }\n * return accumulator;\n * }, { odd: [], even: [] });\n * console.log(result); // { odd: [1, 3, 5], even: [2, 4] }\n *\n * // GOOD! MUCH SIMPLER!\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const odd = [];\n * const even = [];\n * for await (const currentBatch of cursor) {\n * if (currentBatch[0] % 2 === 0) {\n * even.push(...currentBatch);\n * } else {\n * odd.push(...currentBatch);\n * }\n * }\n * console.log({ odd, even }); // { odd: [1, 3, 5], even: [2, 4] }\n * ```\n */\n async reduce<R>(\n reducer: (\n accumulator: R,\n currentBatch: T[],\n index: number,\n self: this\n ) => R,\n initialValue: R\n ): Promise<R>;\n\n /**\n * Depletes the cursor by applying the `reducer` function to each batch in\n * the cursor's remaining result list. Returns the return value of `reducer`\n * for the last batch.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).\n *\n * @param R - Return type of the `reducer` function.\n * @param reducer - Function to execute on each element.\n *\n * @example\n * ```js\n * function largestValue(values1, values2) {\n * return [Math.max(...values1, ...values2)];\n * }\n * const cursor = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 3 }\n * );\n * const result = await cursor.batches.reduce(largestValue);\n * console.log(result); // [5]\n * console.log(cursor.hasNext); // false\n * ```\n *\n */\n async reduce<R>(\n reducer: (\n accumulator: T[] | R,\n currentBatch: T[],\n index: number,\n self: this\n ) => R\n ): Promise<R | undefined>;\n async reduce<R>(\n reducer: (\n accumulator: R,\n currentBatch: T[],\n index: number,\n self: this\n ) => R,\n initialValue?: R\n ): Promise<R | undefined> {\n let index = 0;\n if (!this.hasNext) return initialValue;\n if (initialValue === undefined) {\n initialValue = (await this.next()) as any;\n index += 1;\n }\n let value = initialValue as R;\n while (this.hasNext) {\n const currentBatch = await this.next();\n value = reducer(value, currentBatch!, index, this);\n index++;\n }\n return value;\n }\n\n /**\n * Drains the cursor and frees up associated database resources.\n *\n * This method has no effect if all batches have already been consumed.\n *\n * @example\n * ```js\n * const cursor1 = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * console.log(cursor1.hasMore); // false\n * await cursor1.kill(); // no effect\n *\n * const cursor2 = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * console.log(cursor2.hasMore); // true\n * await cursor2.kill(); // cursor is depleted\n * ```\n */\n async kill(): Promise<void> {\n if (this._batches.length) {\n for (const batch of this._batches.values()) {\n batch.clear();\n }\n this._batches.clear();\n }\n if (!this.hasNext) return undefined;\n return this._db.request(\n {\n method: \"DELETE\",\n path: `/_api/cursor/${encodeURIComponent(this._id!)}`,\n },\n () => {\n this._hasMore = false;\n return undefined;\n }\n );\n }\n}\n\n/**\n * The `ArrayCursor` type represents a cursor returned from a\n * {@link database.Database#query}.\n *\n * When using TypeScript, cursors can be cast to a specific item type in order\n * to increase type safety.\n *\n * See also {@link BatchedArrayCursor}.\n *\n * @param T - Type to use for each item. Defaults to `any`.\n *\n * @example\n * ```ts\n * const db = new Database();\n * const query = aql`FOR x IN 1..5 RETURN x`;\n * const result = await db.query(query) as ArrayCursor<number>;\n * ```\n *\n * @example\n * ```js\n * const db = new Database();\n * const query = aql`FOR x IN 1..10 RETURN x`;\n * const cursor = await db.query(query);\n * for await (const value of cursor) {\n * // Process each value asynchronously\n * await processValue(value);\n * }\n * ```\n */\nexport class ArrayCursor<T = any> {\n protected _batches: BatchedArrayCursor<T>;\n protected _view: BatchView<T>;\n\n /**\n * @internal\n */\n constructor(batchedCursor: BatchedArrayCursor, view: BatchView<T>) {\n this._batches = batchedCursor;\n this._view = view;\n }\n\n /**\n * A {@link BatchedArrayCursor} providing batch-wise access to the cursor\n * result set.\n *\n * See also {@link BatchedArrayCursor#items}.\n */\n get batches() {\n return this._batches;\n }\n\n /**\n * Additional information about the cursor.\n */\n get extra(): CursorExtras {\n return this.batches.extra;\n }\n\n /**\n * Total number of documents in the query result. Only available if the\n * `count` option was used.\n */\n get count(): number | undefined {\n return this.batches.count;\n }\n\n /**\n * Whether the cursor has more values. If set to `false`, the cursor has\n * already been depleted and contains no more items.\n */\n get hasNext(): boolean {\n return this.batches.hasNext;\n }\n\n /**\n * Enables use with `for await` to deplete the cursor by asynchronously\n * yielding every value in the cursor's remaining result set.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`\n * FOR user IN users\n * FILTER user.isActive\n * RETURN user\n * `);\n * for await (const user of cursor) {\n * console.log(user.email, user.isAdmin);\n * }\n * ```\n */\n async *[Symbol.asyncIterator](): AsyncGenerator<T, undefined, undefined> {\n while (this.hasNext) {\n yield this.next() as Promise<T>;\n }\n return undefined;\n }\n\n /**\n * Depletes the cursor, then returns an array containing all values in the\n * cursor's remaining result list.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const result = await cursor.all(); // [1, 2, 3, 4, 5]\n * console.log(cursor.hasNext); // false\n * ```\n */\n async all(): Promise<T[]> {\n return this.batches.flatMap((v) => v);\n }\n\n /**\n * Advances the cursor and returns the next value in the cursor's remaining\n * result list, or `undefined` if the cursor has been depleted.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..3 RETURN x`);\n * const one = await cursor.next(); // 1\n * const two = await cursor.next(); // 2\n * const three = await cursor.next(); // 3\n * const empty = await cursor.next(); // undefined\n * ```\n */\n async next(): Promise<T | undefined> {\n while (this._view.isEmpty && this.batches.hasMore) {\n await this._view.more();\n }\n if (this._view.isEmpty) {\n return undefined;\n }\n return this._view.shift();\n }\n\n /**\n * Advances the cursor by applying the `callback` function to each item in\n * the cursor's remaining result list until the cursor is depleted or\n * `callback` returns the exact value `false`. Returns a promise that\n * evalues to `true` unless the function returned `false`.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.forEach`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach).\n *\n * @param callback - Function to execute on each element.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const result = await cursor.forEach((currentValue) => {\n * console.log(currentValue);\n * });\n * console.log(result) // true\n * console.log(cursor.hasNext); // false\n * ```\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const result = await cursor.forEach((currentValue) => {\n * console.log(currentValue);\n * return false; // stop after the first item\n * });\n * console.log(result); // false\n * console.log(cursor.hasNext); // true\n * ```\n */\n async forEach(\n callback: (currentValue: T, index: number, self: this) => false | void\n ): Promise<boolean> {\n let index = 0;\n while (this.hasNext) {\n const value = await this.next();\n const result = callback(value!, index, this);\n index++;\n if (result === false) return result;\n }\n return true;\n }\n\n /**\n * Depletes the cursor by applying the `callback` function to each item in\n * the cursor's remaining result list. Returns an array containing the\n * return values of `callback` for each item.\n *\n * **Note**: This creates an array of all return values, which may impact\n * memory use when working with very large query result sets. Consider using\n * {@link ArrayCursor#forEach}, {@link ArrayCursor#reduce} or\n * {@link ArrayCursor#flatMap} instead.\n *\n * See also:\n * [`Array.prototype.map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map).\n *\n * @param R - Return type of the `callback` function.\n * @param callback - Function to execute on each element.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const squares = await cursor.map((currentValue) => {\n * return currentValue ** 2;\n * });\n * console.log(squares); // [1, 4, 9, 16, 25]\n * console.log(cursor.hasNext); // false\n * ```\n */\n async map<R>(\n callback: (currentValue: T, index: number, self: this) => R\n ): Promise<R[]> {\n let index = 0;\n const result: any[] = [];\n while (this.hasNext) {\n const value = await this.next();\n result.push(callback(value!, index, this));\n index++;\n }\n return result;\n }\n\n /**\n * Depletes the cursor by applying the `callback` function to each item in\n * the cursor's remaining result list. Returns an array containing the\n * return values of `callback` for each item, flattened to a depth of 1.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.flatMap`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/flatMap).\n *\n * @param R - Return type of the `callback` function.\n * @param callback - Function to execute on each element.\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const squares = await cursor.flatMap((currentValue) => {\n * return [currentValue, currentValue ** 2];\n * });\n * console.log(squares); // [1, 1, 2, 4, 3, 9, 4, 16, 5, 25]\n * console.log(cursor.hasNext); // false\n * ```\n *\n * @example\n * ```js\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const odds = await cursor.flatMap((currentValue) => {\n * if (currentValue % 2 === 0) {\n * return []; // empty array flattens into nothing\n * }\n * return currentValue; // or [currentValue]\n * });\n * console.logs(odds); // [1, 3, 5]\n * ```\n */\n async flatMap<R>(\n callback: (currentValue: T, index: number, self: this) => R | R[]\n ): Promise<R[]> {\n let index = 0;\n const result: any[] = [];\n while (this.hasNext) {\n const value = await this.next();\n const item = callback(value!, index, this);\n if (Array.isArray(item)) {\n result.push(...item);\n } else {\n result.push(item);\n }\n index++;\n }\n return result;\n }\n\n /**\n * Depletes the cursor by applying the `reducer` function to each item in\n * the cursor's remaining result list. Returns the return value of `reducer`\n * for the last item.\n *\n * **Note**: Most complex uses of the `reduce` method can be replaced with\n * simpler code using {@link ArrayCursor#forEach} or the `for await` syntax.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).\n *\n * @param R - Return type of the `reducer` function.\n * @param reducer - Function to execute on each element.\n * @param initialValue - Initial value of the `accumulator` value passed to\n * the `reducer` function.\n *\n * @example\n * ```js\n * function largestOfTwo(one, two) {\n * return Math.max(one, two);\n * }\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const result = await cursor.reduce(largestOfTwo, 0);\n * console.log(result); // 5\n * console.log(cursor.hasNext); // false\n * const emptyResult = await cursor.reduce(largestOfTwo, 0);\n * console.log(emptyResult); // 0\n * ```\n *\n * @example\n * ```js\n * // BAD! NEEDLESSLY COMPLEX!\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const result = await cursor.reduce((accumulator, currentValue) => {\n * if (currentValue % 2 === 0) {\n * accumulator.even.push(...currentValue);\n * } else {\n * accumulator.odd.push(...currentValue);\n * }\n * return accumulator;\n * }, { odd: [], even: [] });\n * console.log(result); // { odd: [1, 3, 5], even: [2, 4] }\n *\n * // GOOD! MUCH SIMPLER!\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const odd = [];\n * const even = [];\n * for await (const currentValue of cursor) {\n * if (currentValue % 2 === 0) {\n * even.push(currentValue);\n * } else {\n * odd.push(currentValue);\n * }\n * }\n * console.log({ odd, even }); // { odd: [1, 3, 5], even: [2, 4] }\n * ```\n */\n async reduce<R>(\n reducer: (accumulator: R, currentValue: T, index: number, self: this) => R,\n initialValue: R\n ): Promise<R>;\n /**\n * Depletes the cursor by applying the `reducer` function to each item in\n * the cursor's remaining result list. Returns the return value of `reducer`\n * for the last item.\n *\n * **Note**: If the result set spans multiple batches, any remaining batches\n * will only be fetched on demand. Depending on the cursor's TTL and the\n * processing speed, this may result in the server discarding the cursor\n * before it is fully depleted.\n *\n * See also:\n * [`Array.prototype.reduce`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce).\n *\n * @param R - Return type of the `reducer` function.\n * @param reducer - Function to execute on each element.\n *\n * @example\n * ```js\n * function largestOfTwo(one, two) {\n * return Math.max(one, two);\n * }\n * const cursor = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * const result = await cursor.reduce(largestOfTwo);\n * console.log(result); // 5\n * console.log(cursor.hasNext); // false\n * const emptyResult = await cursor.reduce(largestOfTwo);\n * console.log(emptyResult); // undefined\n * ```\n */\n async reduce<R>(\n reducer: (\n accumulator: T | R,\n currentValue: T,\n index: number,\n self: this\n ) => R\n ): Promise<R | undefined>;\n async reduce<R>(\n reducer: (accumulator: R, currentValue: T, index: number, self: this) => R,\n initialValue?: R\n ): Promise<R | undefined> {\n let index = 0;\n if (!this.hasNext) return initialValue;\n if (initialValue === undefined) {\n const value = (await this.next()) as any;\n initialValue = value as R;\n index += 1;\n }\n let value = initialValue;\n while (this.hasNext) {\n const item = await this.next();\n value = reducer(value, item!, index, this);\n index++;\n }\n return value;\n }\n\n /**\n * Kills the cursor and frees up associated database resources.\n *\n * This method has no effect if all batches have already been fetched.\n *\n * @example\n * ```js\n * const cursor1 = await db.query(aql`FOR x IN 1..5 RETURN x`);\n * console.log(cursor1.hasMore); // false\n * await cursor1.kill(); // no effect\n *\n * const cursor2 = await db.query(\n * aql`FOR x IN 1..5 RETURN x`,\n * { batchSize: 2 }\n * );\n * console.log(cursor2.hasMore); // true\n * await cursor2.kill(); // cursor is depleted\n * ```\n */\n async kill(): Promise<void> {\n return this.batches.kill();\n }\n}\n"]}