Registry / database / level-supports

level-supports

JSON →
library6.2.0jsnpmunverified

level-supports is a utility package within the LevelDB ecosystem designed to generate a manifest object detailing the capabilities of an `abstract-level` database instance. This manifest allows consumers of a database to programmatically check for specific features, such as `permanence`, `encodings` (like `utf8`), `implicitSnapshots`, `explicitSnapshots`, and `has` (for `has()` and `hasMany()`). The current stable version is 6.2.0. Releases are typically driven by new `abstract-level` features or Node.js compatibility updates, with a focus on semantic versioning for breaking changes. Its key differentiator is providing a standardized, merged, and enriched feature description, moving beyond simple boolean checks to handle more complex truthy values for future extensibility.

npm install level-supports
INSTALL
IMPORT
SIG · LEVEL-SUPPORTS
L
level-supports
databasejavascriptv6.2.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

supports
✓ import { supports } from 'level-supports'
✗ const supports = require('level-supports')
Since v3.0.0, 'level-supports' exports a named 'supports' function, not a default export. CommonJS 'require' still works, but ESM import is preferred in modern Node.js environments.
supports
✓ const { supports } = require('level-supports')
This is the correct CommonJS pattern for named exports. Prior to v3.0.0, it was a default export accessed as `const supports = require('level-supports')`.
Manifest
✓ import type { Manifest } from 'level-supports'
TypeScript type for the manifest object is available for better type safety when defining custom manifests or consuming the generated one.

Demonstrates how to create a support manifest, attach it to a database object, and check for specific features like permanence, encodings, and `has()`.

import { supports } from 'level-supports'; // Simulate a database with specific capabilities const myCustomDb = { // In a real scenario, these would come from the database driver supports: supports({ permanence: true, encodings: { utf8: true, json: { value: true, array: false }, binary: {} // Truthy, details allowed }, implicitSnapshots: true, explicitSnapshots: false, has: true }) }; console.log(`Database supports permanence: ${!!myCustomDb.supports.permanence}`); console.log(`Database supports JSON encoding: ${!!myCustomDb.supports.encodings.json}`); if (myCustomDb.supports.has) { console.log('Database implements has() and hasMany().'); } else { console.log('Database does not implement has().'); } // Merge with another manifest (e.g., from a plugin) const pluginManifest = { signals: true }; const mergedSupports = supports(myCustomDb.supports, pluginManifest); console.log(`Database supports signals (after merge): ${!!mergedSupports.signals}`);
Debug
Known issues
breakingVersion 6.0.0 dropped support for Node.js versions older than 16. Ensure your environment meets this requirement.
fix
Upgrade your Node.js environment to version 16 or newer. If you need to support older Node.js versions, pin 'level-supports' to '~5.x'.
affects: >=6.0.0
breakingVersion 5.0.0 removed properties that were implicitly true since 'abstract-level@1'. This streamlines the manifest, focusing on explicit feature declarations.
fix
Review your manifest creation and usage. If you were relying on implicit truths for older properties, you might need to explicitly define them if still required, though most were redundant with `abstract-level@1`.
affects: >=5.0.0
breakingVersion 3.0.0 introduced significant breaking changes: it is no longer compatible with `abstract-leveldown` or `levelup` directly, and it changed from a default export to a named export (`{ supports }`). Additionally, `encodings` and `events` properties are now always objects.
fix
Update import statements from `const supports = require('level-supports')` to `const { supports } = require('level-supports')` or `import { supports } from 'level-supports'`. Ensure your database implementations are `abstract-level` compatible. Adjust manifest property checks for `encodings` and `events` to expect objects.
affects: >=3.0.0
gotchaManifest properties are truthy rather than strictly boolean. When checking for support, always use `if (db.supports.feature)` instead of `if (db.supports.feature === true)` to accommodate future extensibility where features might have object values.
fix
Adopt the `if (db.supports.feature)` pattern for all feature checks to ensure forward compatibility.
affects: *
deprecated`implicitSnapshots` is aliased as `snapshots` for backwards compatibility. While `snapshots` still works, `implicitSnapshots` is the preferred and more descriptive property name.
fix
Update code referencing `db.supports.snapshots` to `db.supports.implicitSnapshots` for clarity and future-proofing.
affects: >=6.1.0
Errors
Common errors & fixes
TypeError: (0, level_supports_1.default) is not a function
Attempting to use `level-supports` v3.0.0 or higher with a default import/require syntax, but the package changed to a named export.
fix
Change your import statement from `import supports from 'level-supports'` to `import { supports } from 'level-supports'` or for CommonJS, `const supports = require('level-supports')` to `const { supports } = require('level-supports')`.
Error: Persistent storage is required
A consumer of the database is checking for `db.supports.permanence` but the provided manifest or underlying database driver indicates `permanence: false`.
fix
Ensure that the `level-supports` manifest accurately reflects the underlying database's capabilities, especially for critical features like `permanence`. If persistence is required, use a database that provides it or configure the manifest accordingly.
Upgrade
Version history
6.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
Resources
level-supports — npm install level-supports · libregistry