@@ -2513,102 +2513,6 @@ util.makeLink = function(path, query, fragment) {
2513
2513
( ( fragment . length > 0 ) ? ( '#' + fragment ) : '' ) ;
2514
2514
} ;
2515
2515
2516
- /**
2517
- * Follows a path of keys deep into an object hierarchy and set a value.
2518
- * If a key does not exist or it's value is not an object, create an
2519
- * object in it's place. This can be destructive to a object tree if
2520
- * leaf nodes are given as non-final path keys.
2521
- * Used to avoid exceptions from missing parts of the path.
2522
- *
2523
- * SECURITY NOTE: Do not use unsafe inputs. Doing so could expose a prototype
2524
- * pollution security issue.
2525
- *
2526
- * @param object the starting object.
2527
- * @param keys an array of string keys.
2528
- * @param value the value to set.
2529
- */
2530
- util . setPath = function ( object , keys , value ) {
2531
- // need to start at an object
2532
- if ( typeof ( object ) === 'object' && object !== null ) {
2533
- var i = 0 ;
2534
- var len = keys . length ;
2535
- while ( i < len ) {
2536
- var next = keys [ i ++ ] ;
2537
- if ( i == len ) {
2538
- // last
2539
- object [ next ] = value ;
2540
- } else {
2541
- // more
2542
- var hasNext = ( next in object ) ;
2543
- if ( ! hasNext ||
2544
- ( hasNext && typeof ( object [ next ] ) !== 'object' ) ||
2545
- ( hasNext && object [ next ] === null ) ) {
2546
- object [ next ] = { } ;
2547
- }
2548
- object = object [ next ] ;
2549
- }
2550
- }
2551
- }
2552
- } ;
2553
-
2554
- /**
2555
- * Follows a path of keys deep into an object hierarchy and return a value.
2556
- * If a key does not exist, create an object in it's place.
2557
- * Used to avoid exceptions from missing parts of the path.
2558
- *
2559
- * @param object the starting object.
2560
- * @param keys an array of string keys.
2561
- * @param _default value to return if path not found.
2562
- *
2563
- * @return the value at the path if found, else default if given, else
2564
- * undefined.
2565
- */
2566
- util . getPath = function ( object , keys , _default ) {
2567
- var i = 0 ;
2568
- var len = keys . length ;
2569
- var hasNext = true ;
2570
- while ( hasNext && i < len &&
2571
- typeof ( object ) === 'object' && object !== null ) {
2572
- var next = keys [ i ++ ] ;
2573
- hasNext = next in object ;
2574
- if ( hasNext ) {
2575
- object = object [ next ] ;
2576
- }
2577
- }
2578
- return ( hasNext ? object : _default ) ;
2579
- } ;
2580
-
2581
- /**
2582
- * Follow a path of keys deep into an object hierarchy and delete the
2583
- * last one. If a key does not exist, do nothing.
2584
- * Used to avoid exceptions from missing parts of the path.
2585
- *
2586
- * @param object the starting object.
2587
- * @param keys an array of string keys.
2588
- */
2589
- util . deletePath = function ( object , keys ) {
2590
- // need to start at an object
2591
- if ( typeof ( object ) === 'object' && object !== null ) {
2592
- var i = 0 ;
2593
- var len = keys . length ;
2594
- while ( i < len ) {
2595
- var next = keys [ i ++ ] ;
2596
- if ( i == len ) {
2597
- // last
2598
- delete object [ next ] ;
2599
- } else {
2600
- // more
2601
- if ( ! ( next in object ) ||
2602
- ( typeof ( object [ next ] ) !== 'object' ) ||
2603
- ( object [ next ] === null ) ) {
2604
- break ;
2605
- }
2606
- object = object [ next ] ;
2607
- }
2608
- }
2609
- }
2610
- } ;
2611
-
2612
2516
/**
2613
2517
* Check if an object is empty.
2614
2518
*
0 commit comments