云盘
志元云盘
备份云盘
Home
/
志元云盘
/
webdav
/
sync
/
c
/
vue-modbus
/
modbus-project
/
node_modules
/
defaults
File
OriginalPic
Thumbnails
CopyAllDownloadUrl
EditTime
Size
index.js
2024-07-14 16:19:02
277 B
LICENSE
2024-07-14 16:19:02
1.09 KB
package.json
2024-07-14 16:19:02
632 B
README.md
2024-07-14 16:19:02
771 B
test.js
2024-07-14 16:19:02
1.03 KB
# defaults > A simple one level options merge utility ## Install ```sh npm install defaults ``` ## Usage ```js const defaults = require('defaults'); const handle = (options, fn) => { options = defaults(options, { timeout: 100 }); setTimeout(() => { fn(options); }, options.timeout); } handle({timeout: 1000}, () => { // We're here 1000 ms later }); handle({timeout: 10000}, () => { // We're here 10s later }); ``` ## Summary this module exports a function that takes 2 arguments: `options` and `defaults`. When called, it overrides all of `undefined` properties in `options` with the clones of properties defined in `defaults` Sidecases: if called with a falsy `options` value, options will be initialized to a new object before being merged onto.
2025-08-29 19:58:17 Friday 216.73.216.167 Runningtime:0.024s Mem:1.48 MB