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

Side by Side Diff: lib/coreUtils.js

Issue 29746555: Issue 6564 - Replace desc and extend with __proto__ (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created April 8, 2018, 8:57 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/filterClasses.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 "use strict"; 18 "use strict";
19 19
20 function desc(properties)
21 {
22 let descriptor = {};
23 let keys = Object.keys(properties);
24
25 for (let key of keys)
26 descriptor[key] = Object.getOwnPropertyDescriptor(properties, key);
27
28 return descriptor;
29 }
30 exports.desc = desc;
31
32 function extend(cls, properties)
33 {
34 return Object.create(cls.prototype, desc(properties));
35 }
36 exports.extend = extend;
37
38 function findIndex(iterable, callback, thisArg) 20 function findIndex(iterable, callback, thisArg)
39 { 21 {
40 let index = 0; 22 let index = 0;
41 for (let item of iterable) 23 for (let item of iterable)
42 { 24 {
43 if (callback.call(thisArg, item)) 25 if (callback.call(thisArg, item))
44 return index; 26 return index;
45 27
46 index++; 28 index++;
47 } 29 }
48 30
49 return -1; 31 return -1;
50 } 32 }
51 exports.findIndex = findIndex; 33 exports.findIndex = findIndex;
52 34
53 function indexOf(iterable, searchElement) 35 function indexOf(iterable, searchElement)
54 { 36 {
55 return findIndex(iterable, item => item === searchElement); 37 return findIndex(iterable, item => item === searchElement);
56 } 38 }
57 exports.indexOf = indexOf; 39 exports.indexOf = indexOf;
OLDNEW
« no previous file with comments | « no previous file | lib/filterClasses.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld