JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16508
  • Score
    100M100P100Q133836F
  • License MIT

Copies missing properties to the target object.

Package Exports

  • defaulty

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (defaulty) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

defaulty

Copies deep missing properties to the target object.

Installation

Node.js

npm install defaulty --save

Example

const defaulty = require('defaulty');

const defaultObj = {a: 1, b: 2, c: 3, d: {a: 5, b: 2}};
let targetObj = {a: 4, b: 5, d: {a: 1}};

defaulty(targetObj, defaultObj);

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

Exclude default properties

const defaultObj = {a: 1, b: 2, c: 3, d: {a: 5, b: 2}, x: 1, y: 2};
let targetObj = {a: 4, b: 5, d: {a: 1}};

defaulty(targetObj, defaultObj, ['x', 'y']);

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

Copy target object

const defaultObj = {a: 1, b: 2, c: 3, d: {a: 5, b: 2}};
const targetObj = {a: 4, b: 5, d: {a: 1}};

const newTargetObject = defaulty.copy(targetObj, defaultObj);

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

Changelog

You can view the changelog here

License

Defaulty is open-sourced software licensed under the MIT license

Author

Fabio Ricali