
Security News
Next.js Patches Critical Middleware Vulnerability (CVE-2025-29927)
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
ts-options-defaults
Advanced tools
`Object.assign({}, defaults, options)` and equivalent with destructing `{...defaults, ...options}` come with a pitfall of creating only a _shallow copy_. Lodash `_.merge` works on deep properties, but it merges arrays and that usually makes no sense in th
Object.assign({}, defaults, options)
and equivalent with destructing {...defaults, ...options}
come with a pitfall of creating only a shallow copy. Lodash _.merge
works on deep properties, but it merges arrays and that usually makes no sense in the context of default options (also it mutates first element; this package doesn't). This package fixes that problem - it merges objects deeply, overrides arrays and merges class functions plus the result remains strongly typed.
Options-defaults design pattern implementation for reliable configuration.
npm i ts-options-defaults
import { defaults } from 'ts-options-defaults';
export interface ISomeOptions {
logger?: Partial<Console>;
}
export class Something {
static defaults: Required<ISomeOptions> = {
logger: console,
};
constructor(public options: IRatOptions) {
this.options = defaults(Rat.defaults, options);
}
}
import { defaults } from '../src';
class TestLogger {
constructor(public name = `TestLogger`) {}
log() {
console.log(`Call from ${this.name}`);
}
}
const someDefaults = {
console,
nested: {
property: 'default',
shouldBeDefault: 'default',
array: ['default1', 'default2'],
},
};
const someOptions = {
nested: {
property: 'overriden',
array: ['overriden1'],
},
array: ['overriden'],
};
const options = defaults(
someDefaults,
someOptions,
{
console: {
log: () => {
console.log(`TEST`);
},
},
},
{
console: new TestLogger(),
},
);
options.console.log(`log`); // "Call from TestLogger"
options.console.debug(`debug`); // "debug"
// options will be:
{
"nested": {
"property": "overriden",
"shouldBeDefault": "default",
"array": [
"overriden1"
]
},
"array": [
"overriden"
]
}
// someDefaults will not be mutated!
FAQs
Options-defaults design pattern implementation for reliable configuration. It merges objects deeply, overrides arrays and classes (different than Object) and the result remains strongly typed.
The npm package ts-options-defaults receives a total of 16 weekly downloads. As such, ts-options-defaults popularity was classified as not popular.
We found that ts-options-defaults 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
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.