Socket
Socket
Sign inDemoInstall

object-defaults

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    object-defaults

Like _.defaults, assigns properties of source objects to a target, without overriding existing ones.


Version published
Weekly downloads
223
decreased by-18.01%
Maintainers
1
Install size
3.40 kB
Created
Weekly downloads
 

Readme

Source

simulator npm travis

Like _.defaults, assigns properties of source objects to a target, without overriding existing ones.

Install

$ npm install --save object-defaults

Usage

var defaults = require('object-defaults')

// copies source to target
defaults({ foo: 0 }, { bar: 1 })
//=> { foo: 0, bar: 1 }

// multiple sources
defaults({ foo: 0 }, { bar: 1 }, { baz: 2 })
//=> { foo: 0, bar: 1, baz: 2 }

// does not override existing properties
defaults({ foo: 0 }, { foo: 1 }, { foo: 2 })
//=> { foo: 0 }

// ignores falsy sources
defaults({ foo: 0 }, null, '', { bar: 1 }, 0)
//=> { foo: 0, bar: 1 }

defaults(target, [source], [source, ...])

Assigns own enumerable properties of source objects to the target object and returns the target object. Existing properties are not overriden.

  • object-assign: Same thing but overrides existing properties.

License

MIT © Nicolas Gryman

Keywords

FAQs

Last updated on 23 Feb 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc