Skip to content

Commit 3df48fc

Browse files
committed
Add typings
1 parent 7e9e467 commit 3df48fc

File tree

4 files changed

+43
-10
lines changed

4 files changed

+43
-10
lines changed

index.d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
export function supports (...manifests: Array<Partial<IManifest>>): IManifest
2+
3+
export interface IManifest {
4+
bufferKeys: boolean
5+
snapshots: boolean
6+
permanence: boolean
7+
seek: boolean
8+
clear: boolean
9+
getMany: boolean
10+
keyIterator: boolean
11+
valueIterator: boolean
12+
iteratorNextv: boolean
13+
iteratorAll: boolean
14+
status: boolean
15+
idempotentOpen: boolean
16+
passiveOpen: boolean
17+
serialize: boolean
18+
createIfMissing: boolean
19+
errorIfExists: boolean
20+
deferredOpen: boolean
21+
openCallback: boolean
22+
promises: boolean
23+
streams: boolean
24+
encodings: Record<string, boolean>
25+
events: Record<string, boolean>
26+
additionalMethods: Record<string, boolean>
27+
}

index.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ exports.supports = function supports (...manifests) {
44
const manifest = manifests.reduce((acc, m) => Object.assign(acc, m), {})
55

66
return Object.assign(manifest, {
7-
// Features of abstract-leveldown
87
bufferKeys: manifest.bufferKeys || false,
98
snapshots: manifest.snapshots || false,
109
permanence: manifest.permanence || false,
@@ -15,18 +14,12 @@ exports.supports = function supports (...manifests) {
1514
valueIterator: manifest.valueIterator || false,
1615
iteratorNextv: manifest.iteratorNextv || false,
1716
iteratorAll: manifest.iteratorAll || false,
18-
19-
// Features of abstract-leveldown that levelup doesn't have
2017
status: manifest.status || false,
2118
idempotentOpen: manifest.idempotentOpen || false,
2219
passiveOpen: manifest.passiveOpen || false,
2320
serialize: manifest.serialize || false,
24-
25-
// Features of disk-based implementations
2621
createIfMissing: manifest.createIfMissing || false,
2722
errorIfExists: manifest.errorIfExists || false,
28-
29-
// Features of level(up) that abstract-leveldown doesn't have yet
3023
deferredOpen: manifest.deferredOpen || false,
3124
openCallback: manifest.openCallback || false,
3225
promises: manifest.promises || false,

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,30 @@
44
"description": "Create a manifest describing the abilities of a levelup or abstract-leveldown db",
55
"license": "MIT",
66
"scripts": {
7-
"test": "standard && hallmark && (nyc -s node test/self.js | faucet) && nyc report",
7+
"test": "ts-standard && tsc && standard && hallmark && (nyc -s node test/self.js | faucet) && nyc report",
88
"test-browsers-local": "airtap --coverage test/self.js",
99
"coverage": "nyc report -r lcovonly",
1010
"hallmark": "hallmark --fix"
1111
},
12+
"types": "./index.d.ts",
1213
"files": [
1314
"test",
1415
"CHANGELOG.md",
15-
"index.js"
16+
"index.js",
17+
"index.d.ts"
1618
],
1719
"devDependencies": {
20+
"@types/node": "^16.11.6",
21+
"@voxpelli/tsconfig": "^3.0.0",
1822
"airtap": "^4.0.3",
1923
"airtap-playwright": "^1.0.1",
2024
"faucet": "^0.0.1",
2125
"hallmark": "^3.1.0",
2226
"nyc": "^15.1.0",
2327
"standard": "^16.0.3",
24-
"tape": "^5.0.1"
28+
"tape": "^5.0.1",
29+
"ts-standard": "^10.0.0",
30+
"typescript": "^4.4.4"
2531
},
2632
"repository": {
2733
"type": "git",

tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "@voxpelli/tsconfig/node12.json",
3+
"compilerOptions": {
4+
"checkJs": false
5+
},
6+
"include": ["*.ts"]
7+
}

0 commit comments

Comments
 (0)