{"name":"defaults","version":"3.0.0","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":">=18"},"scripts":{"test":"xo && ava && tsd"},"keywords":["config","defaults","options","object","merge","assign","properties","deep"],"devDependencies":{"ava":"^5.3.1","tsd":"^0.29.0","xo":"^0.56.0"},"types":"./index.d.ts","gitHead":"4b2f4e700baeddf6f808c077a23ff632fa96c35d","bugs":{"url":"https://github.com/sindresorhus/node-defaults/issues"},"homepage":"https://github.com/sindresorhus/node-defaults#readme","_id":"defaults@3.0.0","_nodeVersion":"18.17.1","_npmVersion":"9.2.0","dist":{"integrity":"sha512-RsqXDEAALjfRTro+IFNKpcPCt0/Cy2FqHSIlnomiJp9YGadpQnrtbRpSgN2+np21qHcIKiva4fiOQGjS9/qR/A==","shasum":"60b9e0003df1018737c2ce3f4289d8f64786c9c4","tarball":"http://registry-npm.ywwl.com/defaults/download/defaults-3.0.0.tgz","fileCount":5,"unpackedSize":5654,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDnbZW1m/Oj88f6ZCihv2bDmi/nexWsxI20qI5lQD/YLgIhAKptxTDoijRlCPAQpR9kQXQzb8jMff6ZEQ2fyVTkXZOC"}],"size":2490,"noattachment":false,"key":"/defaults/-/defaults-3.0.0.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_3.0.0_1697623943867_0.63856410746187"},"_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":1697623944086,"_cnpm_publish_time":1697623944086,"dist-tags":{"latest":"3.0.0"}}