Code Duplication    Length = 16-30 lines in 2 locations

src/ub.strings.charrange.js 2 locations

@@ 110-139 (lines=30) @@
107
		// check if ends with char of type
108
		return str.charAt(str.length - 1).isOfCharRange(type);
109
	},
110
	indexOfCharRange: function(type, startAt = null, forwards = true){
111
		var str = this;
112
		
113
		// exit quickly if blank string
114
		if (str == null || str.length == 0) {
115
			return -1;
116
		}
117
		
118
		// find char of type
119
		if (forwards) {
120
			if (startAt == null) {
121
				startAt = 0;
122
			}
123
			for (var c = startAt, cl = str.length;c<cl;c++){
124
				if (str.charAt(c).isOfCharRange(type)) {
125
					return c;
126
				}
127
			}
128
		}else {
129
			if (startAt == null) {
130
				startAt = str.length - 1;
131
			}
132
			for (var c = startAt;c >= 0;c--){
133
				if (str.charAt(c).isOfCharRange(type)) {
134
					return c;
135
				}
136
			}
137
		}
138
		return -1;
139
	},
140
	lastIndexOfCharRange: function(type){
141
		var str = this;
142
		return str.indexOfCharRange(type, null, false);
@@ 56-71 (lines=16) @@
53
		}
54
		return true;
55
	},
56
	isAllOfCharRange2: function(type1, type2, ifNoChars = false){
57
		var str = this;
58
		
59
		// exit quickly if blank string
60
		if (str == null || str.length == 0) {
61
			return ifNoChars;
62
		}
63
		
64
		// find char of type
65
		for (var c = 0, cl = str.length;c<cl;c++){
66
			if (!(str.charAt(c).isOfCharRange(type1) || str.charAt(c).isOfCharRange(type2))) {
67
				return false;
68
			}
69
		}
70
		return true;
71
	},
72
	containsCharRange: function(type, startAt = 0, ifNoChars = false){
73
		var str = this;
74