@@ -20,7 +20,7 @@ import { MaybeDocument } from '../model/document';
20
20
import { DocumentKey } from '../model/document_key' ;
21
21
import { Mutation , MutationResult } from '../model/mutation' ;
22
22
import * as api from '../protos/firestore_proto_api' ;
23
- import { debugAssert , hardAssert } from '../util/assert' ;
23
+ import { debugCast , hardAssert } from '../util/assert' ;
24
24
import { Code , FirestoreError } from '../util/error' ;
25
25
import { Connection } from './connection' ;
26
26
import { JsonProtoSerializer } from './serializer' ;
@@ -102,11 +102,7 @@ export async function invokeCommitRpc(
102
102
datastore : Datastore ,
103
103
mutations : Mutation [ ]
104
104
) : Promise < MutationResult [ ] > {
105
- debugAssert (
106
- datastore instanceof DatastoreImpl ,
107
- 'invokeCommitRpc() requires DatastoreImpl'
108
- ) ;
109
- const datastoreImpl : DatastoreImpl = datastore ;
105
+ const datastoreImpl = debugCast ( datastore , DatastoreImpl ) ;
110
106
const params = {
111
107
database : datastoreImpl . serializer . encodedDatabaseId ,
112
108
writes : mutations . map ( m => datastoreImpl . serializer . toMutation ( m ) )
@@ -125,11 +121,7 @@ export async function invokeBatchGetDocumentsRpc(
125
121
datastore : Datastore ,
126
122
keys : DocumentKey [ ]
127
123
) : Promise < MaybeDocument [ ] > {
128
- debugAssert (
129
- datastore instanceof DatastoreImpl ,
130
- 'invokeBatchGetDocumentsRpc() requires DatastoreImpl'
131
- ) ;
132
- const datastoreImpl : DatastoreImpl = datastore ;
124
+ const datastoreImpl = debugCast ( datastore , DatastoreImpl ) ;
133
125
const params = {
134
126
database : datastoreImpl . serializer . encodedDatabaseId ,
135
127
documents : keys . map ( k => datastoreImpl . serializer . toName ( k ) )
@@ -158,11 +150,7 @@ export function newPersistentWriteStream(
158
150
queue : AsyncQueue ,
159
151
listener : WriteStreamListener
160
152
) : PersistentWriteStream {
161
- debugAssert (
162
- datastore instanceof DatastoreImpl ,
163
- 'newPersistentWriteStream() requires DatastoreImpl'
164
- ) ;
165
- const datastoreImpl : DatastoreImpl = datastore ;
153
+ const datastoreImpl = debugCast ( datastore , DatastoreImpl ) ;
166
154
return new PersistentWriteStream (
167
155
queue ,
168
156
datastoreImpl . connection ,
@@ -177,11 +165,7 @@ export function newPersistentWatchStream(
177
165
queue : AsyncQueue ,
178
166
listener : WatchStreamListener
179
167
) : PersistentListenStream {
180
- debugAssert (
181
- datastore instanceof DatastoreImpl ,
182
- 'newPersistentWatchStream() requires DatastoreImpl'
183
- ) ;
184
- const datastoreImpl : DatastoreImpl = datastore ;
168
+ const datastoreImpl = debugCast ( datastore , DatastoreImpl ) ;
185
169
return new PersistentListenStream (
186
170
queue ,
187
171
datastoreImpl . connection ,
0 commit comments