shelving 1.80.1 → 1.81.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/constraint/FilterConstraints.js +1 -1
- package/constraint/QueryConstraints.js +1 -1
- package/constraint/SortConstraints.js +1 -1
- package/db/Change.js +3 -3
- package/db/Collection.d.ts +0 -5
- package/db/Collection.js +0 -4
- package/db/Database.d.ts +0 -5
- package/db/Database.js +0 -4
- package/db/Item.d.ts +9 -16
- package/db/Item.js +9 -10
- package/db/Query.d.ts +7 -14
- package/db/Query.js +11 -12
- package/firestore/client/FirestoreClientProvider.d.ts +3 -5
- package/firestore/client/FirestoreClientProvider.js +10 -11
- package/firestore/lite/FirestoreLiteProvider.d.ts +3 -4
- package/firestore/lite/FirestoreLiteProvider.js +3 -8
- package/firestore/server/FirestoreServerProvider.d.ts +4 -6
- package/firestore/server/FirestoreServerProvider.js +12 -16
- package/index.d.ts +8 -7
- package/index.js +13 -16
- package/iterate/AbstractGenerator.d.ts +8 -0
- package/iterate/AbstractGenerator.js +26 -0
- package/iterate/InspectGenerator.d.ts +32 -0
- package/iterate/InspectGenerator.js +67 -0
- package/iterate/ThroughGenerator.d.ts +9 -0
- package/iterate/ThroughGenerator.js +18 -0
- package/iterate/index.d.ts +3 -0
- package/iterate/index.js +3 -0
- package/package.json +3 -2
- package/provider/CacheProvider.d.ts +2 -4
- package/provider/CacheProvider.js +12 -38
- package/provider/DebugProvider.d.ts +2 -4
- package/provider/DebugProvider.js +98 -71
- package/provider/MemoryProvider.d.ts +27 -24
- package/provider/MemoryProvider.js +138 -101
- package/provider/Provider.d.ts +26 -45
- package/provider/ThroughProvider.d.ts +4 -6
- package/provider/ThroughProvider.js +8 -8
- package/provider/ValidationProvider.d.ts +2 -4
- package/provider/ValidationProvider.js +18 -37
- package/provider/index.d.ts +0 -1
- package/provider/index.js +0 -1
- package/react/index.d.ts +2 -1
- package/react/index.js +3 -3
- package/react/useCache.d.ts +1 -1
- package/react/useItem.d.ts +3 -7
- package/react/useItem.js +12 -30
- package/react/useQuery.d.ts +6 -8
- package/react/useQuery.js +23 -39
- package/react/useSequence.d.ts +9 -0
- package/react/useSequence.js +19 -0
- package/react/useState.d.ts +11 -0
- package/react/useState.js +12 -0
- package/sequence/AbstractSequence.d.ts +8 -0
- package/sequence/AbstractSequence.js +26 -0
- package/sequence/DeferredSequence.d.ts +30 -0
- package/sequence/DeferredSequence.js +64 -0
- package/sequence/InspectSequence.d.ts +32 -0
- package/sequence/InspectSequence.js +67 -0
- package/sequence/LazyDeferredSequence.d.ts +9 -0
- package/sequence/LazyDeferredSequence.js +14 -0
- package/sequence/RegisteringSequence.d.ts +9 -0
- package/sequence/RegisteringSequence.js +51 -0
- package/sequence/ThroughSequence.d.ts +9 -0
- package/sequence/ThroughSequence.js +20 -0
- package/sequence/index.d.ts +6 -0
- package/sequence/index.js +6 -0
- package/state/ArrayState.js +3 -3
- package/state/BooleanState.js +1 -1
- package/state/DataState.d.ts +5 -9
- package/state/DataState.js +7 -16
- package/state/ObjectState.d.ts +5 -4
- package/state/ObjectState.js +8 -7
- package/state/State.d.ts +12 -16
- package/state/State.js +27 -49
- package/state/index.d.ts +0 -1
- package/state/index.js +0 -1
- package/test/util.d.ts +12 -2
- package/test/util.js +26 -7
- package/util/activity.d.ts +38 -0
- package/util/activity.js +64 -0
- package/util/async.d.ts +17 -14
- package/util/async.js +20 -31
- package/util/class.d.ts +1 -1
- package/util/error.d.ts +1 -2
- package/util/error.js +0 -1
- package/util/function.d.ts +6 -0
- package/util/index.d.ts +2 -0
- package/util/index.js +2 -0
- package/util/iterate.d.ts +2 -53
- package/util/iterate.js +2 -88
- package/util/sequence.d.ts +22 -0
- package/util/sequence.js +75 -0
- package/observe/AbstractObserver.d.ts +0 -15
- package/observe/AbstractObserver.js +0 -42
- package/observe/AsyncObserver.d.ts +0 -5
- package/observe/AsyncObserver.js +0 -8
- package/observe/LastSubject.d.ts +0 -5
- package/observe/LastSubject.js +0 -12
- package/observe/MatchObserver.d.ts +0 -9
- package/observe/MatchObserver.js +0 -12
- package/observe/MatchableObserver.d.ts +0 -7
- package/observe/MatchableObserver.js +0 -10
- package/observe/Observable.d.ts +0 -24
- package/observe/Observable.js +0 -4
- package/observe/Observer.d.ts +0 -31
- package/observe/Observer.js +0 -48
- package/observe/OnceObserver.d.ts +0 -5
- package/observe/OnceObserver.js +0 -8
- package/observe/Subject.d.ts +0 -46
- package/observe/Subject.js +0 -116
- package/observe/ThroughObserver.d.ts +0 -5
- package/observe/ThroughObserver.js +0 -8
- package/observe/TransformObserver.d.ts +0 -9
- package/observe/TransformObserver.js +0 -12
- package/observe/TransformableObserver.d.ts +0 -7
- package/observe/TransformableObserver.js +0 -8
- package/observe/index.d.ts +0 -13
- package/observe/index.js +0 -13
- package/observe/util.d.ts +0 -24
- package/observe/util.js +0 -34
- package/provider/BatchProvider.d.ts +0 -26
- package/provider/BatchProvider.js +0 -75
- package/react/useSubscribe.d.ts +0 -9
- package/react/useSubscribe.js +0 -22
- package/state/SelfClosingState.d.ts +0 -18
- package/state/SelfClosingState.js +0 -34
|
@@ -22,6 +22,6 @@ export class FilterConstraints extends Constraints {
|
|
|
22
22
|
}
|
|
23
23
|
// Stringify as object syntax.
|
|
24
24
|
toString() {
|
|
25
|
-
return `{${this._constraints.map(String).join(",")}
|
|
25
|
+
return this._constraints.length ? `"filters":{${this._constraints.map(String).join(",")}}` : "";
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -87,7 +87,7 @@ export class QueryConstraints extends Constraint {
|
|
|
87
87
|
}
|
|
88
88
|
// Implement toString()
|
|
89
89
|
toString() {
|
|
90
|
-
return
|
|
90
|
+
return [this.filters.toString(), this.sorts.toString(), typeof this.limit === "number" ? `"limit":${this.limit}` : null].filter(Boolean).join(",");
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
function* _getAfterFilters(sorts, item) {
|
|
@@ -24,6 +24,6 @@ export class SortConstraints extends Constraints {
|
|
|
24
24
|
}
|
|
25
25
|
// Stringify as array syntax.
|
|
26
26
|
toString() {
|
|
27
|
-
return `[${this._constraints.map(String).join(",")}]
|
|
27
|
+
return this._constraints.length ? `"sorts":[${this._constraints.map(String).join(",")}]` : "";
|
|
28
28
|
}
|
|
29
29
|
}
|
package/db/Change.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
2
2
|
import { FilterConstraint } from "../constraint/FilterConstraint.js";
|
|
3
3
|
import { notNullish } from "../util/null.js";
|
|
4
|
-
import {
|
|
4
|
+
import { flattenItems } from "../util/iterate.js";
|
|
5
5
|
/** Apply a set of changes to a synchronous provider. */
|
|
6
6
|
export function changeProvider(provider, ...changes) {
|
|
7
|
-
return Array.from(
|
|
7
|
+
return Array.from(flattenItems(changes)).filter(notNullish).map(_changeItem, provider);
|
|
8
8
|
}
|
|
9
9
|
function _changeItem(change) {
|
|
10
10
|
const { action, collection } = change;
|
|
@@ -20,7 +20,7 @@ function _changeItem(change) {
|
|
|
20
20
|
}
|
|
21
21
|
/** Apply a set of changes to an asynchronous provider. */
|
|
22
22
|
export function changeAsyncProvider(provider, ...changes) {
|
|
23
|
-
return Promise.all(Array.from(
|
|
23
|
+
return Promise.all(Array.from(flattenItems(changes)).filter(notNullish).map(_changeAsyncItem, provider));
|
|
24
24
|
}
|
|
25
25
|
async function _changeAsyncItem(change) {
|
|
26
26
|
const { collection, action } = change;
|
package/db/Collection.d.ts
CHANGED
|
@@ -4,9 +4,6 @@ import type { FilterList } from "../constraint/FilterConstraint.js";
|
|
|
4
4
|
import type { SortList } from "../constraint/SortConstraint.js";
|
|
5
5
|
import type { DeepIterable } from "../util/iterate.js";
|
|
6
6
|
import type { Updates } from "../update/DataUpdate.js";
|
|
7
|
-
import type { PartialObserver } from "../observe/Observer.js";
|
|
8
|
-
import type { Dispatch } from "../util/function.js";
|
|
9
|
-
import type { Unsubscribe } from "../observe/Observable.js";
|
|
10
7
|
import type { AsyncDatabase, Database } from "./Database.js";
|
|
11
8
|
import { ItemData, AsyncItem, Item, ItemValue } from "./Item.js";
|
|
12
9
|
import { AsyncQuery, Query } from "./Query.js";
|
|
@@ -23,8 +20,6 @@ declare abstract class BaseCollection<T extends Datas = Datas, K extends Key<T>
|
|
|
23
20
|
abstract change(...changes: DeepIterable<Nullish<WriteChange<T, K>>>[]): ItemChanges<T, K> | Promise<ItemChanges<T, K>>;
|
|
24
21
|
/** Get an item from this collection. */
|
|
25
22
|
abstract get(id: string): ItemValue<T[K]> | Promise<ItemValue<T[K]>>;
|
|
26
|
-
/** Subscribe a document from a collection in this database. */
|
|
27
|
-
subscribe(id: string, next: PartialObserver<ItemValue<T[K]>> | Dispatch<[ItemValue<T[K]>]>): Unsubscribe;
|
|
28
23
|
/** Add an item to this collection. */
|
|
29
24
|
abstract add(data: T[K]): string | Promise<string>;
|
|
30
25
|
/** Set a document in this collection. */
|
package/db/Collection.js
CHANGED
|
@@ -3,10 +3,6 @@ import { AsyncQuery, Query } from "./Query.js";
|
|
|
3
3
|
import { changeAsyncProvider, changeProvider } from "./Change.js";
|
|
4
4
|
/** Reference to a collection in a synchronous or asynchronous provider. */
|
|
5
5
|
class BaseCollection {
|
|
6
|
-
/** Subscribe a document from a collection in this database. */
|
|
7
|
-
subscribe(id, next) {
|
|
8
|
-
return this.db.subscribe(this.collection, id, typeof next === "function" ? { next } : next);
|
|
9
|
-
}
|
|
10
6
|
/** Get an add change for this collection. */
|
|
11
7
|
getAdd(data) {
|
|
12
8
|
return this.db.getAdd(this.collection, data);
|
package/db/Database.d.ts
CHANGED
|
@@ -6,9 +6,6 @@ import type { FilterList } from "../constraint/FilterConstraint.js";
|
|
|
6
6
|
import type { SortList } from "../constraint/SortConstraint.js";
|
|
7
7
|
import type { ItemData, ItemValue } from "../db/Item.js";
|
|
8
8
|
import type { Updates } from "../update/DataUpdate.js";
|
|
9
|
-
import type { PartialObserver } from "../observe/Observer.js";
|
|
10
|
-
import type { Dispatch } from "../util/function.js";
|
|
11
|
-
import type { Unsubscribe } from "../observe/Observable.js";
|
|
12
9
|
import { Item, AsyncItem } from "./Item.js";
|
|
13
10
|
import { Query, AsyncQuery } from "./Query.js";
|
|
14
11
|
import { Collection, AsyncCollection } from "./Collection.js";
|
|
@@ -26,8 +23,6 @@ declare abstract class BaseDatabase<T extends Datas> {
|
|
|
26
23
|
abstract change(...changes: DeepIterable<Nullish<WriteChange<T>>>[]): ItemChanges<T> | Promise<ItemChanges<T>>;
|
|
27
24
|
/** Get a document from a collection in this database. */
|
|
28
25
|
abstract get<K extends Key<T>>(collection: K, id: string): ItemValue<T[K]> | Promise<ItemValue<T[K]>>;
|
|
29
|
-
/** Subscribe a document from a collection in this database. */
|
|
30
|
-
subscribe<K extends Key<T>>(collection: K, id: string, next: PartialObserver<ItemValue<T[K]>> | Dispatch<[ItemValue<T[K]>]>): Unsubscribe;
|
|
31
26
|
/** Add a document to a collection in this database. */
|
|
32
27
|
abstract add<K extends Key<T>>(collection: K, data: T[K]): string | Promise<string>;
|
|
33
28
|
/** Set a document in a collection in this database. */
|
package/db/Database.js
CHANGED
|
@@ -4,10 +4,6 @@ import { Collection, AsyncCollection } from "./Collection.js";
|
|
|
4
4
|
import { changeAsyncProvider, changeProvider } from "./Change.js";
|
|
5
5
|
/** Database with a synchronous or asynchronous provider. */
|
|
6
6
|
class BaseDatabase {
|
|
7
|
-
/** Subscribe a document from a collection in this database. */
|
|
8
|
-
subscribe(collection, id, next) {
|
|
9
|
-
return this.provider.subscribeItem(collection, id, typeof next === "function" ? { next } : next);
|
|
10
|
-
}
|
|
11
7
|
/** Get an add change for a collection in this database. */
|
|
12
8
|
getAdd(collection, data) {
|
|
13
9
|
return { action: "ADD", collection, data };
|
package/db/Item.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { Data, Datas, Key } from "../util/data.js";
|
|
2
|
-
import type { Dispatch } from "../util/function.js";
|
|
3
|
-
import type { PartialObserver } from "../observe/Observer.js";
|
|
4
1
|
import type { ImmutableArray } from "../util/array.js";
|
|
5
|
-
import type {
|
|
6
|
-
import { DataUpdate, Updates } from "../update/DataUpdate.js";
|
|
2
|
+
import type { Stop, Handler, Dispatch } from "../util/function.js";
|
|
7
3
|
import type { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
4
|
+
import { Data, Datas, Key } from "../util/data.js";
|
|
5
|
+
import { DataUpdate, Updates } from "../update/DataUpdate.js";
|
|
10
6
|
import type { DeleteChange, SetChange, UpdateChange } from "./Change.js";
|
|
7
|
+
import type { AsyncQuery, Query } from "./Query.js";
|
|
8
|
+
import type { AsyncDatabase, Database } from "./Database.js";
|
|
11
9
|
/** Item data with a string ID that uniquely identifies it. */
|
|
12
10
|
export declare type ItemData<T extends Data = Data> = T & {
|
|
13
11
|
id: string;
|
|
@@ -19,7 +17,7 @@ export declare type ItemArray<T extends Data = Data> = ImmutableArray<ItemData<T
|
|
|
19
17
|
/** A set of query constraints for item data. */
|
|
20
18
|
export declare type ItemConstraints<T extends Data = Data> = QueryConstraints<ItemData<T>>;
|
|
21
19
|
/** Reference to an item in a synchronous or asynchronous database. */
|
|
22
|
-
declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<T>> implements
|
|
20
|
+
declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<T>> implements AsyncIterable<ItemValue<T[K]>> {
|
|
23
21
|
abstract readonly db: Database<T> | AsyncDatabase<T>;
|
|
24
22
|
abstract readonly collection: K;
|
|
25
23
|
abstract readonly id: string;
|
|
@@ -43,14 +41,6 @@ declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<
|
|
|
43
41
|
* @throws RequiredError if the item does not exist.
|
|
44
42
|
*/
|
|
45
43
|
abstract data: ItemData<T[K]> | PromiseLike<ItemData<T[K]>>;
|
|
46
|
-
/**
|
|
47
|
-
* Subscribe to the result of this item (indefinitely).
|
|
48
|
-
* - `next()` is called once with the initial result, and again any time the result changes.
|
|
49
|
-
*
|
|
50
|
-
* @param next Observer with `next`, `error`, or `complete` methods or a `next()` dispatcher.
|
|
51
|
-
* @return Function that ends the subscription.
|
|
52
|
-
*/
|
|
53
|
-
subscribe(next: PartialObserver<ItemValue<T[K]>> | Dispatch<[ItemValue<T[K]>]>): Unsubscribe;
|
|
54
44
|
/** Set the complete data of this item. */
|
|
55
45
|
abstract set(data: T[K]): void | PromiseLike<void>;
|
|
56
46
|
/** Update this item. */
|
|
@@ -64,6 +54,9 @@ declare abstract class BaseItem<T extends Datas = Datas, K extends Key<T> = Key<
|
|
|
64
54
|
/** Get a delete change for this item. */
|
|
65
55
|
getDelete(): DeleteChange<T, K>;
|
|
66
56
|
toString(): `${K}/${string}`;
|
|
57
|
+
/** Subscribe to this item. */
|
|
58
|
+
subscribe(onNext?: Dispatch<[ItemValue<T[K]>]>, onError?: Handler): Stop;
|
|
59
|
+
[Symbol.asyncIterator](): AsyncIterator<ItemValue<T[K]>>;
|
|
67
60
|
}
|
|
68
61
|
/** Reference to an item in a synchronous database. */
|
|
69
62
|
export declare class Item<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseItem<T, K> {
|
package/db/Item.js
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
import { getData } from "../util/data.js";
|
|
2
2
|
import { FilterConstraint } from "../constraint/FilterConstraint.js";
|
|
3
|
+
import { runSequence } from "../util/sequence.js";
|
|
3
4
|
/** Reference to an item in a synchronous or asynchronous database. */
|
|
4
5
|
class BaseItem {
|
|
5
|
-
/**
|
|
6
|
-
* Subscribe to the result of this item (indefinitely).
|
|
7
|
-
* - `next()` is called once with the initial result, and again any time the result changes.
|
|
8
|
-
*
|
|
9
|
-
* @param next Observer with `next`, `error`, or `complete` methods or a `next()` dispatcher.
|
|
10
|
-
* @return Function that ends the subscription.
|
|
11
|
-
*/
|
|
12
|
-
subscribe(next) {
|
|
13
|
-
return this.db.subscribe(this.collection, this.id, next);
|
|
14
|
-
}
|
|
15
6
|
/** Get a set change for this item. */
|
|
16
7
|
getSet(data) {
|
|
17
8
|
return this.db.getSet(this.collection, this.id, data);
|
|
@@ -28,6 +19,14 @@ class BaseItem {
|
|
|
28
19
|
toString() {
|
|
29
20
|
return `${this.collection}/${this.id}`;
|
|
30
21
|
}
|
|
22
|
+
/** Subscribe to this item. */
|
|
23
|
+
subscribe(onNext, onError) {
|
|
24
|
+
return runSequence(this, onNext, onError);
|
|
25
|
+
}
|
|
26
|
+
// Implement AsyncIterable
|
|
27
|
+
[Symbol.asyncIterator]() {
|
|
28
|
+
return this.db.provider.getItemSequence(this.collection, this.id)[Symbol.asyncIterator]();
|
|
29
|
+
}
|
|
31
30
|
}
|
|
32
31
|
/** Reference to an item in a synchronous database. */
|
|
33
32
|
export class Item extends BaseItem {
|
package/db/Query.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import type { Dispatch } from "../util/function.js";
|
|
2
1
|
import type { Key, Datas } from "../util/data.js";
|
|
2
|
+
import type { Dispatch, Handler, Stop } from "../util/function.js";
|
|
3
3
|
import type { Updates } from "../update/DataUpdate.js";
|
|
4
|
-
import type { PartialObserver } from "../observe/Observer.js";
|
|
5
|
-
import type { Observable, Unsubscribe } from "../observe/Observable.js";
|
|
6
4
|
import type { FilterList } from "../constraint/FilterConstraint.js";
|
|
7
5
|
import type { SortList } from "../constraint/SortConstraint.js";
|
|
8
6
|
import { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
9
7
|
import type { ItemArray, ItemValue, ItemData } from "./Item.js";
|
|
10
8
|
import type { AsyncDatabase, Database } from "./Database.js";
|
|
11
9
|
/** Reference to a set of items in a sync or async provider. */
|
|
12
|
-
declare abstract class BaseQuery<T extends Datas = Datas, K extends Key<T> = Key<T>> extends QueryConstraints<ItemData<T[K]>> implements
|
|
10
|
+
declare abstract class BaseQuery<T extends Datas = Datas, K extends Key<T> = Key<T>> extends QueryConstraints<ItemData<T[K]>> implements AsyncIterable<ItemArray<T[K]>> {
|
|
13
11
|
abstract readonly db: Database<T> | AsyncDatabase<T>;
|
|
14
12
|
abstract readonly collection: K;
|
|
15
13
|
/**
|
|
@@ -47,14 +45,6 @@ declare abstract class BaseQuery<T extends Datas = Datas, K extends Key<T> = Key
|
|
|
47
45
|
* @throws RequiredError if there were no results for this query.
|
|
48
46
|
*/
|
|
49
47
|
abstract lastData: ItemData<T[K]> | PromiseLike<ItemData<T[K]>>;
|
|
50
|
-
/**
|
|
51
|
-
* Subscribe to all matching items.
|
|
52
|
-
* - `next()` is called once with the initial results, and again any time the results change.
|
|
53
|
-
*
|
|
54
|
-
* @param next Observer with `next`, `error`, or `complete` methods or a `next()` dispatcher.
|
|
55
|
-
* @return Function that ends the subscription.
|
|
56
|
-
*/
|
|
57
|
-
subscribe(next: PartialObserver<ItemArray<T[K]>> | Dispatch<[ItemArray<T[K]>]>): Unsubscribe;
|
|
58
48
|
/**
|
|
59
49
|
* Set all matching items to the same exact value.
|
|
60
50
|
*
|
|
@@ -75,9 +65,12 @@ declare abstract class BaseQuery<T extends Datas = Datas, K extends Key<T> = Key
|
|
|
75
65
|
*/
|
|
76
66
|
abstract delete(): number | PromiseLike<number>;
|
|
77
67
|
toString(): string;
|
|
68
|
+
/** Subscribe to this item. */
|
|
69
|
+
subscribe(onNext?: Dispatch<[ItemArray<T[K]>]>, onError?: Handler): Stop;
|
|
70
|
+
[Symbol.asyncIterator](): AsyncIterator<ItemArray<T[K]>>;
|
|
78
71
|
}
|
|
79
72
|
/** Reference to a set of items in a provider. */
|
|
80
|
-
export declare class Query<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseQuery<T, K>
|
|
73
|
+
export declare class Query<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseQuery<T, K> {
|
|
81
74
|
readonly db: Database<T>;
|
|
82
75
|
readonly collection: K;
|
|
83
76
|
constructor(db: Database<T>, collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null);
|
|
@@ -93,7 +86,7 @@ export declare class Query<T extends Datas = Datas, K extends Key<T> = Key<T>> e
|
|
|
93
86
|
delete(): number;
|
|
94
87
|
}
|
|
95
88
|
/** Reference to a set of items in a provider. */
|
|
96
|
-
export declare class AsyncQuery<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseQuery<T, K>
|
|
89
|
+
export declare class AsyncQuery<T extends Datas = Datas, K extends Key<T> = Key<T>> extends BaseQuery<T, K> {
|
|
97
90
|
readonly db: AsyncDatabase<T>;
|
|
98
91
|
readonly collection: K;
|
|
99
92
|
constructor(db: AsyncDatabase<T>, collection: K, filters?: FilterList<Partial<ItemData<T[K]>>>, sorts?: SortList<Partial<ItemData<T[K]>>>, limit?: number | null);
|
package/db/Query.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { getFirstItem, getLastItem, getOptionalFirstItem, getOptionalLastItem } from "../util/array.js";
|
|
2
|
-
import { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
3
2
|
import { countItems, hasItems } from "../util/iterate.js";
|
|
3
|
+
import { runSequence } from "../util/sequence.js";
|
|
4
|
+
import { QueryConstraints } from "../constraint/QueryConstraints.js";
|
|
4
5
|
/** Reference to a set of items in a sync or async provider. */
|
|
5
6
|
class BaseQuery extends QueryConstraints {
|
|
6
|
-
/**
|
|
7
|
-
* Subscribe to all matching items.
|
|
8
|
-
* - `next()` is called once with the initial results, and again any time the results change.
|
|
9
|
-
*
|
|
10
|
-
* @param next Observer with `next`, `error`, or `complete` methods or a `next()` dispatcher.
|
|
11
|
-
* @return Function that ends the subscription.
|
|
12
|
-
*/
|
|
13
|
-
subscribe(next) {
|
|
14
|
-
return this.db.provider.subscribeQuery(this.collection, this, typeof next === "function" ? { next } : next);
|
|
15
|
-
}
|
|
16
7
|
// Override to include the collection name.
|
|
17
8
|
toString() {
|
|
18
|
-
return `${this.collection}
|
|
9
|
+
return `${this.collection}?{${super.toString()}`;
|
|
10
|
+
}
|
|
11
|
+
/** Subscribe to this item. */
|
|
12
|
+
subscribe(onNext, onError) {
|
|
13
|
+
return runSequence(this, onNext, onError);
|
|
14
|
+
}
|
|
15
|
+
// Implement AsyncIterable
|
|
16
|
+
[Symbol.asyncIterator]() {
|
|
17
|
+
return this.db.provider.getQuerySequence(this.collection, this)[Symbol.asyncIterator]();
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
/** Reference to a set of items in a provider. */
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import type { Firestore } from "firebase/firestore";
|
|
2
2
|
import type { Data } from "../../util/data.js";
|
|
3
|
-
import type { Unsubscribe } from "../../observe/Observable.js";
|
|
4
3
|
import type { AsyncProvider } from "../../provider/Provider.js";
|
|
5
4
|
import type { ItemArray, ItemValue, ItemConstraints } from "../../db/Item.js";
|
|
6
|
-
import {
|
|
7
|
-
import { Updates } from "../../update/DataUpdate.js";
|
|
5
|
+
import { Updates } from "../../update/index.js";
|
|
8
6
|
/**
|
|
9
7
|
* Firestore client database provider.
|
|
10
8
|
* - Works with the Firebase JS SDK.
|
|
@@ -15,13 +13,13 @@ export declare class FirestoreClientProvider implements AsyncProvider {
|
|
|
15
13
|
private readonly _firestore;
|
|
16
14
|
constructor(firestore: Firestore);
|
|
17
15
|
getItem(collection: string, id: string): Promise<ItemValue>;
|
|
18
|
-
|
|
16
|
+
getItemSequence<K extends string>(collection: K, id: string): AsyncIterable<ItemValue>;
|
|
19
17
|
addItem(collection: string, data: Data): Promise<string>;
|
|
20
18
|
setItem(collection: string, id: string, data: Data): Promise<void>;
|
|
21
19
|
updateItem(collection: string, id: string, updates: Updates): Promise<void>;
|
|
22
20
|
deleteItem(collection: string, id: string): Promise<void>;
|
|
23
21
|
getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
|
|
24
|
-
|
|
22
|
+
getQuerySequence<K extends string>(collection: K, constraints: ItemConstraints): AsyncIterable<ItemArray>;
|
|
25
23
|
setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
|
|
26
24
|
updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
|
|
27
25
|
deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { orderBy as firestoreOrderBy, where as firestoreWhere, limit as firestoreLimit, increment as firestoreIncrement, arrayUnion as firestoreArrayUnion, arrayRemove as firestoreArrayRemove, deleteField as firestoreDeleteField, collection as firestoreCollection, doc as firestoreDocument, query as firestoreQuery, onSnapshot, addDoc, setDoc, updateDoc, deleteDoc, getDoc, getDocs, } from "firebase/firestore";
|
|
2
|
-
import {
|
|
3
|
-
import { ArrayUpdate } from "../../update/
|
|
4
|
-
import { DataUpdate } from "../../update/DataUpdate.js";
|
|
5
|
-
import { Increment } from "../../update/Increment.js";
|
|
6
|
-
import { ObjectUpdate } from "../../update/ObjectUpdate.js";
|
|
7
|
-
import { Delete } from "../../update/Delete.js";
|
|
8
|
-
import { Update } from "../../update/Update.js";
|
|
2
|
+
import { LazyDeferredSequence } from "../../sequence/LazyDeferredSequence.js";
|
|
3
|
+
import { ArrayUpdate, DataUpdate, Increment, ObjectUpdate, Delete, Update } from "../../update/index.js";
|
|
9
4
|
// Constants.
|
|
10
5
|
// const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
|
|
11
6
|
const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
|
|
@@ -91,8 +86,10 @@ export class FirestoreClientProvider {
|
|
|
91
86
|
async getItem(collection, id) {
|
|
92
87
|
return _getItemValue(await getDoc(firestoreDocument(this._firestore, collection, id)));
|
|
93
88
|
}
|
|
94
|
-
|
|
95
|
-
return onSnapshot(firestoreDocument(this._firestore, collection, id),
|
|
89
|
+
getItemSequence(collection, id) {
|
|
90
|
+
return new LazyDeferredSequence(({ resolve, reject }) => onSnapshot(firestoreDocument(this._firestore, collection, id), //
|
|
91
|
+
//
|
|
92
|
+
snapshot => resolve(_getItemValue(snapshot)), reject));
|
|
96
93
|
}
|
|
97
94
|
async addItem(collection, data) {
|
|
98
95
|
const reference = await addDoc(firestoreCollection(this._firestore, collection), data);
|
|
@@ -110,8 +107,10 @@ export class FirestoreClientProvider {
|
|
|
110
107
|
async getQuery(collection, constraints) {
|
|
111
108
|
return _getItems(await getDocs(_getQuery(this._firestore, collection, constraints)));
|
|
112
109
|
}
|
|
113
|
-
|
|
114
|
-
return onSnapshot(_getQuery(this._firestore, collection, constraints),
|
|
110
|
+
getQuerySequence(collection, constraints) {
|
|
111
|
+
return new LazyDeferredSequence(({ resolve, reject }) => onSnapshot(_getQuery(this._firestore, collection, constraints), //
|
|
112
|
+
//
|
|
113
|
+
snapshot => resolve(_getItems(snapshot)), reject));
|
|
115
114
|
}
|
|
116
115
|
async setQuery(collection, constraints, data) {
|
|
117
116
|
const snapshot = await getDocs(_getQuery(this._firestore, collection, constraints));
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Firestore } from "firebase/firestore/lite";
|
|
2
2
|
import type { Data } from "../../util/data.js";
|
|
3
|
-
import type { Unsubscribe } from "../../observe/Observable.js";
|
|
4
3
|
import type { AsyncProvider } from "../../provider/Provider.js";
|
|
5
4
|
import type { ItemArray, ItemValue, ItemConstraints } from "../../db/Item.js";
|
|
6
|
-
import { Updates } from "../../update/
|
|
5
|
+
import { Updates } from "../../update/index.js";
|
|
7
6
|
/**
|
|
8
7
|
* Firestore Lite client database provider.
|
|
9
8
|
* - Works with the Firebase JS SDK.
|
|
@@ -14,13 +13,13 @@ export declare class FirestoreLiteProvider implements AsyncProvider {
|
|
|
14
13
|
private readonly _firestore;
|
|
15
14
|
constructor(firestore: Firestore);
|
|
16
15
|
getItem(collection: string, id: string): Promise<ItemValue>;
|
|
17
|
-
|
|
16
|
+
getItemSequence(): AsyncIterableIterator<ItemValue>;
|
|
18
17
|
addItem(collection: string, data: Data): Promise<string>;
|
|
19
18
|
setItem(collection: string, id: string, data: Data): Promise<void>;
|
|
20
19
|
updateItem(collection: string, id: string, updates: Updates): Promise<void>;
|
|
21
20
|
deleteItem(collection: string, id: string): Promise<void>;
|
|
22
21
|
getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
|
|
23
|
-
|
|
22
|
+
getQuerySequence(): AsyncIterableIterator<ItemArray>;
|
|
24
23
|
setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
|
|
25
24
|
updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
|
|
26
25
|
deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { orderBy as firestoreOrderBy, where as firestoreWhere, limit as firestoreLimit, increment as firestoreIncrement, arrayUnion as firestoreArrayUnion, arrayRemove as firestoreArrayRemove, deleteField as firestoreDeleteField, collection as firestoreCollection, doc as firestoreDocument, query as firestoreQuery, setDoc, addDoc, updateDoc, deleteDoc, getDoc, getDocs, } from "firebase/firestore/lite";
|
|
2
2
|
import { UnsupportedError } from "../../error/UnsupportedError.js";
|
|
3
|
-
import { ArrayUpdate } from "../../update/
|
|
4
|
-
import { DataUpdate } from "../../update/DataUpdate.js";
|
|
5
|
-
import { Increment } from "../../update/Increment.js";
|
|
6
|
-
import { ObjectUpdate } from "../../update/ObjectUpdate.js";
|
|
7
|
-
import { Update } from "../../update/Update.js";
|
|
8
|
-
import { Delete } from "../../update/Delete.js";
|
|
3
|
+
import { ArrayUpdate, DataUpdate, Increment, ObjectUpdate, Delete, Update } from "../../update/index.js";
|
|
9
4
|
// Constants.
|
|
10
5
|
// const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
|
|
11
6
|
const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
|
|
@@ -91,7 +86,7 @@ export class FirestoreLiteProvider {
|
|
|
91
86
|
async getItem(collection, id) {
|
|
92
87
|
return _getItemValue(await getDoc(firestoreDocument(this._firestore, collection, id)));
|
|
93
88
|
}
|
|
94
|
-
|
|
89
|
+
getItemSequence() {
|
|
95
90
|
throw new UnsupportedError("FirestoreLiteProvider does not support realtime subscriptions");
|
|
96
91
|
}
|
|
97
92
|
async addItem(collection, data) {
|
|
@@ -110,7 +105,7 @@ export class FirestoreLiteProvider {
|
|
|
110
105
|
async getQuery(collection, constraints) {
|
|
111
106
|
return _getItems(await getDocs(_getQuery(this._firestore, collection, constraints)));
|
|
112
107
|
}
|
|
113
|
-
|
|
108
|
+
getQuerySequence() {
|
|
114
109
|
throw new UnsupportedError("FirestoreLiteProvider does not support realtime subscriptions");
|
|
115
110
|
}
|
|
116
111
|
async setQuery(collection, constraints, data) {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Firestore } from "@google-cloud/firestore";
|
|
2
|
-
import type {
|
|
2
|
+
import type { Data } from "../../util/data.js";
|
|
3
3
|
import type { AsyncProvider } from "../../provider/Provider.js";
|
|
4
4
|
import type { ItemArray, ItemValue, ItemConstraints } from "../../db/Item.js";
|
|
5
|
-
import {
|
|
6
|
-
import { Updates } from "../../update/DataUpdate.js";
|
|
7
|
-
import { Data } from "../../util/data.js";
|
|
5
|
+
import { Updates } from "../../update/index.js";
|
|
8
6
|
/**
|
|
9
7
|
* Firestore server database provider.
|
|
10
8
|
* - Works with the Firebase Admin SDK for Node.JS
|
|
@@ -13,13 +11,13 @@ export declare class FirestoreServerProvider implements AsyncProvider {
|
|
|
13
11
|
private readonly _firestore;
|
|
14
12
|
constructor(firestore?: Firestore);
|
|
15
13
|
getItem(collection: string, id: string): Promise<ItemValue>;
|
|
16
|
-
|
|
14
|
+
getItemSequence(collection: string, id: string): AsyncIterable<ItemValue>;
|
|
17
15
|
addItem(collection: string, data: Data): Promise<string>;
|
|
18
16
|
setItem(collection: string, id: string, data: Data): Promise<void>;
|
|
19
17
|
updateItem(collection: string, id: string, updates: Updates): Promise<void>;
|
|
20
18
|
deleteItem(collection: string, id: string): Promise<void>;
|
|
21
19
|
getQuery(collection: string, constraints: ItemConstraints): Promise<ItemArray>;
|
|
22
|
-
|
|
20
|
+
getQuerySequence<K extends string>(collection: K, constraints: ItemConstraints): AsyncIterable<ItemArray>;
|
|
23
21
|
setQuery(collection: string, constraints: ItemConstraints, data: Data): Promise<number>;
|
|
24
22
|
updateQuery(collection: string, constraints: ItemConstraints, updates: Updates): Promise<number>;
|
|
25
23
|
deleteQuery(collection: string, constraints: ItemConstraints): Promise<number>;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Firestore, FieldValue as FirestoreFieldValue } from "@google-cloud/firestore";
|
|
2
|
-
import {
|
|
3
|
-
import { ArrayUpdate } from "../../update/
|
|
4
|
-
import { DataUpdate } from "../../update/DataUpdate.js";
|
|
5
|
-
import { Increment } from "../../update/Increment.js";
|
|
6
|
-
import { ObjectUpdate } from "../../update/ObjectUpdate.js";
|
|
7
|
-
import { Delete } from "../../update/Delete.js";
|
|
8
|
-
import { Update } from "../../update/Update.js";
|
|
2
|
+
import { LazyDeferredSequence } from "../../sequence/LazyDeferredSequence.js";
|
|
3
|
+
import { ArrayUpdate, DataUpdate, Increment, ObjectUpdate, Delete, Update } from "../../update/index.js";
|
|
9
4
|
// Constants.
|
|
10
5
|
// const ID = "__name__"; // DH: `__name__` is the entire path of the document. `__id__` is just ID.
|
|
11
6
|
const ID = "__id__"; // Internal way Firestore Queries can reference the ID of the current document.
|
|
@@ -38,7 +33,7 @@ function _getQuery(firestore, collection, constraints) {
|
|
|
38
33
|
query = query.limit(limit);
|
|
39
34
|
return query;
|
|
40
35
|
}
|
|
41
|
-
function
|
|
36
|
+
function _getItemArray(snapshot) {
|
|
42
37
|
return snapshot.docs.map(_getItemData);
|
|
43
38
|
}
|
|
44
39
|
function _getItemData(snapshot) {
|
|
@@ -89,11 +84,10 @@ export class FirestoreServerProvider {
|
|
|
89
84
|
async getItem(collection, id) {
|
|
90
85
|
return _getItemValue(await this._firestore.collection(collection).doc(id).get());
|
|
91
86
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
.onSnapshot(snapshot => dispatchNext(observer, _getItemValue(snapshot)), thrown => dispatchError(observer, thrown));
|
|
87
|
+
getItemSequence(collection, id) {
|
|
88
|
+
const ref = this._firestore.collection(collection).doc(id);
|
|
89
|
+
return new LazyDeferredSequence(({ resolve, reject }) => ref.onSnapshot(snapshot => resolve(_getItemValue(snapshot)), //
|
|
90
|
+
reject));
|
|
97
91
|
}
|
|
98
92
|
async addItem(collection, data) {
|
|
99
93
|
return (await this._firestore.collection(collection).add(data)).id;
|
|
@@ -111,10 +105,12 @@ export class FirestoreServerProvider {
|
|
|
111
105
|
await this._firestore.collection(collection).doc(id).delete();
|
|
112
106
|
}
|
|
113
107
|
async getQuery(collection, constraints) {
|
|
114
|
-
return
|
|
108
|
+
return _getItemArray(await _getQuery(this._firestore, collection, constraints).get());
|
|
115
109
|
}
|
|
116
|
-
|
|
117
|
-
|
|
110
|
+
getQuerySequence(collection, constraints) {
|
|
111
|
+
const ref = _getQuery(this._firestore, collection, constraints);
|
|
112
|
+
return new LazyDeferredSequence(({ resolve, reject }) => ref.onSnapshot(snapshot => resolve(_getItemArray(snapshot)), //
|
|
113
|
+
reject));
|
|
118
114
|
}
|
|
119
115
|
async setQuery(collection, constraints, data) {
|
|
120
116
|
return await bulkWrite(this._firestore, collection, constraints, (w, s) => void w.set(s.ref, data));
|
package/index.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This module exports almost everything in Shelving except...
|
|
3
|
-
* - Modules that use peer dependencies, like `shelving/react` and `shelving/firebase
|
|
4
|
-
* - Modules that are for internal
|
|
3
|
+
* - Modules that use peer dependencies, like `shelving/react` and `shelving/firebase/client`
|
|
4
|
+
* - Modules that are for internal use, like `shelving/test`
|
|
5
5
|
*/
|
|
6
|
-
export * from "./schema/index.js";
|
|
7
|
-
export * from "./db/index.js";
|
|
8
|
-
export * from "./provider/index.js";
|
|
9
|
-
export * from "./constraint/index.js";
|
|
10
6
|
export * from "./api/index.js";
|
|
7
|
+
export * from "./constraint/index.js";
|
|
8
|
+
export * from "./db/index.js";
|
|
11
9
|
export * from "./error/index.js";
|
|
12
10
|
export * from "./feedback/index.js";
|
|
11
|
+
export * from "./iterate/index.js";
|
|
13
12
|
export * from "./markup/index.js";
|
|
14
|
-
export * from "./
|
|
13
|
+
export * from "./provider/index.js";
|
|
14
|
+
export * from "./schema/index.js";
|
|
15
|
+
export * from "./sequence/index.js";
|
|
15
16
|
export * from "./state/index.js";
|
|
16
17
|
export * from "./update/index.js";
|
|
17
18
|
export * from "./util/index.js";
|
package/index.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This module exports almost everything in Shelving except...
|
|
3
|
-
* - Modules that use peer dependencies, like `shelving/react` and `shelving/firebase
|
|
4
|
-
* - Modules that are for internal
|
|
3
|
+
* - Modules that use peer dependencies, like `shelving/react` and `shelving/firebase/client`
|
|
4
|
+
* - Modules that are for internal use, like `shelving/test`
|
|
5
5
|
*/
|
|
6
|
-
// Data storage.
|
|
7
|
-
export * from "./schema/index.js";
|
|
8
|
-
export * from "./db/index.js";
|
|
9
|
-
export * from "./provider/index.js";
|
|
10
|
-
export * from "./constraint/index.js";
|
|
11
6
|
export * from "./api/index.js";
|
|
12
|
-
|
|
7
|
+
export * from "./constraint/index.js";
|
|
8
|
+
export * from "./db/index.js";
|
|
13
9
|
export * from "./error/index.js";
|
|
14
10
|
export * from "./feedback/index.js";
|
|
15
|
-
export * from "./markup/index.js";
|
|
16
|
-
export * from "./observe/index.js";
|
|
17
|
-
export * from "./state/index.js";
|
|
18
|
-
export * from "./update/index.js";
|
|
19
|
-
export * from "./util/index.js";
|
|
20
|
-
// Integrations.
|
|
21
|
-
// export * from "./react/index.js"; // Not exported.
|
|
22
11
|
// export * from "./firestore/client/index.js"; // Not exported.
|
|
23
12
|
// export * from "./firestore/lite/index.js"; // Not exported.
|
|
24
13
|
// export * from "./firestore/server/index.js"; // Not exported.
|
|
25
|
-
|
|
14
|
+
export * from "./iterate/index.js";
|
|
15
|
+
export * from "./markup/index.js";
|
|
16
|
+
export * from "./provider/index.js";
|
|
17
|
+
// export * from "./react/index.js"; // Not exported.
|
|
18
|
+
export * from "./schema/index.js";
|
|
19
|
+
export * from "./sequence/index.js";
|
|
20
|
+
export * from "./state/index.js";
|
|
26
21
|
// export * from "./test/index.js"; // Not exported.
|
|
22
|
+
export * from "./update/index.js";
|
|
23
|
+
export * from "./util/index.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Abstract generator designed to be extended that implements the full generator protocol. */
|
|
2
|
+
export declare abstract class AbstractGenerator<T, R, N> implements Generator<T, R, N> {
|
|
3
|
+
readonly [Symbol.toStringTag]: string;
|
|
4
|
+
abstract next(value: N): IteratorResult<T, R>;
|
|
5
|
+
throw(thrown: Error | unknown): IteratorResult<T, R>;
|
|
6
|
+
return(value: R): IteratorResult<T, R>;
|
|
7
|
+
[Symbol.iterator](): Generator<T, R, N>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var _a;
|
|
8
|
+
import { setPrototype } from "../util/class.js";
|
|
9
|
+
/** Abstract generator designed to be extended that implements the full generator protocol. */
|
|
10
|
+
export class AbstractGenerator {
|
|
11
|
+
throw(thrown) {
|
|
12
|
+
// Default behaviour for a generator is to throw the error back out of the iterator and not continue.
|
|
13
|
+
throw thrown;
|
|
14
|
+
}
|
|
15
|
+
return(value) {
|
|
16
|
+
// Default behaviour for a generator is to return `done: true` and the input value.
|
|
17
|
+
return { done: true, value };
|
|
18
|
+
}
|
|
19
|
+
// Implement `Iterable`
|
|
20
|
+
[(_a = Symbol.toStringTag, Symbol.iterator)]() {
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
__decorate([
|
|
25
|
+
setPrototype(Symbol.toStringTag, "Generator")
|
|
26
|
+
], AbstractGenerator.prototype, _a, void 0);
|