Skip to content

Commit

Permalink
Add typings
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Nov 7, 2021
1 parent 7e9e467 commit 3df48fc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
27 changes: 27 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
export function supports (...manifests: Array<Partial<IManifest>>): IManifest

export interface IManifest {
bufferKeys: boolean
snapshots: boolean
permanence: boolean
seek: boolean
clear: boolean
getMany: boolean
keyIterator: boolean
valueIterator: boolean
iteratorNextv: boolean
iteratorAll: boolean
status: boolean
idempotentOpen: boolean
passiveOpen: boolean
serialize: boolean
createIfMissing: boolean
errorIfExists: boolean
deferredOpen: boolean
openCallback: boolean
promises: boolean
streams: boolean
encodings: Record<string, boolean>
events: Record<string, boolean>
additionalMethods: Record<string, boolean>
}
7 changes: 0 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ exports.supports = function supports (...manifests) {
const manifest = manifests.reduce((acc, m) => Object.assign(acc, m), {})

return Object.assign(manifest, {
// Features of abstract-leveldown
bufferKeys: manifest.bufferKeys || false,
snapshots: manifest.snapshots || false,
permanence: manifest.permanence || false,
Expand All @@ -15,18 +14,12 @@ exports.supports = function supports (...manifests) {
valueIterator: manifest.valueIterator || false,
iteratorNextv: manifest.iteratorNextv || false,
iteratorAll: manifest.iteratorAll || false,

// Features of abstract-leveldown that levelup doesn't have
status: manifest.status || false,
idempotentOpen: manifest.idempotentOpen || false,
passiveOpen: manifest.passiveOpen || false,
serialize: manifest.serialize || false,

// Features of disk-based implementations
createIfMissing: manifest.createIfMissing || false,
errorIfExists: manifest.errorIfExists || false,

// Features of level(up) that abstract-leveldown doesn't have yet
deferredOpen: manifest.deferredOpen || false,
openCallback: manifest.openCallback || false,
promises: manifest.promises || false,
Expand Down
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,30 @@
"description": "Create a manifest describing the abilities of a levelup or abstract-leveldown db",
"license": "MIT",
"scripts": {
"test": "standard && hallmark && (nyc -s node test/self.js | faucet) && nyc report",
"test": "ts-standard && tsc && standard && hallmark && (nyc -s node test/self.js | faucet) && nyc report",
"test-browsers-local": "airtap --coverage test/self.js",
"coverage": "nyc report -r lcovonly",
"hallmark": "hallmark --fix"
},
"types": "./index.d.ts",
"files": [
"test",
"CHANGELOG.md",
"index.js"
"index.js",
"index.d.ts"
],
"devDependencies": {
"@types/node": "^16.11.6",
"@voxpelli/tsconfig": "^3.0.0",
"airtap": "^4.0.3",
"airtap-playwright": "^1.0.1",
"faucet": "^0.0.1",
"hallmark": "^3.1.0",
"nyc": "^15.1.0",
"standard": "^16.0.3",
"tape": "^5.0.1"
"tape": "^5.0.1",
"ts-standard": "^10.0.0",
"typescript": "^4.4.4"
},
"repository": {
"type": "git",
Expand Down
7 changes: 7 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@voxpelli/tsconfig/node12.json",
"compilerOptions": {
"checkJs": false
},
"include": ["*.ts"]
}

0 comments on commit 3df48fc

Please sign in to comment.