Skip to content
🇩 Recursively assign default properties. Lightweight and Fast!
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci fix circle Feb 7, 2019
lib fix: improve es5 compatibility (#2, #9) Jan 1, 2020
test test: improve coverage Feb 7, 2019
.editorconfig initial commit Feb 7, 2019
.eslintrc.yml initial commit Feb 7, 2019
.gitignore initial commit Feb 7, 2019
CHANGELOG.md chore(release): 1.0.0 Feb 2, 2020
LICENSE initial commit Feb 7, 2019
README.md chore: fix typo in readme Apr 17, 2019
jest.config.js initial commit Feb 7, 2019
package.json chore(release): 1.0.0 Feb 2, 2020
renovate.json initial commit Feb 7, 2019
yarn.lock initial commit Feb 7, 2019

README.md

🇩 defu

Recursively assign default properties. Lightweight and Fast!

Standard JS david dm codecov circleci

npm version npm downloads package phobia bundle phobia

Install

Install package:

npm install defu

OR

yarn add defu

Usage

const options = defu (object, defaults)

Arguments

  • object (Object): The destination object.
  • source (Object): The source object.
const defu = require('defu')

console.log(defu({ 'a': { 'b': 2 } }, { 'a': { 'b': 1, 'c': 3 } }))
// => { a: { b: 2, c: 3 } }

Remarks

  • object and defaults are not modified

  • Assignment of __proto__ and constructor keys will be skipped to prevent security issues with object pollution.

License

MIT. Made with 💖

You can’t perform that action at this time.