| 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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 String.prototype.escapeForRegExp = function() | 160 String.prototype.escapeForRegExp = function() |
| 161 { | 161 { |
| 162 return this.escapeCharacters(String.regexSpecialCharacters()); | 162 return this.escapeCharacters(String.regexSpecialCharacters()); |
| 163 } | 163 } |
| 164 | 164 |
| 165 /** | 165 /** |
| 166 * @return {string} | 166 * @return {string} |
| 167 */ | 167 */ |
| 168 String.prototype.escapeHTML = function() | 168 String.prototype.escapeHTML = function() |
| 169 { | 169 { |
| 170 return this.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">
").replace(/"/g, """); //" doublequotes just for editor | 170 return this.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">
").replace(/"/g, """); // " doublequotes just for editor |
| 171 } | 171 } |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * @return {string} | 174 * @return {string} |
| 175 */ | 175 */ |
| 176 String.prototype.unescapeHTML = function() | 176 String.prototype.unescapeHTML = function() |
| 177 { | 177 { |
| 178 return this.replace(/</g, "<") | 178 return this.replace(/</g, "<") |
| 179 .replace(/>/g, ">") | 179 .replace(/>/g, ">") |
| 180 .replace(/:/g, ":") | 180 .replace(/:/g, ":") |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 var z = 0x5033d967; // 32 bits from random.org | 277 var z = 0x5033d967; // 32 bits from random.org |
| 278 var z2 = 0x59d2f15d; // random odd 32 bit number | 278 var z2 = 0x59d2f15d; // random odd 32 bit number |
| 279 var s = 0; | 279 var s = 0; |
| 280 var zi = 1; | 280 var zi = 1; |
| 281 for (var i = 0; i < string.length; i++) { | 281 for (var i = 0; i < string.length; i++) { |
| 282 var xi = string.charCodeAt(i) * z2; | 282 var xi = string.charCodeAt(i) * z2; |
| 283 s = (s + zi * xi) % p; | 283 s = (s + zi * xi) % p; |
| 284 zi = (zi * z) % p; | 284 zi = (zi * z) % p; |
| 285 } | 285 } |
| 286 s = (s + zi * (p - 1)) % p; | 286 s = (s + zi * (p - 1)) % p; |
| 287 return Math.abs(s|0); | 287 return Math.abs(s | 0); |
| 288 } | 288 } |
| 289 | 289 |
| 290 /** | 290 /** |
| 291 * @param {string} string | 291 * @param {string} string |
| 292 * @param {number} index | 292 * @param {number} index |
| 293 * @return {boolean} | 293 * @return {boolean} |
| 294 */ | 294 */ |
| 295 String.isDigitAt = function(string, index) | 295 String.isDigitAt = function(string, index) |
| 296 { | 296 { |
| 297 var c = string.charCodeAt(index); | 297 var c = string.charCodeAt(index); |
| 298 return 48 <= c && c <= 57; | 298 return (48 <= c && c <= 57); |
| 299 } | 299 } |
| 300 | 300 |
| 301 /** | 301 /** |
| 302 * @return {string} | 302 * @return {string} |
| 303 */ | 303 */ |
| 304 String.prototype.toBase64 = function() | 304 String.prototype.toBase64 = function() |
| 305 { | 305 { |
| 306 /** | 306 /** |
| 307 * @param {number} b | 307 * @param {number} b |
| 308 * @return {number} | 308 * @return {number} |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 * @return {!Array.<T>} | 922 * @return {!Array.<T>} |
| 923 * @this {!Array.<T>} | 923 * @this {!Array.<T>} |
| 924 * @template T | 924 * @template T |
| 925 */ | 925 */ |
| 926 value: function(array, comparator) | 926 value: function(array, comparator) |
| 927 { | 927 { |
| 928 return mergeOrIntersect(this, array, comparator, true); | 928 return mergeOrIntersect(this, array, comparator, true); |
| 929 } | 929 } |
| 930 }); | 930 }); |
| 931 | 931 |
| 932 }()); | 932 })(); |
| 933 | 933 |
| 934 /** | 934 /** |
| 935 * @param {string} format | 935 * @param {string} format |
| 936 * @param {...*} var_arg | 936 * @param {...*} var_arg |
| 937 * @return {string} | 937 * @return {string} |
| 938 */ | 938 */ |
| 939 String.sprintf = function(format, var_arg) | 939 String.sprintf = function(format, var_arg) |
| 940 { | 940 { |
| 941 return String.vsprintf(format, Array.prototype.slice.call(arguments, 1)); | 941 return String.vsprintf(format, Array.prototype.slice.call(arguments, 1)); |
| 942 } | 942 } |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1531 return callback.apply(null, arg); | 1531 return callback.apply(null, arg); |
| 1532 } | 1532 } |
| 1533 } | 1533 } |
| 1534 | 1534 |
| 1535 /** | 1535 /** |
| 1536 * @param {T} defaultValue | 1536 * @param {T} defaultValue |
| 1537 * @return {!Promise.<T>} | 1537 * @return {!Promise.<T>} |
| 1538 * @template T | 1538 * @template T |
| 1539 */ | 1539 */ |
| 1540 Promise.prototype.catchException = function(defaultValue) { | 1540 Promise.prototype.catchException = function(defaultValue) { |
| 1541 return this.catch(function (error) { | 1541 return this.catch(function(error) { |
| 1542 console.error(error); | 1542 console.error(error); |
| 1543 return defaultValue; | 1543 return defaultValue; |
| 1544 }); | 1544 }); |
| 1545 } | 1545 } |
| OLD | NEW |