
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
Set object values using property chaining syntax.
Support this project by ⭐️ starring and sharing it. Follow me to see what other cool projects I'm working on! ❤️
Setting a value on an arbitrary nested path can be cumbersome to do correctly.
For example, someObject.propA.propB.propC = 'value' on a potentially empty someObject requires a guard for each nested property.
chainsetconst someObject = {}
if (!Object.hasOwn(someObject, 'propA')) {
someObject.propA = {}
}
if (!Object.hasOwn(someObject.propA, 'propB')) {
someObject.propA.propB = {}
}
someObject.propA.propB.propC = 'value'
chainsetconst someObject = chainset()
someObject.propA.propB.propC = 'value'
import chainset from 'chainset'
const object = chainset() // => {}
// Automatically initializes 'propB' & 'propC' to objects
object.propA.propB.propC = 'value'
console.log(object)
/*
{
propA: {
propB: {
propC: 'value'
}
}
}
*/
const object = chainset({
foo: {
bar: {}
}
})
// Automatically initializes 'propA' & 'propB' to objects
object.foo.bar.propA.propB = 'value'
console.log(object)
/*
{
foo: {
bar: {
propA: {
propB: 'value'
}
}
}
}
*/
Type: object
Default: Object.create(null) (a pure, prototype-less object)
The object to ehance with "chain-setting" support.
Type: boolean | number
Default: true
How deep to add automatic object initialization support on access. Set to true to add support infinitely. Set a number to limit the depth of objects to add support to. Set to false to only add support to the immediate object.
Type: RegExp | (string|RegExp)[] | (path, object) => boolean
A regular expression pattern, array of strings/patterns, or function that restrict what property names will be initialized on access.
Type: (key?: string) => object
Default: () => Object.create(null)
A function that creates a new object to use when a property is accessed.
FAQs
Set object values using property chaining syntax
We found that chainset demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.