index.js
function deep_set(root, path, value) {
    var twig = root;
    path.split('/').forEach(function (branch, index, branches) {
        if (branch) {
            if (self.camelize) {
                branch = branch.replace(/(\-([a-z]))/g, function (m) { return m[1].toUpperCase(); })
            }
            if (index < branches.length - 1) {
                twig = twig[branch] || (twig[branch] = {});
            } else {
                // optimistically try treating the value as JSON
                try {
                    twig[branch] = JSON.parse(value);
                } catch (e) {
                    twig[branch] = value;
                }
            }
        }
    });
}
function deep_set(root, path, value) {
    var twig = root;
    path.split('/').forEach(function (branch, index, branches) {
        if (branch) {
            if (self.camelize) {
                branch = branch.replace(/(\-([a-z]))/g, function (m) { return m[1].toUpperCase(); })
            }
            if (index < branches.length - 1) {
                twig = twig[branch] || (twig[branch] = {});
            } else {
                // optimistically try treating the value as JSON
                try {
                    twig[branch] = JSON.parse(value);
                } catch (e) {
                    twig[branch] = value;
                }
            }
        }
    });
}
function deep_set ( root , path , value ) { var twig = root ; path . split ( '/' ) . forEach ( function ( branch , index , branches ) { if ( branch ) { if ( self . camelize ) { branch = branch . replace ( / (\-([a-z])) / g , function ( m ) { return m [ 1 ] . toUpperCase ( ) ; } ) } if ( index < branches . length - 1 ) { twig = twig [ branch ] || ( twig [ branch ] = { } ) ; } else { // optimistically try treating the value as JSON try { twig [ branch ] = JSON . parse ( value ) ; } catch ( e ) { twig [ branch ] = value ; } } } } ) ; }
helper to turn a set of paths into nested objects
helper to turn a set of paths into nested objects