Giter Club home page Giter Club logo

defaults-deep's Introduction

defaults-deep NPM version Build Status

Like extend but recursively copies only the missing properties/values to the target object.

Install

Install with npm

$ npm i defaults-deep --save

Install with bower

$ bower install defaults-deep --save

Usage

var defaults = require('defaults-deep');

defaults({a: {one: 'one'}}, {a: {two: 'two'}})
//=> {a: {one: 'one', two: 'two'}};

Related projects

  • assign-deep: Deeply assign the enumerable properties of source objects to a destination object. If a callback… more
  • extend-shallow: Extend an object with the properties of additional objects. node.js/javascript util.
  • merge-deep: Recursively merge values in a javascript object.
  • mixin-deep: Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone.
  • omit-deep: Recursively omit the given keys from an object.

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue

Author

Jon Schlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on May 28, 2015.

defaults-deep's People

Contributors

doowb avatar jonschlinkert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

defaults-deep's Issues

Custom validation callback

Hello,
If found this package pretty useful but the "missing" criteria doesn't match with my needs.
So I would propose (as a new feature) having a custom, optional, callback as the last parameter so the user can modify this at his will.

It could look something like this (3 lines change):

function defaultsDeep(target, objects, isMissing) {
  target = target || {};
  isMissing = isMissing || ((val) => val == null);
  [...]
      if (isMissing(val)) {
        target[key] = value;
      }
  [...]
}

Dependant Package "defaults-deep" is flagged as having a 'moderate' issue

Prior to publishing one of my applications today, ran into this warning today.

┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate      │ Prototype Pollution                                          │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ defaults-deep                                                │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Patched in    │ No patch available                                           │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ update                                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ update > base-cli-process > base-config-process >            │
│               │ base-config-schema > base-pkg > expand-pkg > defaults-deep   │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://nodesecurity.io/advisories/778                       │
└───────────────┴──────────────────────────────────────────────────────────────┘

don't change origin object

const a = {client: {}};
const b = {test:'test', client: { a: 'b'}};
const c = defaults({}, a, b);

// should not change a
assert(a.client.a === undefined);

Abandoned project?

Due to the lack of issues and PR's being responded to is has this project been abandoned?

Vulnerability Detected

Prototype Pollution
defaults-deep is vulnerable to prototype pollution. Properties of the Object prototype can be added or modified via JSON.parse, causing a denial of service condition or possibly remote code execution depending on the application.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.