Code Duplication    Length = 23-26 lines in 2 locations

src/ub.arrays.core.js 2 locations

@@ 578-603 (lines=26) @@
575
	moveToBottom: function(slot, returnNew = false){
576
		var list = this;
577
578
		if (returnNew){
579
580
			// ALWAYS RETURNS NEW ARRAY
581
			
582
			// exit quickly if slot not in array
583
			var al = list.length;
584
			if (slot < 0 || slot >= al) {
585
				return list.concat();
586
			}
587
			
588
			// create new array with slot on top
589
			var newArr = [];
590
			var n = 0;
591
			
592
			// add all other slots
593
			for (var a = 0;a<al;a++){
594
				if (a != slot) {
595
					newArr[n++] = list[a];
596
				}
597
			}
598
			
599
			// add slot to bottom
600
			newArr[n++] = list[slot];
601
			return newArr;
602
603
		}
604
605
		// MODIFIES ARRAY IN PLACE
606
		
@@ 537-559 (lines=23) @@
534
	moveToTop: function(slot, returnNew = false){
535
		var list = this;
536
537
		if (returnNew){
538
539
			// ALWAYS RETURNS NEW ARRAY
540
			
541
			// exit quickly if slot not in array
542
			var al = list.length;
543
			if (slot < 0 || slot >= al) {
544
				return list.concat();
545
			}
546
			
547
			// create new array with slot on top
548
			var newArr = [list[slot]];
549
			var n = 1;
550
			
551
			// add all other slots
552
			for (var a = 0;a<al;a++){
553
				if (a != slot) {
554
					newArr[n++] = list[a];
555
				}
556
			}
557
558
			return newArr;
559
		}
560
561
562
		// MODIFIES ARRAY IN PLACE