chai-exclude.js
function removeKeysFromObject (obj, props, recursive = false) {
    const res = {}
    const keys = Object.keys(obj)
    const isRecursive = !!recursive

    for (let i = 0; i < keys.length; i++) {
      const key = keys[i]
      const val = obj[key]

      const hasKey = props.indexOf(key) === -1

      if (isRecursive && hasKey && isObject(val)) {
        res[key] = removeKeysFromObject(val, props, true)
      } else if (isRecursive && hasKey && isArray(val)) {
        res[key] = removeKeysFromArray(val, props, true)
      } else if (hasKey) {
        res[key] = val
      }
    }

    return res
  }
function removeKeysFromObject (obj, props, recursive = false) {
    const res = {}
    const keys = Object.keys(obj)
    const isRecursive = !!recursive

    for (let i = 0; i < keys.length; i++) {
      const key = keys[i]
      const val = obj[key]

      const hasKey = props.indexOf(key) === -1

      if (isRecursive && hasKey && isObject(val)) {
        res[key] = removeKeysFromObject(val, props, true)
      } else if (isRecursive && hasKey && isArray(val)) {
        res[key] = removeKeysFromArray(val, props, true)
      } else if (hasKey) {
        res[key] = val
      }
    }

    return res
  }
function removeKeysFromObject ( obj , props , recursive = false ) { const res = { } const keys = Object . keys ( obj ) const isRecursive = ! ! recursive for ( let i = 0 ; i < keys . length ; i ++ ) { const key = keys [ i ] const val = obj [ key ] const hasKey = props . indexOf ( key ) === - 1 if ( isRecursive && hasKey && isObject ( val ) ) { res [ key ] = removeKeysFromObject ( val , props , true ) } else if ( isRecursive && hasKey && isArray ( val ) ) { res [ key ] = removeKeysFromArray ( val , props , true ) } else if ( hasKey ) { res [ key ] = val } } return res }
Remove keys from an object and return a new object.

@param   {Object}  obj       object to remove keys
@param   {Array}   props     array of keys to remove
@param   {Boolean} recursive true if property needs to be removed recursively
@returns {Object}
Remove keys from an object and return a new object .