{"_id":"defaults","_rev":"4628224","name":"defaults","description":"Easily handle defaults for your options","dist-tags":{"latest":"3.0.0"},"maintainers":[{"name":"sindresorhus","email":""}],"time":{"modified":"2026-04-10T18:43:36.000Z","created":"2013-02-03T02:22:58.793Z","3.0.0":"2023-10-18T10:12:24.086Z","2.0.2":"2023-08-28T10:13:33.992Z","2.0.1":"2023-04-11T07:32:40.702Z","2.0.0":"2023-04-11T07:26:47.523Z","1.0.4":"2022-10-10T06:15:56.068Z","1.0.3":"2015-10-02T22:27:02.099Z","1.0.2":"2015-03-15T03:29:36.798Z","1.0.1":"2015-03-15T03:23:08.224Z","1.0.0":"2013-02-03T02:22:58.793Z"},"users":{"shriek":true,"kontrax":true,"nichoth":true,"tur-nr":true,"wangnan0610":true,"rdydns":true,"hecto932":true,"joaquinaraujo":true,"monjer":true,"steel1990":true},"repository":{"type":"git","url":"git+https://github.com/sindresorhus/node-defaults.git"},"versions":{"3.0.0":{"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":{"shasum":"60b9e0003df1018737c2ce3f4289d8f64786c9c4","size":2490,"noattachment":false,"key":"/defaults/-/defaults-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/defaults/download/defaults-3.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/defaults_3.0.0_1697623943867_0.63856410746187"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-10-18T10:12:24.086Z","publish_time":1697623944086,"_source_registry_name":"default","_cnpm_publish_time":1697623944086},"2.0.2":{"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":{"shasum":"63dccc0d0b8a093f3ac91c1a5da7c249d38d5af5","size":2446,"noattachment":false,"key":"/defaults/-/defaults-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/defaults/download/defaults-2.0.2.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/defaults_2.0.2_1693217613797_0.9623793340764013"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-08-28T10:13:33.992Z","publish_time":1693217613992,"_source_registry_name":"default","_cnpm_publish_time":1693217613992},"2.0.1":{"name":"defaults","version":"2.0.1","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":"2ba983197d7122c64c5bfcfd73759b9d8bb70dd7","bugs":{"url":"https://github.com/sindresorhus/node-defaults/issues"},"homepage":"https://github.com/sindresorhus/node-defaults#readme","_id":"defaults@2.0.1","_nodeVersion":"19.8.1","_npmVersion":"9.2.0","dist":{"shasum":"4350551a163121e9726840babccdedbcafbf7b3a","size":2433,"noattachment":false,"key":"/defaults/-/defaults-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/defaults/download/defaults-2.0.1.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/defaults_2.0.1_1681198360533_0.7632755889873994"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-04-11T07:32:40.702Z","publish_time":1681198360702,"_cnpm_publish_time":1681198360702},"2.0.0":{"name":"defaults","version":"2.0.0","description":"Easily handle defaults for your options","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/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":"73bd2e9087a8e571f540502355797b3c85d4da5b","bugs":{"url":"https://github.com/sindresorhus/defaults/issues"},"homepage":"https://github.com/sindresorhus/defaults#readme","_id":"defaults@2.0.0","_nodeVersion":"19.8.1","_npmVersion":"9.2.0","dist":{"shasum":"7805dec8c5e8ba4f4fb90868961e3102eb2ee649","size":2430,"noattachment":false,"key":"/defaults/-/defaults-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/defaults/download/defaults-2.0.0.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/defaults_2.0.0_1681198007338_0.06066704013325652"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-04-11T07:26:47.523Z","publish_time":1681198007523,"_cnpm_publish_time":1681198007523},"1.0.4":{"name":"defaults","version":"1.0.4","description":"merge single level defaults over a config object","main":"index.js","funding":"https://github.com/sponsors/sindresorhus","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git://github.com/sindresorhus/node-defaults.git"},"keywords":["config","defaults","options","object","merge","assign","properties","deep"],"author":{"name":"Elijah Insua","email":"tmpvar@gmail.com"},"license":"MIT","dependencies":{"clone":"^1.0.2"},"devDependencies":{"tap":"^2.0.0"},"gitHead":"15efe64bad27f59ca6658b44e018d719533d347a","bugs":{"url":"https://github.com/sindresorhus/node-defaults/issues"},"homepage":"https://github.com/sindresorhus/node-defaults#readme","_id":"defaults@1.0.4","_nodeVersion":"16.15.0","_npmVersion":"8.3.2","dist":{"shasum":"b0b02062c1e2aa62ff5d9528f0f98baa90978d7a","size":1978,"noattachment":false,"key":"/defaults/-/defaults-1.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/defaults/download/defaults-1.0.4.tgz"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/defaults_1.0.4_1665382555724_0.5269675784016179"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-10-10T06:33:03.618Z","publish_time":1665382556068,"_cnpm_publish_time":1665382556068},"1.0.3":{"name":"defaults","version":"1.0.3","description":"merge single level defaults over a config object","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git://github.com/tmpvar/defaults.git"},"keywords":["config","defaults"],"author":{"name":"Elijah Insua","email":"tmpvar@gmail.com"},"license":"MIT","dependencies":{"clone":"^1.0.2"},"devDependencies":{"tap":"^2.0.0"},"gitHead":"8831ec32a5f999bfae1a8c9bf32880971ed7c6f2","bugs":{"url":"https://github.com/tmpvar/defaults/issues"},"homepage":"https://github.com/tmpvar/defaults#readme","_id":"defaults@1.0.3","_shasum":"c656051e9817d9ff08ed881477f3fe4019f3ef7d","_from":".","_npmVersion":"2.14.4","_nodeVersion":"4.1.1","_npmUser":{"name":"tmpvar","email":"tmpvar@gmail.com"},"dist":{"shasum":"c656051e9817d9ff08ed881477f3fe4019f3ef7d","size":1978,"noattachment":false,"key":"/defaults/-/defaults-1.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/defaults/download/defaults-1.0.3.tgz"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1443824822099,"_cnpm_publish_time":1443824822099,"_hasShrinkwrap":false},"1.0.2":{"name":"defaults","version":"1.0.2","description":"merge single level defaults over a config object","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git://github.com/tmpvar/defaults.git"},"keywords":["config","defaults"],"author":{"name":"Elijah Insua","email":"tmpvar@gmail.com"},"license":"MIT","dependencies":{"clone":"~0.1.5"},"devDependencies":{"tap":"~0.4.0"},"gitHead":"22c57d1f87a2f03c1f9d21bd39c67db8553a0064","bugs":{"url":"https://github.com/tmpvar/defaults/issues"},"homepage":"https://github.com/tmpvar/defaults","_id":"defaults@1.0.2","_shasum":"6902e25aa047649a501e19ef9e98f3e8365c109a","_from":".","_npmVersion":"1.4.23","_npmUser":{"name":"tmpvar","email":"tmpvar@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"6902e25aa047649a501e19ef9e98f3e8365c109a","size":1992,"noattachment":false,"key":"/defaults/-/defaults-1.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/defaults/download/defaults-1.0.2.tgz"},"directories":{},"publish_time":1426390176798,"_cnpm_publish_time":1426390176798,"_hasShrinkwrap":false},"1.0.1":{"name":"defaults","version":"1.0.1","description":"merge single level defaults over a config object","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git://github.com/tmpvar/defaults.git"},"keywords":["config","defaults"],"author":{"name":"Elijah Insua","email":"tmpvar@gmail.com"},"license":"MIT","dependencies":{"clone":"~0.1.5"},"devDependencies":{"tap":"~0.4.0"},"gitHead":"d3ca162791cdbdb2c0313152ef89c57fcbf793c9","bugs":{"url":"https://github.com/tmpvar/defaults/issues"},"homepage":"https://github.com/tmpvar/defaults","_id":"defaults@1.0.1","_shasum":"00f1a15ad95ae500e287bfec9c4da918835c97ac","_from":".","_npmVersion":"1.4.23","_npmUser":{"name":"tmpvar","email":"tmpvar@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"dist":{"shasum":"00f1a15ad95ae500e287bfec9c4da918835c97ac","size":1992,"noattachment":false,"key":"/defaults/-/defaults-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/defaults/download/defaults-1.0.1.tgz"},"directories":{},"publish_time":1426389788224,"_cnpm_publish_time":1426389788224,"_hasShrinkwrap":false},"1.0.0":{"name":"defaults","version":"1.0.0","description":"merge single level defaults over a config object","main":"index.js","scripts":{"test":"node test.js"},"repository":{"type":"git","url":"git://github.com/tmpvar/defaults.git"},"keywords":["config","defaults"],"author":{"name":"Elijah Insua","email":"tmpvar@gmail.com"},"license":"MIT","readmeFilename":"README.md","dependencies":{"clone":"~0.1.5"},"devDependencies":{"tap":"~0.4.0"},"_id":"defaults@1.0.0","dist":{"shasum":"3ae25f44416c6c01f9809a25fcdd285912d2a6b1","size":1313,"noattachment":false,"key":"/defaults/-/defaults-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/defaults/download/defaults-1.0.0.tgz"},"_npmVersion":"1.1.65","_npmUser":{"name":"tmpvar","email":"tmpvar@gmail.com"},"maintainers":[{"name":"sindresorhus","email":""}],"directories":{},"publish_time":1359858178793,"_cnpm_publish_time":1359858178793,"_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","_attachments":{},"homepage":"https://github.com/sindresorhus/node-defaults#readme","bugs":{"url":"https://github.com/sindresorhus/node-defaults/issues"},"license":"MIT"}