@@ -571,78 +571,25 @@ namespace ts {
571571 * @param copyOnWrite Indicates whether to return a fresh array rather than modify the
572572 * existing array.
573573 */
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 {
575575 if ( value === undefined ) return to ;
576576 if ( to === undefined ) return [ value ] ;
577- if ( copyOnWrite ) return [ ...to , value ] ;
578577 to . push ( value ) ;
579578 return to ;
580579 }
581580
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-
600581 /**
601582 * Appends a range of value to an array, returning the array.
602583 *
603584 * @param to The array to which `value` is to be appended. If `to` is `undefined`, a new array
604585 * is created if `value` was appended.
605586 * @param from The values to append to the array. If `from` is `undefined`, nothing is
606587 * 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.
609588 */
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 {
611590 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 ) ;
646593 }
647594 return to ;
648595 }
0 commit comments