diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..376c367 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,31 @@ +class NS { + ns: string; + dotIndex: number; + database: string; + collection: string; + system: boolean; + isSystem: boolean; + oplog: boolean; + isOplog: boolean; + command: boolean; + isCommand: boolean; + special: boolean; + isSpecial: boolean; + specialish: boolean; + normal: boolean; + isNormal: boolean; + validDatabaseName: boolean; + validCollectionName: boolean; + databaseHash: number; + toString(): string; + static sort(namespaces: (string | NS)[]): typeof namespaces; + static MAX_DATABASE_NAME_LENGTH: number; + // Assigned in the constructor, but will always be undefined + // isConf: undefined; +} + +declare const toNS: ((namespace: string | NS) => NS) & { + sort: typeof NS['sort']; +}; + +export default toNS; diff --git a/package.json b/package.json index 1d025f9..08fc9e5 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,8 @@ "version": "2.1.0", "author": "Lucas Hrabovsky (http://imlucas.com)", "description": "MongoDB namespace parsing and validation", + "main": "./index.js", + "types": "./index.d.ts", "scripts": { "test": "mocha", "check": "mongodb-js-precommit"