Skip to content

Commit 865c436

Browse files
committed
Make wrap* methods static in Wrapper
1 parent 6e05fb7 commit 865c436

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ export {
6767
} from "nano";
6868

6969
export default <D>(config: Nano.Configuration | string): ServerScopeAsync | DocumentScopeAsync<D> => {
70-
return (new Wrapper()).wrap(nanoFactory(config));
70+
return Wrapper.wrap(nanoFactory(config));
7171
};

src/Wrapper.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import {isServerScope} from "./isServerScope";
66
import {promisify} from "./promisify";
77

88
export class Wrapper {
9-
public wrapServerScope(serverScope: Nano.ServerScope): ServerScopeAsync {
9+
public static wrapServerScope(serverScope: Nano.ServerScope): ServerScopeAsync {
1010
const serverScopeAsync: ServerScopeAsync = serverScope as any;
1111

1212
const {use, scope} = serverScope;
1313

14-
serverScopeAsync.db = this.wrapDatabaseScope(serverScopeAsync.db);
15-
serverScopeAsync.use = (db: string) => this.wrapDocumentScope(use(db));
16-
serverScopeAsync.scope = (db: string) => this.wrapDocumentScope(scope(db));
14+
serverScopeAsync.db = Wrapper.wrapDatabaseScope(serverScopeAsync.db);
15+
serverScopeAsync.use = (db: string) => Wrapper.wrapDocumentScope(use(db));
16+
serverScopeAsync.scope = (db: string) => Wrapper.wrapDocumentScope(scope(db));
1717

1818
serverScopeAsync.authAsync = promisify(serverScopeAsync.auth);
1919
serverScopeAsync.sessionAsync = promisify(serverScopeAsync.session);
@@ -23,12 +23,12 @@ export class Wrapper {
2323
return serverScopeAsync;
2424
}
2525

26-
public wrapDatabaseScope(databaseScope: Nano.DatabaseScope): DatabaseScopeAsync {
26+
public static wrapDatabaseScope(databaseScope: Nano.DatabaseScope): DatabaseScopeAsync {
2727
const databaseScopeAsync: DatabaseScopeAsync = databaseScope as any;
2828

2929
const {use} = databaseScope;
3030

31-
databaseScopeAsync.use = (db: string) => this.wrapDocumentScope(use(db));
31+
databaseScopeAsync.use = (db: string) => Wrapper.wrapDocumentScope(use(db));
3232

3333
databaseScopeAsync.createAsync = promisify(databaseScopeAsync.create);
3434
databaseScopeAsync.getAsync = promisify(databaseScopeAsync.getAsync);
@@ -42,7 +42,7 @@ export class Wrapper {
4242
return databaseScopeAsync;
4343
}
4444

45-
public wrapDocumentScope<D>(documentScope: Nano.DocumentScope<D>): DocumentScopeAsync<D> {
45+
public static wrapDocumentScope<D>(documentScope: Nano.DocumentScope<D>): DocumentScopeAsync<D> {
4646
const documentScopeAsync: DocumentScopeAsync<D> = documentScope as any;
4747

4848
documentScopeAsync.infoAsync = promisify(documentScopeAsync.info);
@@ -78,7 +78,7 @@ export class Wrapper {
7878
return documentScopeAsync;
7979
}
8080

81-
public wrap<D>(nano: Nano.ServerScope | Nano.DocumentScope<D>): ServerScopeAsync | DocumentScopeAsync<D> {
82-
return isServerScope(nano) ? this.wrapServerScope(nano) : this.wrapDocumentScope(nano);
81+
public static wrap<D>(nano: Nano.ServerScope | Nano.DocumentScope<D>): ServerScopeAsync | DocumentScopeAsync<D> {
82+
return isServerScope(nano) ? Wrapper.wrapServerScope(nano) : Wrapper.wrapDocumentScope(nano);
8383
}
8484
}

0 commit comments

Comments
 (0)