lib/tools/keypath.js
function _set(obj, keypath, value) {
    var parts = _keyPathNormalize(keypath).split('.')
    var last = parts.pop()
    var dest = obj
    var hasError
    var errorInfo
    util.some(parts, function(key) {
        var t = util.type(dest)
        if (t != 'object' && t != 'array') {
            hasError = true
            errorInfo = [key, dest]
            return true
        }
        dest = dest[key]
    })
    // set value
    if (!hasError) {
        if (util.type(dest) != 'object' && util.type(dest) != 'array') {
            hasError = true
            errorInfo = [last, dest]
        } else {
            dest[last] = value
            return obj
        }
    }
    throw new Error('Can\' not access "' + errorInfo[0] + '" of "'+ errorInfo[1] + '" when set value of "' + keypath + '"')
}
function _set(obj, keypath, value) {
    var parts = _keyPathNormalize(keypath).split('.')
    var last = parts.pop()
    var dest = obj
    var hasError
    var errorInfo
    util.some(parts, function(key) {
        var t = util.type(dest)
        if (t != 'object' && t != 'array') {
            hasError = true
            errorInfo = [key, dest]
            return true
        }
        dest = dest[key]
    })
    // set value
    if (!hasError) {
        if (util.type(dest) != 'object' && util.type(dest) != 'array') {
            hasError = true
            errorInfo = [last, dest]
        } else {
            dest[last] = value
            return obj
        }
    }
    throw new Error('Can\' not access "' + errorInfo[0] + '" of "'+ errorInfo[1] + '" when set value of "' + keypath + '"')
}
function _set ( obj , keypath , value ) { var parts = _keyPathNormalize ( keypath ) . split ( '.' ) var last = parts . pop ( ) var dest = obj var hasError var errorInfo util . some ( parts , function ( key ) { var t = util . type ( dest ) if ( t != 'object' && t != 'array' ) { hasError = true errorInfo = [ key , dest ] return true } dest = dest [ key ] } ) // set value if ( ! hasError ) { if ( util . type ( dest ) != 'object' && util . type ( dest ) != 'array' ) { hasError = true errorInfo = [ last , dest ] } else { dest [ last ] = value return obj } } throw new Error ( 'Can\' not access "' + errorInfo [ 0 ] + '" of "' + errorInfo [ 1 ] + '" when set value of "' + keypath + '"' ) }
set value to object by keypath
set value to object by keypath