@ndhoule/defaults

Copies owned, enumerable properties from a source object(s) to a target object when the value of that property on the source object is undefined.

defaults

Copies owned, enumerable properties from a source object(s) to a target object when the value of that property on the source object is undefined.

Installation

$ component install ndhoule/defaults
$ npm install @ndhoule/defaults

API

defaults(target : Object, sources : ...Object)=> Object

Copies owned, enumerable properties from a source object(s) to a target object when the value of that property on the source object is undefined.

var a = { a: 1 };
var b = { a: 2, b: 2 };

defaults(a, b);
console.log(a); //=> { a: 1, b: 2 }

defaults.deep(target : Object, sources : ...Object)=> Object

Deeply copies owned, enumerable properties from a source object(s), recursing on object properties, to a target object when the value of that property on the source object is undefined.

var a = { a: 1, b: { c: 3 } };
var b = { a: 2, b: { d: 4 } };

defaults(a, b);
console.log(a); //=> { a: 1, b: { c: 3, d: 4} }

License

Released under the MIT license.

HomePage

https://github.com/ndhoule/defaults

Repository

https://github.com/ndhoule/defaults.git


上一篇:@ndhoule/each
下一篇:@ndhoule/after

相关推荐

  • webpack-defaults

    Project configuration and boilerplate defaults for webpack projects npmnpmnpmurl node...

    2 年前
  • vue项目之配置本地,测试,生产环境,配置axios.defaults.baseURL,解决跨域问题

    最近在做一个vue项目,想通过不同的命令调用不同环境的api,防止来回手动修改api出错。网上看了好多写的都不全,然后自己突发奇想自己写一篇文章。 一、先简单说一下项目搭建 1、安装vue脚手架 ...

    1 年前
  • verb-defaults

    Plugin for setting basic defaults in verb projects. verbdefaults NPM version(https://img.shields.i...

    2 年前
  • superagent-defaults

    Create some defaults for superagent requests superagentdefaults Build Status(https://travisci.org/c...

    5 个月前
  • strong-url-defaults

    provide defaults for URLs strongurldefaults =================== Normalize URLs, providing defaults...

    2 年前
  • object.defaults

    Like but only copies missing properties/values to the target object. object.defaults NPM version(...

    2 年前
  • merge-defaults

    A recursive version of .defaults. Note: Lodash now includes a (https://lodash.com/docs/4.17.10defa...

    2 年前
  • lodash.defaultsdeep

    The Lodash method exported as a module. lodash.defaultsdeep v4.6.1 The Lodash(https://lodash.com...

    1 年前
  • lodash.defaults

    The lodash method exported as a module. lodash.defaults v4.2.0 The lodash(https://lodash.com/) m...

    2 年前
  • levelup-defaults

    Change the defaults settings on a levelup instance by returning a new levelup instance that uses the...

    1 年前

官方社区

扫码加入 JavaScript 社区