Registry / storage / config-cache

config-cache

JSON →
library6.0.1jsnpmunverified

A general-purpose JavaScript object storage library providing get/set with dot-notation, union, extend, delete, and constant methods. Version 6.0.1 is stable; last updated in 2020. It is part of the jonschlinkert ecosystem and leverages underyling packages like get-value and set-value. Compared to other cache solutions, it focuses on object manipulation with chaining and supports deep nested property access. Note that version 5.0 introduced breaking changes removing many utility methods.

npm install config-cache
INSTALL
IMPORT
SIG · CONFIG-CACHE
C
config-cache
storagejavascriptv6.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

Config
import Config from 'config-cache'
const { Config } = require('config-cache')
Default export is the constructor. CommonJS users should use const Config = require('config-cache').
Config
const Config = require('config-cache')
const config = require('config-cache')
The require returns the constructor, not an instance.
mixin
import Config from 'config-cache'; Config.mixin(obj)
import { mixin } from 'config-cache'
mixin is a static method on Config, not a named export.

Demonstrates basic usage: creating a Config instance, setting values with dot notation, getting values, extending, union, deletion, and inspecting the cache.

const Config = require('config-cache'); const config = new Config(); config.set('name', 'Alice'); config.set('address.city', 'New York'); config.get('name'); // 'Alice' config.get('address.city'); // 'New York' config.extend({ age: 30 }); config.union('tags', ['a', 'b'], ['c']); config.del('address'); console.log(config.cache); // { name: 'Alice', age: 30, tags: ['a', 'b', 'c'] }
Debug
Known issues
breakingMethods removed in version 5.0: clone, keys, omit, exists, has, hasOwn, data, process, plasma, extendData
fix
Use alternative libraries: clone-deep, has-value, plasma-cache, or native methods.
affects: >=5.0.0
breakingThe method 'get' now returns undefined instead of throwing when key does not exist, matching get-value behavior.
fix
Check for undefined or use has-value to verify existence.
affects: >=5.0.0
deprecatedThe package has not been updated since 2020; consider using modern alternatives like lodash.set, dot-prop, or a dedicated config module.
fix
Migrate to a maintained library.
affects: >=0.0.0
gotchaThe 'set' method with an object as first argument merges into cache, not replace. If you pass a plain object to set, it will extend the cache.
fix
To replace entire cache, use config.cache = newObj.
affects: >=0.0.0
gotchaThe 'del' method with no arguments resets the entire cache. This may be unintentional if you meant to delete a single key.
fix
Always pass a key or array of keys to del.
affects: >=0.0.0
gotchaThe 'union' method mutates the cache array in place and does not return the new array; it returns the Config instance for chaining.
fix
Access the value via config.get('key') after union.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'config-cache'
Package not installed or not in node_modules.
fix
Run 'npm install config-cache' or add it to package.json.
config.get is not a function
Using require incorrectly: const config = require('config-cache') returns the constructor, not an instance.
fix
Use 'const Config = require('config-cache'); const config = new Config();'
TypeError: config.set(...).set is not a function
Using set with an object argument returns the Config instance for chaining, but if you accidentally use set on a non-chainable return, this may occur.
fix
Ensure set is called correctly: config.set('key', value) or config.set({ ... }).
config.get('a.b') returns undefined even though object exists
The get method uses get-value which does not evaluate dot notation if the key already contains dots; you must pass separate arguments or an array.
fix
Use config.get(['a', 'b']) or config.get('a', 'b').
Upgrade
Version history
6.0.1latest on npm
Audit
Dependencies
get-valuerequiredUsed internally for deep property access via dot notation.
set-valuerequiredUsed internally for setting deep properties.
has-valuerequiredUsed internally to check for nested property existence.
union-valuerequiredUsed internally for array union operations.
set-getterrequiredUsed internally for getter/setter definition.
Agent activity
29 hits · last 30 days
node
26
Resources
config-cache — npm install config-cache · libregistry