OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * | 8 * |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 * @param {!Object.<string, function(string, ...):*>} formatters | 952 * @param {!Object.<string, function(string, ...):*>} formatters |
953 * @return {!Array.<!Object>} | 953 * @return {!Array.<!Object>} |
954 */ | 954 */ |
955 String.tokenizeFormatString = function(format, formatters) | 955 String.tokenizeFormatString = function(format, formatters) |
956 { | 956 { |
957 var tokens = []; | 957 var tokens = []; |
958 var substitutionIndex = 0; | 958 var substitutionIndex = 0; |
959 | 959 |
960 function addStringToken(str) | 960 function addStringToken(str) |
961 { | 961 { |
962 tokens.push({ type: "string", value: str }); | 962 if (tokens.length && tokens[tokens.length - 1].type === "string") |
| 963 tokens[tokens.length - 1].value += str; |
| 964 else |
| 965 tokens.push({ type: "string", value: str }); |
963 } | 966 } |
964 | 967 |
965 function addSpecifierToken(specifier, precision, substitutionIndex) | 968 function addSpecifierToken(specifier, precision, substitutionIndex) |
966 { | 969 { |
967 tokens.push({ type: "specifier", specifier: specifier, precision: precis
ion, substitutionIndex: substitutionIndex }); | 970 tokens.push({ type: "specifier", specifier: specifier, precision: precis
ion, substitutionIndex: substitutionIndex }); |
968 } | 971 } |
969 | 972 |
970 var index = 0; | 973 var index = 0; |
971 for (var precentIndex = format.indexOf("%", index); precentIndex !== -1; pre
centIndex = format.indexOf("%", index)) { | 974 for (var precentIndex = format.indexOf("%", index); precentIndex !== -1; pre
centIndex = format.indexOf("%", index)) { |
972 if (format.length === index) // unescaped % sign at the end of the form
at string. | 975 if (format.length === index) // unescaped % sign at the end of the form
at string. |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1489 * @param {T} defaultValue | 1492 * @param {T} defaultValue |
1490 * @return {!Promise.<T>} | 1493 * @return {!Promise.<T>} |
1491 * @template T | 1494 * @template T |
1492 */ | 1495 */ |
1493 Promise.prototype.catchException = function(defaultValue) { | 1496 Promise.prototype.catchException = function(defaultValue) { |
1494 return this.catch(function (error) { | 1497 return this.catch(function (error) { |
1495 console.error(error); | 1498 console.error(error); |
1496 return defaultValue; | 1499 return defaultValue; |
1497 }); | 1500 }); |
1498 } | 1501 } |
OLD | NEW |