Registry / devops / confidence

confidence

JSON →
library0.17.2jsnpmunverified

Confidence is a configuration management library that provides a structured document format and an API for serving dynamic configuration values. It builds upon standard JSON objects, introducing special `$`-prefixed keys for filtering values based on defined criteria, facilitating environment-specific configurations, A/B testing, and dynamic value selection. The current stable version is 5.0.1, which requires Node.js v12 or higher; older Node.js environments (pre-v12) must use version 4.x. The project is actively maintained, with releases primarily driven by bug fixes, feature enhancements, and Node.js compatibility updates. Its key differentiators include built-in support for environment variables, criteria-based filtering, value ranges for A/B testing, and metadata attachment, making it a robust solution for complex application configurations.

npm install confidence
INSTALL
IMPORT
SIG · CONFIDENCE
C
confidence
devopsjavascriptv0.17.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
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 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

Store
import { Store } from 'confidence';
const Store = require('confidence');
Confidence v5+ is ESM-only. For CommonJS, use v4 or earlier, or a bundler that handles ESM to CJS conversion.
ConfidenceStore
import { Store } from 'confidence';
The class is named 'Store', not 'ConfidenceStore', despite being referred to as 'confidenceStore' in some documentation snippets (e.g., 'new confidenceStore').

Demonstrates initializing a Confidence Store, retrieving configuration values with and without criteria, and showcases environment variable integration.

import { Store } from 'confidence'; const configDoc = { "key1": "abc", "key2": { "$filter": "env", "production": { "deeper": "production_value" }, "$default": { "$filter": "platform", "android": 0, "ios": 1, "$default": 2 } }, "key3": { "sub1": 123, "sub2": { "$filter": "xfactor", "yes": 6, "$default": 7 } }, "mysql": { "host": { "$env": "MYSQL_HOST" }, "port": { "$env": "MYSQL_PORT" }, "user": { "$env": "MYSQL_USER" } } }; const store = new Store(configDoc); // Simulate environment variables for demonstration process.env.MYSQL_HOST = process.env.MYSQL_HOST ?? 'localhost'; process.env.MYSQL_PORT = process.env.MYSQL_PORT ?? '3306'; process.env.MYSQL_USER = process.env.MYSQL_USER ?? 'testuser'; console.log('Without criteria:'); console.log(store.get('/')); const criteria = { "env": "production", "platform": "ios", "xfactor": "yes" }; console.log('\nWith criteria:'); console.log(store.get('/', criteria)); console.log('\nSpecific key with criteria:'); console.log(store.get('/key2/deeper', criteria)); console.log('\nEnvironment variable based config:'); console.log(store.get('/mysql'));
Debug
Known issues
breakingConfidence v5.x drops support for Node.js versions older than v12. Applications running on Node.js v10 or earlier must remain on Confidence v4.x or upgrade their Node.js environment.
fix
Upgrade Node.js to v12 or higher, or explicitly install `confidence@4` for older Node.js environments (`npm install confidence@4`).
affects: >=5.0.0
breakingConfidence v5.x is distributed as an ES Module (ESM) and no longer provides a CommonJS (CJS) entry point. Direct `require()` statements will fail in Node.js environments unless transpiled or using dynamic `import()`.
fix
Update import statements to use ES Modules syntax (`import { Store } from 'confidence';`). For CJS-only projects, consider using dynamic `import()` or stick to `confidence@4`.
affects: >=5.0.0
gotchaThe configuration document uses special `$`-prefixed keys (e.g., `$filter`, `$default`, `$env`) for directives. Attempting to use these prefixes for regular data keys will lead to unexpected behavior or errors as they are reserved for Confidence's internal logic.
fix
Avoid using `$` as a prefix for your own configuration data keys. Restrict custom keys to alphanumeric characters and underscores.
affects: >=1.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Attempting to `require('confidence')` in a CommonJS module when using Confidence v5+.
fix
Change `const { Store } = require('confidence');` to `import { Store } from 'confidence';` and ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`). For CJS-only projects, install `confidence@4`.
TypeError: Cannot read properties of undefined (reading 'get')
Trying to call `store.get()` before initializing the `Store` instance with a configuration document, or passing an invalid document.
fix
Ensure `new Store(document)` is called with a valid JSON-like object before attempting to access methods like `get` or `meta`. Check the `document` for syntax errors.
Upgrade
Version history
0.17.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
confidence — npm install confidence · libregistry