Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/compat.js

Issue 29366747: Issue 4657 - Add Acceptable Ads API (Closed)
Left Patch Set: Created Dec. 2, 2016, 4:27 p.m.
Right Patch Set: fix typo Created April 5, 2017, 4:53 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « lib/api.js ('k') | src/FilterEngine.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 notificationCallbacks: {}, 436 notificationCallbacks: {},
437 loadFlags: 0, 437 loadFlags: 0,
438 INHIBIT_CACHING: 0, 438 INHIBIT_CACHING: 0,
439 VALIDATE_ALWAYS: 0, 439 VALIDATE_ALWAYS: 0,
440 QueryInterface: function() 440 QueryInterface: function()
441 { 441 {
442 return this; 442 return this;
443 } 443 }
444 } 444 }
445 }; 445 };
446
447
448 // Polyfill Array.prototype.find
449 // from https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Ob jects/Array/find
450 // https://tc39.github.io/ecma262/#sec-array.prototype.find
451 if (!Array.prototype.find) {
452 Object.defineProperty(Array.prototype, 'find', {
453 value: function (predicate) {
454 // 1. Let O be ? ToObject(this value).
455 if (this == null) {
456 throw new TypeError('"this" is null or not defined');
457 }
458
459 var o = Object(this);
460
461 // 2. Let len be ? ToLength(? Get(O, "length")).
462 var len = o.length >>> 0;
463
464 // 3. If IsCallable(predicate) is false, throw a TypeError exception.
465 if (typeof predicate !== 'function') {
466 throw new TypeError('predicate must be a function');
467 }
468
469 // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
470 var thisArg = arguments[1];
471
472 // 5. Let k be 0.
473 var k = 0;
474
475 // 6. Repeat, while k < len
476 while (k < len) {
477 // a. Let Pk be ! ToString(k).
478 // b. Let kValue be ? Get(O, Pk).
479 // c. Let testResult be ToBoolean(? Call(predicate, T, "kValue, k, O")).
480 // d. If testResult is true, return kValue.
481 var kValue = o[k];
482 if (predicate.call(thisArg, kValue, k, o)) {
483 return kValue;
484 }
485 // e. Increase k by 1.
486 k++;
487 }
488 }
489 });
490 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld