src/tinier.js
function treeSet (address, tree, value) {
  if (address.length === 0) {
    return value
  } else {
    const [ k, rest ] = head(address)
    return (typeof k === 'string' ?
            { ...tree, [k]: treeSet(rest, treeGet([ k ], tree), value) } :
            [ ...tree.slice(0, k), treeSet(rest, treeGet([ k ], tree), value),
              ...tree.slice(k + 1) ])
  }
}
function treeSet (address, tree, value) {
  if (address.length === 0) {
    return value
  } else {
    const [ k, rest ] = head(address)
    return (typeof k === 'string' ?
            { ...tree, [k]: treeSet(rest, treeGet([ k ], tree), value) } :
            [ ...tree.slice(0, k), treeSet(rest, treeGet([ k ], tree), value),
              ...tree.slice(k + 1) ])
  }
}
function treeSet ( address , tree , value ) { if ( address . length === 0 ) { return value } else { const [ k , rest ] = head ( address ) return ( typeof k === 'string' ? { ... tree , [ k ] : treeSet ( rest , treeGet ( [ k ] , tree ) , value ) } : [ ... tree . slice ( 0 , k ) , treeSet ( rest , treeGet ( [ k ] , tree ) , value ) , ... tree . slice ( k + 1 ) ] ) } }
Set the value in a tree; immutable.
@param {Array} address -
@param {Object} tree -
@param {*} value - The new value to set at address.
@return (*) The new tree.
Set the value in a tree ; immutable .