1.1.4 • Published 7 years ago

js-utils-deep v1.1.4

Weekly downloads
1,434
License
MIT
Repository
github
Last release
7 years ago

JavaScript Deep Utility Functions

recursiveOmit (deepObject)

Recursively omits the null, '', undefined values from the object. Checks all levels deep to remove the keys associated.

let deepObject = {
  x: {
    y: {
      z: ''  
    }
    a: {
      b: null,
      c: undefined
    }
    d: null
  }
};
recursiveOmit(deepObject) // returns {}

deepExtend (object1, object2)

Deeply extend object1 with object2 where object1 will be target and object2 will be source.

let object1 = {
  x: {
    y: {
      z: ''  
    }
    a: {
      b: null,
      c: undefined
    }
  }
};

let object 2 = {
  x: {
    y: {
      z: 'z',
    }
    a: {
      b: 'b',
      c: 'c'
    }
    d: 'd'
  }
};

deepExtend(object1, object2)
/* returns {
  x: {
    y: {
      z: 'z',
    }
    a: {
      b: 'b',
      c: 'c'
    }
    d: 'd'
  }
}; */

diffObject(object1, object2)

Compares object1 with object2 and returns the different key value pairs.

eg: let object1 = {
  x: 'a',
  y: 'b'
};

let object 2 = {
  x: 'a',
  z: 'c',
};

diffObject(object1, object2) 
/* returns {
  y: 'b',
  z: 'c'
}; */

Resources

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago