
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
@poppinss/object-builder
Advanced tools
A convenience class to create an object with dynamic properties
Install the package from the npm package registry.
# Npm
npm i @poppinss/object-builder
# Yarn
yarn add @poppinss/object-builder
# Pnpm
pnpm add @poppinss/object-builder
The ObjectBuilder is a convenience class to create an object with dynamic properties. Consider the following example, where we wrap our code inside conditionals before adding the property b to the startingObject.
const startingObject = {
a: 1
// Add "b", if it exists
...(b ? { b } : {})
}
// OR
if (b) {
startingObject.b = b
}
Instead of writing conditionals, you can consider using the Object builder fluent API.
import { ObjectBuilder } from '@poppinss/object-builder'
const builder = new ObjectBuilder({ a: 1 })
const plainObject = builder.add('b', b).toObject()
By default, only the undefined values are ignored. However, you can also ignore null values.
import { ObjectBuilder } from '@poppinss/object-builder'
const ignoreNullValues = true
const builder = new ObjectBuilder({ a: 1 }, ignoreNullValues)
Following are the available methods on the ObjectBuilder class.
builder.remove(key)
builder.has(key)
builder.get(key)
builder.add(key)
builder.toObject() // get plain object
One of the primary goals of Poppinss is to have a vibrant community of users and contributors who believes in the principles of the framework.
We encourage you to read the contribution guide before contributing to the framework.
In order to ensure that the Poppinss community is welcoming to all, please review and abide by the Code of Conduct.
Poppinss object builder is open-sourced software licensed under the MIT license.
FAQs
A convenience class to create an object with dynamic properties
The npm package @poppinss/object-builder receives a total of 146,906 weekly downloads. As such, @poppinss/object-builder popularity was classified as popular.
We found that @poppinss/object-builder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.