OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 class StringBase { | |
6 // TODO(jmesserly): this array copy is really unfortunate | |
7 // TODO(jmesserly): check the performance of String.fromCharCode.apply | |
8 // TODO(jmesserly): fix the generated JS name of factory ctors, | |
9 // they shouldn't be duplicating the name. | |
10 static String createFromCharCodes(List<int> charCodes) native @''' | |
11 if (Object.getPrototypeOf(charCodes) !== Array.prototype) { | |
12 charCodes = new ListFactory.ListFactory$from$factory(charCodes); | |
13 } | |
14 return String.fromCharCode.apply(null, charCodes); | |
15 ''' { | |
16 // we may need to iterate over charCodes | |
17 var i = charCodes.iterator(); i.next(); i.hasNext(); | |
18 new ListFactory.from(charCodes); // ensure List.from is generated | |
19 } | |
20 | |
21 static String join(List<String> strings, String separator) { | |
22 if (strings.length == 0) return ''; | |
23 String s = strings[0]; | |
24 for (int i = 1; i < strings.length; i++) { | |
25 s = s + separator + strings[i]; | |
26 } | |
27 return s; | |
28 } | |
29 | |
30 static String concatAll(List<String> strings) => join(strings, ""); | |
31 } | |
OLD | NEW |