Big update!Introducing GitHub Bot Commands. Learn more
Socket
Log inBook a demo

defaults

Package Overview
Dependencies
1
Maintainers
2
Versions
5
Issues
File Explorer

Advanced tools

defaults

merge single level defaults over a config object

    1.0.4latest

Version published
Maintainers
2
Weekly downloads
13,000,748
decreased by-12.01%

Weekly downloads

Changelog

Source

  • Update repo reference 587321d

https://github.com/sindresorhus/node-defaults/compare/v1.0.3...v1.0.4

Readme

Source

defaults

A simple one level options merge utility

Install

npm install defaults

Usage

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.

Keywords

FAQs

What is defaults?

merge single level defaults over a config object

Is defaults popular?

The npm package defaults receives a total of 10,395,852 weekly downloads. As such, defaults popularity was classified as popular.

Is defaults well maintained?

We found that defaults demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 2 open source maintainers collaborating on the project.

Last updated on 10 Oct 2022

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket

Product

Subscribe to our newsletter

Get open source security insights delivered straight into your inbox. Be the first to learn about new features and product updates.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc