New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ts-options-defaults

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-options-defaults - npm Package Compare versions

Comparing version 0.0.3-7 to 0.0.10

5

package.json
{
"name": "ts-options-defaults",
"version": "0.0.3-7",
"version": "0.0.10",
"license": "GPL-3.0",

@@ -17,7 +17,6 @@ "files": [

"chalk": "^4.1.0",
"find-up": "^4.1.0",
"ts-essentials": "^7.0.0",
"ts-import": "0.0.9-8",
"ts-import": "0.0.10",
"typescript": "^3.9.5"
}
}

7

README.md
# ts-options-defaults
`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.
`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). **ts-options-defaults** fixes that problem - **it merges objects deeply, overrides arrays and classes** (different than Object) plus the result remains strongly typed.

@@ -21,7 +21,8 @@ > Options-defaults design pattern implementation for reliable configuration.

export class Something {
static defaults: Required<ISomeOptions> = {
static defaults = {
logger: console,
};
constructor(public options: IRatOptions) {
options: ISomeOptions & typeof Something.defaults;
constructor(options?: ISomeOptions) {
this.options = defaults(Rat.defaults, options);

@@ -28,0 +29,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc