LevelDB Feature Support Manifest

6.2.0 · active · verified Tue Apr 21

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.

Common errors

Warnings

Install

Imports

Quickstart

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}`);

view raw JSON →