UNPKG

basebee

Version:

Basebee is a powerful key-value store built on top of Autobase and Hyperbee, designed to efficiently manage data with customizable key/value encodings, prefix-based key organization, and batch operations. It integrates stream-based APIs for handling key-v

19 lines (14 loc) 807 B
import c from "compact-encoding"; import {nullSafeEncoding} from "./nullSafeEncoding.js"; export function prepareOptions(rangeOrKey, options, config) { const _opts = {...(rangeOrKey || {}), ...(config || {}), ...(options || {})}; // Handle prefix: if options.prefix is undefined, fallback to config.prefix, otherwise null let prefix = options.prefix !== undefined ? options.prefix : (config.prefix !== undefined ? config.prefix : null); _opts.prefix = prefix; // For keyEncoding and valueEncoding, prioritize options, then fallback to config, and default to binary _opts.keyEncoding = options.keyEncoding || config.keyEncoding || c.binary; _opts.valueEncoding = nullSafeEncoding(options.valueEncoding || config.valueEncoding || c.binary); return _opts; }