src/index.js
function _removeWishIdFromEnteredMagicWords(id) {
  function removeIdFromWishes(charObj, parent, charObjName) {
    _each(charObj, (childProp, propName) => {
      if (propName === 'wishes') {
        const index = childProp.indexOf(id)
        if (index !== -1) {
          childProp.splice(index, 1)
        }
        if (!childProp.length) {
          delete charObj[propName]
        }
      } else {
        removeIdFromWishes(childProp, charObj, propName)
      }
    })
    const keepCharObj = _getPropFromPosterity(charObj, 'wishes').length > 0
    if (!keepCharObj && parent && charObjName) {
      delete parent[charObjName]
    }
  }
  removeIdFromWishes(_enteredMagicWords)
}
function _removeWishIdFromEnteredMagicWords(id) {
  function removeIdFromWishes(charObj, parent, charObjName) {
    _each(charObj, (childProp, propName) => {
      if (propName === 'wishes') {
        const index = childProp.indexOf(id)
        if (index !== -1) {
          childProp.splice(index, 1)
        }
        if (!childProp.length) {
          delete charObj[propName]
        }
      } else {
        removeIdFromWishes(childProp, charObj, propName)
      }
    })
    const keepCharObj = _getPropFromPosterity(charObj, 'wishes').length > 0
    if (!keepCharObj && parent && charObjName) {
      delete parent[charObjName]
    }
  }
  removeIdFromWishes(_enteredMagicWords)
}
function _removeWishIdFromEnteredMagicWords ( id ) { function removeIdFromWishes ( charObj , parent , charObjName ) { _each ( charObj , ( childProp , propName ) => { if ( propName === 'wishes' ) { const index = childProp . indexOf ( id ) if ( index !== - 1 ) { childProp . splice ( index , 1 ) } if ( ! childProp . length ) { delete charObj [ propName ] } } else { removeIdFromWishes ( childProp , charObj , propName ) } } ) const keepCharObj = _getPropFromPosterity ( charObj , 'wishes' ) . length > 0 if ( ! keepCharObj && parent && charObjName ) { delete parent [ charObjName ] } } removeIdFromWishes ( _enteredMagicWords ) }
Iterates through _enteredMagicWords and removes
all instances of this id. If this leaves the letter
empty it removes the letter.
@param {string} id
@private
Iterates through _enteredMagicWords and removes all instances of this id . If this leaves the letter empty it removes the letter .