|
1 | 1 | ;(function(undefined) {
|
2 | 2 | 'use strict';
|
3 | 3 |
|
4 |
| - var _methods = {}, |
5 |
| - _indexes = {}, |
6 |
| - _initBindings = {}, |
7 |
| - _methodBindings = {}, |
| 4 | + var _methods = Object.create(null), |
| 5 | + _indexes = Object.create(null), |
| 6 | + _initBindings = Object.create(null), |
| 7 | + _methodBindings = Object.create(null), |
8 | 8 | _defaultSettings = {
|
9 | 9 | immutable: true,
|
10 | 10 | clone: true
|
|
62 | 62 | * ***************
|
63 | 63 | * These indexes just index data by ids.
|
64 | 64 | */
|
65 |
| - nodesIndex: {}, |
66 |
| - edgesIndex: {}, |
| 65 | + nodesIndex: Object.create(null), |
| 66 | + edgesIndex: Object.create(null), |
67 | 67 |
|
68 | 68 | /**
|
69 | 69 | * LOCAL INDEXES:
|
70 | 70 | * **************
|
71 | 71 | * These indexes refer from node to nodes. Each key is an id, and each
|
72 | 72 | * value is the array of the ids of related nodes.
|
73 | 73 | */
|
74 |
| - inNeighborsIndex: {}, |
75 |
| - outNeighborsIndex: {}, |
76 |
| - allNeighborsIndex: {}, |
| 74 | + inNeighborsIndex: Object.create(null), |
| 75 | + outNeighborsIndex: Object.create(null), |
| 76 | + allNeighborsIndex: Object.create(null), |
77 | 77 |
|
78 |
| - inNeighborsCount: {}, |
79 |
| - outNeighborsCount: {}, |
80 |
| - allNeighborsCount: {} |
| 78 | + inNeighborsCount: Object.create(null), |
| 79 | + outNeighborsCount: Object.create(null), |
| 80 | + allNeighborsCount: Object.create(null) |
81 | 81 | };
|
82 | 82 |
|
83 | 83 | // Execute bindings:
|
|
135 | 135 | var k;
|
136 | 136 |
|
137 | 137 | for (k in obj)
|
138 |
| - if (obj.hasOwnProperty(k)) |
| 138 | + if (!('hasOwnProperty' in obj) || obj.hasOwnProperty(k)) |
139 | 139 | delete obj[k];
|
140 | 140 |
|
141 | 141 | return obj;
|
|
177 | 177 | throw 'The method "' + methodName + '" already exists.';
|
178 | 178 |
|
179 | 179 | _methods[methodName] = fn;
|
180 |
| - _methodBindings[methodName] = {}; |
| 180 | + _methodBindings[methodName] = Object.create(null); |
181 | 181 |
|
182 | 182 | return this;
|
183 | 183 | };
|
|
328 | 328 |
|
329 | 329 | var k,
|
330 | 330 | id = node.id,
|
331 |
| - validNode = {}; |
| 331 | + validNode = Object.create(null); |
332 | 332 |
|
333 | 333 | // Check the "clone" option:
|
334 | 334 | if (this.settings('clone')) {
|
|
348 | 348 | validNode.id = id;
|
349 | 349 |
|
350 | 350 | // Add empty containers for edges indexes:
|
351 |
| - this.inNeighborsIndex[id] = {}; |
352 |
| - this.outNeighborsIndex[id] = {}; |
353 |
| - this.allNeighborsIndex[id] = {}; |
| 351 | + this.inNeighborsIndex[id] = Object.create(null); |
| 352 | + this.outNeighborsIndex[id] = Object.create(null); |
| 353 | + this.allNeighborsIndex[id] = Object.create(null); |
354 | 354 |
|
355 | 355 | this.inNeighborsCount[id] = 0;
|
356 | 356 | this.outNeighborsCount[id] = 0;
|
|
396 | 396 | throw 'The edge "' + edge.id + '" already exists.';
|
397 | 397 |
|
398 | 398 | var k,
|
399 |
| - validEdge = {}; |
| 399 | + validEdge = Object.create(null); |
400 | 400 |
|
401 | 401 | // Check the "clone" option:
|
402 | 402 | if (this.settings('clone')) {
|
|
433 | 433 | this.edgesIndex[validEdge.id] = validEdge;
|
434 | 434 |
|
435 | 435 | if (!this.inNeighborsIndex[edge.target][edge.source])
|
436 |
| - this.inNeighborsIndex[edge.target][edge.source] = {}; |
| 436 | + this.inNeighborsIndex[edge.target][edge.source] = Object.create(null); |
437 | 437 | this.inNeighborsIndex[edge.target][edge.source][edge.id] = edge;
|
438 | 438 |
|
439 | 439 | if (!this.outNeighborsIndex[edge.source][edge.target])
|
440 |
| - this.outNeighborsIndex[edge.source][edge.target] = {}; |
| 440 | + this.outNeighborsIndex[edge.source][edge.target] = Object.create(null); |
441 | 441 | this.outNeighborsIndex[edge.source][edge.target][edge.id] = edge;
|
442 | 442 |
|
443 | 443 | if (!this.allNeighborsIndex[edge.source][edge.target])
|
444 |
| - this.allNeighborsIndex[edge.source][edge.target] = {}; |
| 444 | + this.allNeighborsIndex[edge.source][edge.target] = Object.create(null); |
445 | 445 | this.allNeighborsIndex[edge.source][edge.target][edge.id] = edge;
|
446 | 446 |
|
447 | 447 | if (!this.allNeighborsIndex[edge.target][edge.source])
|
448 |
| - this.allNeighborsIndex[edge.target][edge.source] = {}; |
| 448 | + this.allNeighborsIndex[edge.target][edge.source] = Object.create(null); |
449 | 449 | this.allNeighborsIndex[edge.target][edge.source][edge.id] = edge;
|
450 | 450 |
|
451 | 451 | // Keep counts up to date:
|
|
778 | 778 | * *******
|
779 | 779 | */
|
780 | 780 | if (typeof sigma !== 'undefined') {
|
781 |
| - sigma.classes = sigma.classes || {}; |
| 781 | + sigma.classes = sigma.classes || Object.create(null); |
782 | 782 | sigma.classes.graph = graph;
|
783 | 783 | } else if (typeof exports !== 'undefined') {
|
784 | 784 | if (typeof module !== 'undefined' && module.exports)
|
|
0 commit comments