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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 leadZero(this.getDate()) + "T" + | 367 leadZero(this.getDate()) + "T" + |
368 leadZero(this.getHours()) + | 368 leadZero(this.getHours()) + |
369 leadZero(this.getMinutes()) + | 369 leadZero(this.getMinutes()) + |
370 leadZero(this.getSeconds()); | 370 leadZero(this.getSeconds()); |
371 } | 371 } |
372 | 372 |
373 Object.defineProperty(Array.prototype, "remove", | 373 Object.defineProperty(Array.prototype, "remove", |
374 { | 374 { |
375 /** | 375 /** |
376 * @param {!T} value | 376 * @param {!T} value |
377 * @param {boolean=} onlyFirst | 377 * @param {boolean=} firstOnly |
378 * @this {Array.<!T>} | 378 * @this {Array.<!T>} |
379 * @template T | 379 * @template T |
380 */ | 380 */ |
381 value: function(value, onlyFirst) | 381 value: function(value, firstOnly) |
382 { | 382 { |
383 if (onlyFirst) { | 383 if (firstOnly) { |
384 var index = this.indexOf(value); | 384 var index = this.indexOf(value); |
385 if (index !== -1) | 385 if (index !== -1) |
386 this.splice(index, 1); | 386 this.splice(index, 1); |
387 return; | 387 return; |
388 } | 388 } |
389 | 389 |
390 var length = this.length; | 390 for (var pos = this.indexOf(value); pos !== -1; pos = this.indexOf(value , pos + 1)) { |
391 for (var i = 0; i < length; ++i) { | 391 for (var end = pos + 1; end < this.length && this[end] === value; ++ end) {} |
392 if (this[i] === value) | 392 this.splice(pos, end - pos); |
aandrey
2014/03/25 12:04:23
not lgtm.
this is too complex, I think this does n
| |
393 this.splice(i, 1); | |
394 } | 393 } |
395 } | 394 } |
396 }); | 395 }); |
397 | 396 |
398 Object.defineProperty(Array.prototype, "keySet", | 397 Object.defineProperty(Array.prototype, "keySet", |
399 { | 398 { |
400 /** | 399 /** |
401 * @return {!Object.<string, boolean>} | 400 * @return {!Object.<string, boolean>} |
402 * @this {Array.<*>} | 401 * @this {Array.<*>} |
403 */ | 402 */ |
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1528 this._outgoingCallback(); | 1527 this._outgoingCallback(); |
1529 } | 1528 } |
1530 } | 1529 } |
1531 | 1530 |
1532 /** | 1531 /** |
1533 * @param {*} value | 1532 * @param {*} value |
1534 */ | 1533 */ |
1535 function suppressUnused(value) | 1534 function suppressUnused(value) |
1536 { | 1535 { |
1537 } | 1536 } |
OLD | NEW |