{"name":"defaults","version":"2.0.2","description":"Easily handle defaults for your options","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/node-defaults.git"},"funding":"https://github.com/sponsors/sindresorhus","type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"engines":{"node":">=16"},"scripts":{"test":"xo && ava && tsd"},"keywords":["config","defaults","options","object","merge","assign","properties","deep"],"devDependencies":{"ava":"^5.2.0","tsd":"^0.28.1","xo":"^0.54.0"},"types":"./index.d.ts","gitHead":"fa7d41df77ba65adf4a8cd72f342b469dd0295cb","bugs":{"url":"https://github.com/sindresorhus/node-defaults/issues"},"homepage":"https://github.com/sindresorhus/node-defaults#readme","_id":"defaults@2.0.2","_nodeVersion":"18.17.1","_npmVersion":"9.2.0","dist":{"integrity":"sha512-cuIw0PImdp76AOfgkjbW4VhQODRmNNcKR73vdCH5cLd/ifj7aamfoXvYgfGkEAjNJZ3ozMIy9Gu2LutUkGEPbA==","shasum":"63dccc0d0b8a093f3ac91c1a5da7c249d38d5af5","tarball":"http://registry-npm.ywwl.com/defaults/download/defaults-2.0.2.tgz","fileCount":5,"unpackedSize":5548,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDcbvSwgUgUYjvD++raABgiB4vjYdgTQ8jlmG/mhTRkxQIhAJIjzWjHmjlTSFCQbPxAMDeuZV8941uovlDt1//iFt40"}],"size":2446,"noattachment":false,"key":"/defaults/-/defaults-2.0.2.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/defaults_2.0.2_1693217613797_0.9623793340764013"},"_hasShrinkwrap":false,"readme":"# defaults\n\n> Easily handle defaults for your options\n\n## Install\n\n```sh\nnpm install defaults\n```\n\n## Usage\n\n```js\nimport defaults from 'defaults';\n\nconst calculate = options => {\n\toptions = defaults(options, {\n\t\ttimeout: {\n\t\t\tbefore: 100,\n\t\t\tafter: 100\n\t\t}\n\t});\n\n\tconsole.log(options);\n\t//=> {timeout: {before: 200, after: 100}}\n\n\t// …\n}\n\n// …\n\ncalculate({timeout: {before: 200}});\n```\n\n## API\n\n### defaults(options, defaultOptions?)\n\nDeeply merges the given options with the specified defaults and returns a new object.\n\nThe given parameters are deep-cloned and never mutated.\n\n#### options\n\nType: `object`\n\nThe user-provided options.\n\nIf the value is not a plain object, a new plain object will be used instead.\n\n#### defaultOptions\n\nType: `object | undefined`\n\nThe default options to use when a value is not provided in the `options` object.\n\n## FAQ\n\n### Why use this over [object-spread](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax#spread_in_object_literals)?\n\n- Does not overwrite options if they are not defined in the `options` object\n- Supports deep merging of objects\n- Provides protection against prototype pollution attacks\n","publish_time":1693217613992,"_cnpm_publish_time":1693217613992,"dist-tags":{"latest":"3.0.0"}}