云盘
志元云盘
备份云盘
Home
/
志元云盘
/
webdav
/
home
/
moxa
/
c
/
vue-modbus
/
modbus-project
/
node_modules
/
defaults
File
OriginalPic
Thumbnails
CopyAllDownloadUrl
EditTime
Size
index.js
1985-10-26 16:15:00
277 B
LICENSE
1985-10-26 16:15:00
1.09 KB
package.json
1985-10-26 16:15:00
632 B
README.md
1985-10-26 16:15:00
771 B
test.js
1985-10-26 16:15:00
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-09-03 00:05:54 Wednesday 216.73.216.107 Runningtime:0.015s Mem:1.48 MB