@@ -571,78 +571,25 @@ namespace ts {
571
571
* @param copyOnWrite Indicates whether to return a fresh array rather than modify the
572
572
* existing array.
573
573
*/
574
- export function append < T > ( to : T [ ] | undefined , value : T | undefined , copyOnWrite ?: boolean ) : T [ ] | undefined {
574
+ export function append < T > ( to : T [ ] | undefined , value : T | undefined ) : T [ ] | undefined {
575
575
if ( value === undefined ) return to ;
576
576
if ( to === undefined ) return [ value ] ;
577
- if ( copyOnWrite ) return [ ...to , value ] ;
578
577
to . push ( value ) ;
579
578
return to ;
580
579
}
581
580
582
- /**
583
- * Prepends a value to an array, returning the array.
584
- *
585
- * @param to The array to which `value` is to be prepended. If `to` is `undefined`, a new array
586
- * is created if `value` was prepended.
587
- * @param value The value to prepend to the array. If `value` is `undefined`, nothing is
588
- * prepended.
589
- * @param copyOnWrite Indicates whether to return a fresh array rather than modify the
590
- * existing array.
591
- */
592
- export function prepend < T > ( to : T [ ] | undefined , value : T | undefined , copyOnWrite ?: boolean ) : T [ ] | undefined {
593
- if ( value === undefined ) return to ;
594
- if ( to === undefined ) return [ value ] ;
595
- if ( copyOnWrite ) return [ value , ...to ] ;
596
- to . unshift ( value ) ;
597
- return to ;
598
- }
599
-
600
581
/**
601
582
* Appends a range of value to an array, returning the array.
602
583
*
603
584
* @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array
604
585
* is created if `value` was appended.
605
586
* @param from The values to append to the array. If `from` is `undefined`, nothing is
606
587
* appended. If an element of `from` is `undefined`, that element is not appended.
607
- * @param copyOnWrite Indicates whether to return a fresh array rather than modify the
608
- * existing array.
609
588
*/
610
- export function addRange < T > ( to : T [ ] | undefined , from : T [ ] | undefined , copyOnWrite ?: boolean ) : T [ ] | undefined {
589
+ export function addRange < T > ( to : T [ ] | undefined , from : T [ ] | undefined ) : T [ ] | undefined {
611
590
if ( from === undefined ) return to ;
612
- from = filter ( from , isDefined ) ;
613
- if ( to === undefined ) return from ;
614
- if ( from . length > 0 ) {
615
- if ( copyOnWrite ) {
616
- return [ ...to , ...from ] ;
617
- }
618
- for ( const v of from ) {
619
- to . push ( v ) ;
620
- }
621
- }
622
- return to ;
623
- }
624
-
625
- /**
626
- * Appends a range of value to an array, returning the array.
627
- *
628
- * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array
629
- * is created if `value` was appended.
630
- * @param from The values to append to the array. If `from` is `undefined`, nothing is
631
- * appended. If an element of `from` is `undefined`, that element is not appended.
632
- * @param copyOnWrite Indicates whether to return a fresh array rather than modify the
633
- * existing array.
634
- */
635
- export function prependRange < T > ( to : T [ ] | undefined , from : T [ ] | undefined , copyOnWrite ?: boolean ) : T [ ] | undefined {
636
- if ( from === undefined ) return to ;
637
- from = filter ( from , isDefined ) ;
638
- if ( to === undefined ) return from ;
639
- if ( from . length > 0 ) {
640
- if ( copyOnWrite ) {
641
- return [ ...from , ...to ] ;
642
- }
643
- for ( let i = from . length - 1 ; i >= 0 ; i -- ) {
644
- to . unshift ( from [ i ] ) ;
645
- }
591
+ for ( const v of from ) {
592
+ to = append ( to , v ) ;
646
593
}
647
594
return to ;
648
595
}
0 commit comments