Skip to content

Commit 7c644b8

Browse files
committed
chore: add access control
1 parent 89cf5ce commit 7c644b8

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/cursor/abstract_cursor.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,13 @@ export abstract class AbstractCursor<
133133
CursorEvents extends AbstractCursorEvents = AbstractCursorEvents
134134
> extends TypedEventEmitter<CursorEvents> {
135135
/** @internal */
136-
[kId]: Long | null;
136+
private [kId]: Long | null;
137137
/** @internal */
138-
[kSession]: ClientSession;
138+
private [kSession]: ClientSession;
139139
/** @internal */
140-
[kServer]?: Server;
140+
private [kServer]?: Server;
141141
/** @internal */
142-
[kNamespace]: MongoDBNamespace;
142+
private [kNamespace]: MongoDBNamespace;
143143
/** @internal */
144144
[kDocuments]: {
145145
length: number;
@@ -149,23 +149,23 @@ export abstract class AbstractCursor<
149149
push(item: TSchema): void;
150150
};
151151
/** @internal */
152-
[kClient]: MongoClient;
152+
private [kClient]: MongoClient;
153153
/** @internal */
154-
[kTransform]?: (doc: TSchema) => any;
154+
private [kTransform]?: (doc: TSchema) => any;
155155
/** @internal */
156-
[kInitialized]: boolean;
156+
private [kInitialized]: boolean;
157157
/** @internal */
158-
[kClosed]: boolean;
158+
private [kClosed]: boolean;
159159
/** @internal */
160-
[kKilled]: boolean;
160+
private [kKilled]: boolean;
161161
/** @internal */
162-
[kOptions]: InternalAbstractCursorOptions;
162+
private [kOptions]: InternalAbstractCursorOptions;
163163

164164
/** @event */
165165
static readonly CLOSE = 'close' as const;
166166

167167
/** @internal */
168-
constructor(
168+
protected constructor(
169169
client: MongoClient,
170170
namespace: MongoDBNamespace,
171171
options: AbstractCursorOptions = {}
@@ -706,7 +706,7 @@ export abstract class AbstractCursor<
706706
return;
707707
}
708708

709-
/** Attempt to obtain more documents */
709+
/** @internal Attempt to obtain more documents */
710710
private async fetchBatch(): Promise<void> {
711711
if (this.closed) {
712712
return;
@@ -759,6 +759,7 @@ export abstract class AbstractCursor<
759759
}
760760
}
761761

762+
/** @internal */
762763
private async cleanup(error?: Error) {
763764
this[kClosed] = true;
764765
const session = this[kSession];
@@ -791,7 +792,9 @@ export abstract class AbstractCursor<
791792
}
792793
}
793794

795+
/** @internal */
794796
private hasEmittedClose = false;
797+
/** @internal */
795798
private emitClose() {
796799
try {
797800
if (!this.hasEmittedClose && (this[kDocuments].length === 0 || this[kClosed])) {
@@ -803,6 +806,7 @@ export abstract class AbstractCursor<
803806
}
804807
}
805808

809+
/** @internal */
806810
private makeSafeTransform<TSchema>(transform: (doc: TSchema) => any): (doc: TSchema) => any {
807811
return doc => {
808812
try {
@@ -823,6 +827,7 @@ export abstract class AbstractCursor<
823827
};
824828
}
825829

830+
/** @internal */
826831
protected throwIfInitialized() {
827832
if (this[kInitialized]) throw new MongoCursorInUseError();
828833
}

0 commit comments

Comments
 (0)