Skip to content

Commit 1f9ebc6

Browse files
committed
chore: Add type definitions for the package
1 parent 0ba72a0 commit 1f9ebc6

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

index.d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
class NS {
2+
ns: string;
3+
dotIndex: number;
4+
database: string;
5+
collection: string;
6+
system: boolean;
7+
isSystem: boolean;
8+
oplog: boolean;
9+
isOplog: boolean;
10+
command: boolean;
11+
isCommand: boolean;
12+
special: boolean;
13+
isSpecial: boolean;
14+
specialish: boolean;
15+
normal: boolean;
16+
isNormal: boolean;
17+
validDatabaseName: boolean;
18+
validCollectionName: boolean;
19+
databaseHash: number;
20+
toString(): string;
21+
static sort(namespaces: (string | NS)[]): typeof namespaces;
22+
static MAX_DATABASE_NAME_LENGTH: number;
23+
// Assigned in the constructor, but will always be undefined
24+
// isConf: undefined;
25+
}
26+
27+
declare const toNS: ((namespace: string | NS) => NS) & {
28+
sort: typeof NS['sort'];
29+
};
30+
31+
export default toNS;

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
"version": "2.1.0",
44
"author": "Lucas Hrabovsky <[email protected]> (http://imlucas.com)",
55
"description": "MongoDB namespace parsing and validation",
6+
"main": "./index.js",
7+
"types": "./index.d.ts",
68
"scripts": {
79
"test": "mocha",
810
"check": "mongodb-js-precommit"

0 commit comments

Comments
 (0)