Code Duplication    Length = 11-24 lines in 3 locations

src/ub.numbers.js 3 locations

@@ 801-824 (lines=24) @@
798
		var input = this;
799
		return parseFloat(input.toString().substr(0, digits));
800
	},
801
	limit: function(min, max){
802
		var input = this;
803
		
804
		// ensure ok
805
		if (input != input) { /// fast isNaN check
806
			return min;
807
		}
808
		
809
		// flip limits if in reverse order
810
		if (min > max) {
811
			var temp = max;
812
			max = min;
813
			min = temp;
814
		}
815
		
816
		// ensure within limits
817
		if (input < min) {
818
			return min;
819
		}
820
		if (input > max) {
821
			return max;
822
		}
823
		return input;
824
	},
825
	limitToArray: function(array, extraMax = 0, extraMin = 0){
826
		var pointer = this;
827
		if (pointer <= -extraMin) {
@@ 849-868 (lines=20) @@
846
		}
847
		return min + (value % diff);
848
	},
849
	wrap2: function(min, max){
850
		var input = this;
851
		
852
		// flip limits if in reverse order
853
		if (min > max) {
854
			var temp = max;
855
			max = min;
856
			min = temp;
857
		}
858
		
859
		// ensure wrapped to limits
860
		var diff = (max - min) + 1;
861
		while (input < min) {
862
			input += diff;
863
		}
864
		while (input > max) {
865
			input -= diff;
866
		}
867
		return input;
868
	},
869
	wrapToMax: function(max){
870
		var value = this;
871
		var diff = max + 1;
@@ 266-276 (lines=11) @@
263
		var val = this;
264
		return (val < 0);
265
	},
266
	relativeTo: function(v2, type){
267
		var v1 = this;
268
		// type .. 0=any, 1=pos, 2=neg
269
		var v = v2 - v1;
270
		if (type == 1) {
271
			return v > 0 ? v : -v;
272
		}else if (type == 2) {
273
			return v > 0 ? -v : v;
274
		}
275
		return v;
276
	},
277
	abs: function(negative = false){
278
		var v = this;
279
		if (negative){