Skip to content

Commit a0a627f

Browse files
committed
refactor(StringWrapper): remove useless methods
Closes angular#5039
1 parent c5693f0 commit a0a627f

19 files changed

Lines changed: 33 additions & 110 deletions

File tree

modules/angular1_router/karma-router.conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = function (config) {
99
frameworks: ['jasmine'],
1010

1111
files: [
12+
'../../node_modules/es6-shim/es6-shim.js',
1213
'../../node_modules/angular/angular.js',
1314
'../../node_modules/angular-animate/angular-animate.js',
1415
'../../node_modules/angular-mocks/angular-mocks.js',

modules/angular1_router/lib/facades.es5

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,10 @@ var StringWrapper = {
247247
return s.split(re);
248248
},
249249

250-
substring: function(s, start, end) {
251-
return s.substr(start, end);
252-
},
253-
254250
replaceAll: function(s, from, replace) {
255251
return s.replace(from, replace);
256252
},
257253

258-
startsWith: function(s, start) {
259-
return s.substr(0, start.length) === start;
260-
},
261-
262254
replaceAllMapped: function(s, from, cb) {
263255
return s.replace(from, function(matches) {
264256
// Remove offset & string from the result array

modules/angular2/src/common/pipes/lowercase_pipe.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {isString, StringWrapper, CONST, isBlank} from 'angular2/src/core/facade/lang';
1+
import {isString, CONST, isBlank} from 'angular2/src/core/facade/lang';
22
import {Injectable} from 'angular2/src/core/di';
33
import {PipeTransform, WrappedValue} from 'angular2/src/core/change_detection';
44
import {Pipe} from 'angular2/src/core/metadata';
@@ -32,6 +32,6 @@ export class LowerCasePipe implements PipeTransform {
3232
if (!isString(value)) {
3333
throw new InvalidPipeArgumentException(LowerCasePipe, value);
3434
}
35-
return StringWrapper.toLowerCase(value);
35+
return value.toLowerCase();
3636
}
3737
}

modules/angular2/src/common/pipes/uppercase_pipe.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {isString, StringWrapper, CONST, isBlank} from 'angular2/src/core/facade/lang';
1+
import {isString, CONST, isBlank} from 'angular2/src/core/facade/lang';
22
import {Pipe} from 'angular2/src/core/metadata';
33
import {Injectable} from 'angular2/src/core/di';
44
import {PipeTransform, WrappedValue} from 'angular2/src/core/change_detection';
@@ -31,6 +31,6 @@ export class UpperCasePipe implements PipeTransform {
3131
if (!isString(value)) {
3232
throw new InvalidPipeArgumentException(UpperCasePipe, value);
3333
}
34-
return StringWrapper.toUpperCase(value);
34+
return value.toUpperCase();
3535
}
3636
}

modules/angular2/src/compiler/template_parser.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,8 @@ class TemplateParseVisitor implements HtmlAstVisitor {
254254
var templateBindingsSource = null;
255255
if (attr.name == TEMPLATE_ATTR) {
256256
templateBindingsSource = attr.value;
257-
} else if (StringWrapper.startsWith(attr.name, TEMPLATE_ATTR_PREFIX)) {
258-
var key = StringWrapper.substring(attr.name, TEMPLATE_ATTR_PREFIX.length); // remove the star
257+
} else if (attr.name.startsWith(TEMPLATE_ATTR_PREFIX)) {
258+
var key = attr.name.substring(TEMPLATE_ATTR_PREFIX.length); // remove the star
259259
templateBindingsSource = (attr.value.length == 0) ? key : key + ' ' + attr.value;
260260
}
261261
if (isPresent(templateBindingsSource)) {
@@ -333,8 +333,7 @@ class TemplateParseVisitor implements HtmlAstVisitor {
333333
}
334334

335335
private _normalizeAttributeName(attrName: string): string {
336-
return StringWrapper.startsWith(attrName, 'data-') ? StringWrapper.substring(attrName, 5) :
337-
attrName;
336+
return attrName.startsWith('data-') ? attrName.substring(5) : attrName;
338337
}
339338

340339
private _parseVariable(identifier: string, value: string, sourceInfo: any,

modules/angular2/src/core/dom/generic_browser_adapter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {ListWrapper, StringMapWrapper} from 'angular2/src/core/facade/collection';
2-
import {isPresent, isFunction, StringWrapper, Type} from 'angular2/src/core/facade/lang';
2+
import {isPresent, isFunction, Type} from 'angular2/src/core/facade/lang';
33
import {DomAdapter} from './dom_adapter';
44
import {XHRImpl} from 'angular2/src/compiler/xhr_impl';
55

@@ -20,7 +20,7 @@ export abstract class GenericBrowserDomAdapter extends DomAdapter {
2020
var domPrefixes = ['Webkit', 'Moz', 'O', 'ms'];
2121
for (var i = 0; i < domPrefixes.length; i++) {
2222
if (isPresent(this.getStyle(element, domPrefixes[i] + 'AnimationName'))) {
23-
this._animationPrefix = '-' + StringWrapper.toLowerCase(domPrefixes[i]) + '-';
23+
this._animationPrefix = '-' + domPrefixes[i].toLowerCase() + '-';
2424
break;
2525
}
2626
}

modules/angular2/src/core/facade/lang.dart

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,6 @@ class StringWrapper {
8080
return s.replaceAll(from, replace);
8181
}
8282

83-
static String toUpperCase(String s) {
84-
return s.toUpperCase();
85-
}
86-
87-
static String toLowerCase(String s) {
88-
return s.toLowerCase();
89-
}
90-
91-
static startsWith(String s, String start) {
92-
return s.startsWith(start);
93-
}
94-
9583
static String slice(String s, [int start = 0, int end]) {
9684
start = _startOffset(s, start);
9785
end = _endOffset(s, end);
@@ -102,10 +90,6 @@ class StringWrapper {
10290
return s.substring(start, end);
10391
}
10492

105-
static String substring(String s, int start, [int end]) {
106-
return s.substring(start, end);
107-
}
108-
10993
static String replaceAllMapped(String s, RegExp from, Function cb) {
11094
return s.replaceAllMapped(from, cb);
11195
}

modules/angular2/src/core/facade/lang.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,6 @@ export class StringWrapper {
176176
return s.slice(from, to === null ? undefined : to);
177177
}
178178

179-
static toUpperCase(s: string): string { return s.toUpperCase(); }
180-
181-
static toLowerCase(s: string): string { return s.toLowerCase(); }
182-
183-
static startsWith(s: string, start: string): boolean { return s.startsWith(start); }
184-
185-
static substring(s: string, start: number, end: number = null): string {
186-
return s.substring(start, end === null ? undefined : end);
187-
}
188-
189179
static replaceAllMapped(s: string, from: RegExp, cb: Function): string {
190180
return s.replace(from, function(...matches) {
191181
// Remove offset & string from the result array

modules/angular2/src/core/linker/event_config.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import {StringWrapper} from 'angular2/src/core/facade/lang';
21
export const EVENT_TARGET_SEPARATOR = ':';
32

43
export class EventConfig {
@@ -9,8 +8,8 @@ export class EventConfig {
98
var separatorIdx = eventConfig.indexOf(EVENT_TARGET_SEPARATOR);
109
if (separatorIdx > -1) {
1110
// long format: 'fieldName: eventName'
12-
fieldName = StringWrapper.substring(eventConfig, 0, separatorIdx).trim();
13-
eventName = StringWrapper.substring(eventConfig, separatorIdx + 1).trim();
11+
fieldName = eventConfig.substring(0, separatorIdx).trim();
12+
eventName = eventConfig.substring(separatorIdx + 1).trim();
1413
isLongForm = true;
1514
}
1615
return new EventConfig(fieldName, eventName, isLongForm);

modules/angular2/src/core/metadata/di.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
CONST,
3-
Type,
4-
stringify,
5-
isPresent,
6-
StringWrapper,
7-
isString
8-
} from 'angular2/src/core/facade/lang';
1+
import {CONST, Type, stringify, isPresent, isString} from 'angular2/src/core/facade/lang';
92
import {resolveForwardRef} from 'angular2/src/core/di';
103
import {DependencyMetadata} from 'angular2/src/core/di/metadata';
114

@@ -192,7 +185,7 @@ export class QueryMetadata extends DependencyMetadata {
192185
* returns a list of variable bindings this is querying for.
193186
* Only applicable if this is a variable bindings query.
194187
*/
195-
get varBindings(): string[] { return StringWrapper.split(this.selector, new RegExp(",")); }
188+
get varBindings(): string[] { return this.selector.split(','); }
196189

197190
toString(): string { return `@Query(${stringify(this.selector)})`; }
198191
}

0 commit comments

Comments
 (0)