documentdb-typescript
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -12,2 +12,4 @@ "use strict"; | ||
const Util_1 = require("./Util"); | ||
// polyfill Symbol.asyncIterator | ||
Symbol.asyncIterator = Symbol.asyncIterator || Symbol("Symbol.asyncIterator"); | ||
/** Represents asynchronously loaded query result sets as a stream; the type parameter represents the query result type, i.e. a full document resource type for `SELECT * FROM` queries, an object with only projected properties for `SELECT x, y, ... FROM` queries, or even a scalar value for `SELECT VALUE ... FROM` queries */ | ||
@@ -22,2 +24,4 @@ class DocumentStream { | ||
this.timeout = this._collection.database.client.timeout; | ||
/** This property makes the entire instance usable as an async iterator */ | ||
this[Symbol.asyncIterator] = () => this; | ||
/** @internal Promise for the last operation's result */ | ||
@@ -38,5 +42,2 @@ this._nextP = Promise.resolve(true); | ||
} | ||
// TODO: the following method can be used to turn this object into an ES6 | ||
// asynchronous iterator, when that feature lands in TypeScript 2.3 (?), | ||
// i.e. we just need [Symbol.asyncIterator] = () => this | ||
/** Get the next result (asynchronously), if any; promise resolves to a `{ value, done }` pair, or is rejected if an error occurred; subsequent calls to this function will return promises for results after the current result (i.e. requests are queued) */ | ||
@@ -43,0 +44,0 @@ next() { |
{ | ||
"name": "documentdb-typescript", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "TypeScript API for Microsoft Azure DocumentDB", | ||
@@ -12,3 +12,3 @@ "keywords": [ | ||
"main": "./dist/index.js", | ||
"typings": "./typings/index.d.ts", | ||
"typings": "./typings-compat.d.ts", | ||
"scripts": { | ||
@@ -33,4 +33,4 @@ "build": "tsc -p src", | ||
"@types/node": "^7.0.8", | ||
"typescript": "^2.1.0" | ||
"typescript": "^2.3.0" | ||
} | ||
} |
@@ -1,8 +0,3 @@ | ||
export interface AsyncIterator<T> { | ||
next(value?: any): Promise<IteratorResult<T>>; | ||
return?(value?: any): Promise<IteratorResult<T>>; | ||
throw?(e?: any): Promise<IteratorResult<T>>; | ||
} | ||
/** Represents asynchronously loaded query result sets as a stream; the type parameter represents the query result type, i.e. a full document resource type for `SELECT * FROM` queries, an object with only projected properties for `SELECT x, y, ... FROM` queries, or even a scalar value for `SELECT VALUE ... FROM` queries */ | ||
export declare class DocumentStream<T> implements AsyncIterator<T> { | ||
export declare class DocumentStream<T> implements AsyncIterable<T> { | ||
private _collection; | ||
@@ -17,2 +12,4 @@ private _uid; | ||
read(): Promise<T | null>; | ||
/** This property makes the entire instance usable as an async iterator */ | ||
[Symbol.asyncIterator]: () => this; | ||
/** Get the next result (asynchronously), if any; promise resolves to a `{ value, done }` pair, or is rejected if an error occurred; subsequent calls to this function will return promises for results after the current result (i.e. requests are queued) */ | ||
@@ -19,0 +16,0 @@ next(): Promise<{ |
83518
64
20
1305