defaults
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"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": "Elijah Insua <tmpvar@gmail.com>", | ||
"license": "MIT", | ||
"readmeFilename": "README.md", | ||
"dependencies": { | ||
"clone": "^1.0.2" | ||
}, | ||
"devDependencies": { | ||
"tap": "^2.0.0" | ||
} | ||
"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": "Elijah Insua <tmpvar@gmail.com>", | ||
"license": "MIT", | ||
"readmeFilename": "README.md", | ||
"dependencies": { | ||
"clone": "^1.0.2" | ||
}, | ||
"devDependencies": { | ||
"tap": "^2.0.0" | ||
} | ||
} |
# defaults | ||
A simple one level options merge utility | ||
> A simple one level options merge utility | ||
## install | ||
## Install | ||
`npm install defaults` | ||
```sh | ||
npm install defaults | ||
``` | ||
## use | ||
## Usage | ||
```javascript | ||
```js | ||
const defaults = require('defaults'); | ||
var defaults = require('defaults'); | ||
const handle = (options, fn) => { | ||
options = defaults(options, { | ||
timeout: 100 | ||
}); | ||
var handle = function(options, fn) { | ||
options = defaults(options, { | ||
timeout: 100 | ||
}); | ||
setTimeout(function() { | ||
fn(options); | ||
}, options.timeout); | ||
setTimeout(() => { | ||
fn(options); | ||
}, options.timeout); | ||
} | ||
handle({ timeout: 1000 }, function() { | ||
// we're here 1000 ms later | ||
handle({timeout: 1000}, () => { | ||
// We're here 1000 ms later | ||
}); | ||
handle({ timeout: 10000 }, function() { | ||
// we're here 10s later | ||
handle({timeout: 10000}, () => { | ||
// We're here 10s later | ||
}); | ||
``` | ||
## summary | ||
## Summary | ||
@@ -40,5 +40,1 @@ 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. | ||
## license | ||
[MIT](LICENSE) |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
3842
5
40
1