Skip to content

Commit

Permalink
refactor: remove usage of 'self' (#884)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian authored Jan 15, 2020
1 parent b2740ed commit cd0d758
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 6 additions & 7 deletions dev/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -898,10 +898,8 @@ export class Firestore {
request.mask = {fieldPaths};
}

const self = this;
return self
.requestStream('batchGetDocuments', request, requestTag)
.then(stream => {
return this.requestStream('batchGetDocuments', request, requestTag).then(
stream => {
return new Promise<Array<DocumentSnapshot<T>>>((resolve, reject) => {
stream
.on('error', err => {
Expand All @@ -924,15 +922,15 @@ export class Firestore {
'Received document: %s',
response.found.name!
);
document = self.snapshot_(response.found, response.readTime!);
document = this.snapshot_(response.found, response.readTime!);
} else {
logger(
'Firestore.getAll_',
requestTag,
'Document missing: %s',
response.missing!
);
document = self.snapshot_(
document = this.snapshot_(
response.missing!,
response.readTime!
);
Expand Down Expand Up @@ -983,7 +981,8 @@ export class Firestore {
});
stream.resume();
});
});
}
);
}

/**
Expand Down
4 changes: 1 addition & 3 deletions dev/src/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1747,14 +1747,12 @@ export class Query<T = DocumentData> {
* @param {bytes=} transactionId A transaction ID.
*/
_get(transactionId?: Uint8Array): Promise<QuerySnapshot<T>> {
const self = this;
const docs: Array<QueryDocumentSnapshot<T>> = [];

return new Promise((resolve, reject) => {
let readTime: Timestamp;

self
._stream(transactionId)
this._stream(transactionId)
.on('error', err => {
reject(err);
})
Expand Down

0 comments on commit cd0d758

Please sign in to comment.