{"id":16101,"library":"level-supports","title":"LevelDB Feature Support Manifest","description":"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.","status":"active","version":"6.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/Level/supports","tags":["javascript","abstract-leveldown","database","db","level","levelup","manifest","typescript"],"install":[{"cmd":"npm install level-supports","lang":"bash","label":"npm"},{"cmd":"yarn add level-supports","lang":"bash","label":"yarn"},{"cmd":"pnpm add level-supports","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"const supports = require('level-supports')","symbol":"supports","correct":"import { supports } from 'level-supports'"},{"note":"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')`.","symbol":"supports","correct":"const { supports } = require('level-supports')"},{"note":"TypeScript type for the manifest object is available for better type safety when defining custom manifests or consuming the generated one.","symbol":"Manifest","correct":"import type { Manifest } from 'level-supports'"}],"quickstart":{"code":"import { supports } from 'level-supports';\n\n// Simulate a database with specific capabilities\nconst myCustomDb = {\n  // In a real scenario, these would come from the database driver\n  supports: supports({\n    permanence: true,\n    encodings: {\n      utf8: true,\n      json: { value: true, array: false },\n      binary: {} // Truthy, details allowed\n    },\n    implicitSnapshots: true,\n    explicitSnapshots: false,\n    has: true\n  })\n};\n\nconsole.log(`Database supports permanence: ${!!myCustomDb.supports.permanence}`);\nconsole.log(`Database supports JSON encoding: ${!!myCustomDb.supports.encodings.json}`);\n\nif (myCustomDb.supports.has) {\n  console.log('Database implements has() and hasMany().');\n} else {\n  console.log('Database does not implement has().');\n}\n\n// Merge with another manifest (e.g., from a plugin)\nconst pluginManifest = { signals: true };\nconst mergedSupports = supports(myCustomDb.supports, pluginManifest);\nconsole.log(`Database supports signals (after merge): ${!!mergedSupports.signals}`);","lang":"typescript","description":"Demonstrates how to create a support manifest, attach it to a database object, and check for specific features like permanence, encodings, and `has()`."},"warnings":[{"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'.","message":"Version 6.0.0 dropped support for Node.js versions older than 16. Ensure your environment meets this requirement.","severity":"breaking","affected_versions":">=6.0.0"},{"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`.","message":"Version 5.0.0 removed properties that were implicitly true since 'abstract-level@1'. This streamlines the manifest, focusing on explicit feature declarations.","severity":"breaking","affected_versions":">=5.0.0"},{"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.","message":"Version 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.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Adopt the `if (db.supports.feature)` pattern for all feature checks to ensure forward compatibility.","message":"Manifest 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.","severity":"gotcha","affected_versions":"*"},{"fix":"Update code referencing `db.supports.snapshots` to `db.supports.implicitSnapshots` for clarity and future-proofing.","message":"`implicitSnapshots` is aliased as `snapshots` for backwards compatibility. While `snapshots` still works, `implicitSnapshots` is the preferred and more descriptive property name.","severity":"deprecated","affected_versions":">=6.1.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"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')`.","cause":"Attempting to use `level-supports` v3.0.0 or higher with a default import/require syntax, but the package changed to a named export.","error":"TypeError: (0, level_supports_1.default) is not a function"},{"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.","cause":"A consumer of the database is checking for `db.supports.permanence` but the provided manifest or underlying database driver indicates `permanence: false`.","error":"Error: Persistent storage is required"}],"ecosystem":"npm"}